mirror of https://github.com/rails/rails
fix Que integration tests for Active Job
Replace Que.* settings that were removed in Que 1.0 with options passed to Que::Locker. The Locker class creates its own thread for managing work distribution, so the Thread created in the QueJobsManager was also removed.
This commit is contained in:
parent
efae65d005
commit
f83f5c81af
|
@ -403,7 +403,7 @@ GEM
|
||||||
public_suffix (4.0.6)
|
public_suffix (4.0.6)
|
||||||
puma (5.5.2)
|
puma (5.5.2)
|
||||||
nio4r (~> 2.0)
|
nio4r (~> 2.0)
|
||||||
que (0.14.3)
|
que (1.0.0)
|
||||||
raabro (1.4.0)
|
raabro (1.4.0)
|
||||||
racc (1.6.0)
|
racc (1.6.0)
|
||||||
rack (2.2.3)
|
rack (2.2.3)
|
||||||
|
|
|
@ -4,8 +4,6 @@ module QueJobsManager
|
||||||
def setup
|
def setup
|
||||||
require "sequel"
|
require "sequel"
|
||||||
ActiveJob::Base.queue_adapter = :que
|
ActiveJob::Base.queue_adapter = :que
|
||||||
Que.mode = :off
|
|
||||||
Que.worker_count = 1
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def clear_jobs
|
def clear_jobs
|
||||||
|
@ -21,14 +19,13 @@ module QueJobsManager
|
||||||
%x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -X -c 'drop database if exists "#{db}"' -U #{user} -t template1}
|
%x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -X -c 'drop database if exists "#{db}"' -U #{user} -t template1}
|
||||||
%x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -X -c 'create database "#{db}"' -U #{user} -t template1}
|
%x{#{"PGPASSWORD=\"#{pass}\"" if pass} psql -X -c 'create database "#{db}"' -U #{user} -t template1}
|
||||||
Que.connection = Sequel.connect(que_url)
|
Que.connection = Sequel.connect(que_url)
|
||||||
Que.migrate!
|
Que.migrate!(version: Que::Migrations::CURRENT_VERSION)
|
||||||
|
|
||||||
@thread = Thread.new do
|
@locker = Que::Locker.new(
|
||||||
loop do
|
queues: ["integration_tests"],
|
||||||
Que::Job.work("integration_tests")
|
poll_interval: 0.5,
|
||||||
sleep 0.5
|
worker_priorities: [nil]
|
||||||
end
|
)
|
||||||
end
|
|
||||||
|
|
||||||
rescue Sequel::DatabaseConnectionError
|
rescue Sequel::DatabaseConnectionError
|
||||||
puts "Cannot run integration tests for que. To be able to run integration tests for que you need to install and start postgresql.\n"
|
puts "Cannot run integration tests for que. To be able to run integration tests for que you need to install and start postgresql.\n"
|
||||||
|
@ -37,6 +34,6 @@ module QueJobsManager
|
||||||
end
|
end
|
||||||
|
|
||||||
def stop_workers
|
def stop_workers
|
||||||
@thread.kill
|
@locker.stop!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue