1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Make AJ integration tests much less verbose

In passing, avoid a blind retry in QC: instead, just fix the problem.
This commit is contained in:
Matthew Draper 2014-09-27 21:55:03 +09:30
parent d13b75bc26
commit d7a058f785
8 changed files with 14 additions and 26 deletions

View file

@ -10,7 +10,7 @@ module DelayedJobJobsManager
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

View file

@ -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!

View file

@ -1,12 +1,12 @@
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 @@ module QueueClassicJobsManager
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

View file

@ -17,13 +17,15 @@ module ResqueJobsManager
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!

View file

@ -29,7 +29,6 @@ module SidekiqJobsManager
"--concurrency", "1",
"--timeout", "1",
"--daemon",
"--verbose"
])
require 'celluloid'
require 'sidekiq/scheduled'

View file

@ -1,5 +1,6 @@
module SuckerPunchJobsManager
def setup
ActiveJob::Base.queue_adapter = :sucker_punch
SuckerPunch.logger = nil
end
end

View file

@ -1,5 +1,5 @@
if ENV['AJADAPTER'] == 'delayed_job'
generate "delayed_job:active_record"
generate "delayed_job:active_record", "--quiet"
rake("db:migrate")
end

View file

@ -1,6 +1,4 @@
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 @@ require 'rails/generators/rails/app/app_generator'
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