1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activejob/test/support/integration/adapters/resque.rb
yuuji.yaginuma 8e964556e7 Make sidekiq and resque integration tests work in CI
Since 8f2490b, the integration test of sidekiq and resque is not working
in CI.
https://travis-ci.org/rails/rails/jobs/301276197#L2055
https://travis-ci.org/rails/rails/jobs/301276197#L2061

Because 8f2490b removed password from `redis-server`.
So must also remove passwords from these tests.
2017-11-13 21:02:40 +09:00

49 lines
1.3 KiB
Ruby

# frozen_string_literal: true
module ResqueJobsManager
def setup
ActiveJob::Base.queue_adapter = :resque
Resque.redis = Redis::Namespace.new "active_jobs_int_test", redis: Redis.new(url: "redis://127.0.0.1:6379/12", thread_safe: true)
Resque.logger = Rails.logger
unless can_run?
puts "Cannot run integration tests for resque. To be able to run integration tests for resque you need to install and start redis.\n"
status = ENV["CI"] ? false : true
exit status
end
end
def clear_jobs
Resque.queues.each { |queue_name| Resque.redis.del "queue:#{queue_name}" }
Resque.redis.keys("delayed:*").each { |key| Resque.redis.del "#{key}" }
Resque.redis.del "delayed_queue_schedule"
end
def start_workers
@resque_thread = Thread.new do
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.quiet = true
c.logfile = nil
end
Resque::Scheduler.master_lock.release!
Resque::Scheduler.run
end
end
def stop_workers
@resque_thread.kill
@scheduler_thread.kill
end
def can_run?
Resque.redis.ping == "PONG"
rescue
false
end
end