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)
puma (5.5.2)
nio4r (~> 2.0)
que (0.14.3)
que (1.0.0)
raabro (1.4.0)
racc (1.6.0)
rack (2.2.3)

View File

@ -4,8 +4,6 @@ module QueJobsManager
def setup
require "sequel"
ActiveJob::Base.queue_adapter = :que
Que.mode = :off
Que.worker_count = 1
end
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 'create database "#{db}"' -U #{user} -t template1}
Que.connection = Sequel.connect(que_url)
Que.migrate!
Que.migrate!(version: Que::Migrations::CURRENT_VERSION)
@thread = Thread.new do
loop do
Que::Job.work("integration_tests")
sleep 0.5
end
end
@locker = Que::Locker.new(
queues: ["integration_tests"],
poll_interval: 0.5,
worker_priorities: [nil]
)
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"
@ -37,6 +34,6 @@ module QueJobsManager
end
def stop_workers
@thread.kill
@locker.stop!
end
end