提交 d7a058f7 编写于 作者: M Matthew Draper

Make AJ integration tests much less verbose

In passing, avoid a blind retry in QC: instead, just fix the problem.
上级 d13b75bc
......@@ -10,7 +10,7 @@ def clear_jobs
end
def start_workers
@worker = Delayed::Worker.new(quiet: false, sleep_delay: 0.5, queues: %w(integration_tests))
@worker = Delayed::Worker.new(quiet: true, sleep_delay: 0.5, queues: %w(integration_tests))
@thread = Thread.new { @worker.start }
end
......
......@@ -2,12 +2,12 @@ module QueJobsManager
def setup
require 'sequel'
ActiveJob::Base.queue_adapter = :que
que_url = ENV['QUE_DATABASE_URL'] || 'postgres://localhost/active_jobs_que_int_test'
que_url = ENV['QUE_DATABASE_URL'] || 'postgres:///active_jobs_que_int_test'
uri = URI.parse(que_url)
user = uri.user||ENV['USER']
pass = uri.password
db = uri.path[1..-1]
%x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'drop database "#{db}"' -U #{user} -t template1}
%x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'drop database if exists "#{db}"' -U #{user} -t template1}
%x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'create database "#{db}"' -U #{user} -t template1}
Que.connection = Sequel.connect(que_url)
Que.migrate!
......
module QueueClassicJobsManager
def setup
ENV['QC_DATABASE_URL'] ||= 'postgres://localhost/active_jobs_qc_int_test'
ENV['QC_DATABASE_URL'] ||= 'postgres:///active_jobs_qc_int_test'
ENV['QC_LISTEN_TIME'] = "0.5"
uri = URI.parse(ENV['QC_DATABASE_URL'])
user = uri.user||ENV['USER']
pass = uri.password
db = uri.path[1..-1]
%x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'drop database "#{db}"' -U #{user} -t template1}
%x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'drop database if exists "#{db}"' -U #{user} -t template1}
%x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -c 'create database "#{db}"' -U #{user} -t template1}
ActiveJob::Base.queue_adapter = :queue_classic
QC::Setup.create
......@@ -17,23 +17,11 @@ def setup
def clear_jobs
QC::Queue.new("integration_tests").delete_all
retried = false
rescue => e
puts "Got exception while trying to clear jobs: #{e.inspect}"
if retried
puts "Already retried. Raising exception"
raise e
else
puts "Retrying"
retried = true
QC::Conn.connection = QC::Conn.connect
retry
end
end
def start_workers
QC::Conn.disconnect
@pid = fork do
QC::Conn.connection = QC::Conn.connect
worker = QC::Worker.new(q_name: 'integration_tests')
worker.start
end
......
......@@ -17,13 +17,15 @@ def clear_jobs
def start_workers
@resque_thread = Thread.new do
Resque::Worker.new("integration_tests").work(0.5)
w = Resque::Worker.new("integration_tests")
w.term_child = true
w.work(0.5)
end
@scheduler_thread = Thread.new do
Resque::Scheduler.configure do |c|
c.poll_sleep_amount = 0.5
c.dynamic = true
c.verbose = true
c.quiet = true
c.logfile = nil
end
Resque::Scheduler.master_lock.release!
......
......@@ -29,7 +29,6 @@ def start_workers
"--concurrency", "1",
"--timeout", "1",
"--daemon",
"--verbose"
])
require 'celluloid'
require 'sidekiq/scheduled'
......
module SuckerPunchJobsManager
def setup
ActiveJob::Base.queue_adapter = :sucker_punch
SuckerPunch.logger = nil
end
end
if ENV['AJADAPTER'] == 'delayed_job'
generate "delayed_job:active_record"
generate "delayed_job:active_record", "--quiet"
rake("db:migrate")
end
......
puts "\n\n"
puts "*** Running integration tests for #{ENV['AJADAPTER']} ***"
puts "\n\n"
puts "*** rake aj:integration:#{ENV['AJADAPTER']} ***\n"
ENV["RAILS_ENV"] = "test"
ActiveJob::Base.queue_name_prefix = nil
......@@ -10,7 +8,7 @@
dummy_app_path = Dir.mktmpdir + "/dummy"
dummy_app_template = File.expand_path("../dummy_app_template.rb", __FILE__)
args = Rails::Generators::ARGVScrubber.new(["new", dummy_app_path, "--skip-gemfile", "--skip-bundle",
"--skip-git", "--skip-spring", "-d", "sqlite3", "--skip-javascript", "--force", "--quite",
"--skip-git", "--skip-spring", "-d", "sqlite3", "--skip-javascript", "--force", "--quiet",
"--template", dummy_app_template]).prepare!
Rails::Generators::AppGenerator.start args
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册