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:
Hartley McGuire 2022-01-27 16:11:53 -05:00
parent efae65d005
commit f83f5c81af
2 changed files with 8 additions and 11 deletions

View File

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

View File

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