mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00

* Initial work on Sidekiq::Config * Initial work on Sidekiq::Config * reduce dependencies in deploy marks * bare sidekiq and webapp * Modify runtime to work with Capsules * Cleanup * Rename test files to remove test_ prefix * Update test suite and standard rules to be more compliant * Move constant definition outside code, per standard formatting * Loads of changes for introduction of Capsules * Remove Redis adapter abstraction * update capsule overview * Ensure Sidekiq.redis uses the correct pool for jobs running within a Capsule * Use default_capsule for safety * Slow down the beat to halve its Redis overhead * move config fixtures into cfg/ * Add capsule middleware test * use accessor
47 lines
1.7 KiB
Ruby
47 lines
1.7 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
require_relative "helper"
|
|
require "sidekiq/api"
|
|
|
|
describe "DeadSet" do
|
|
def dead_set
|
|
Sidekiq::DeadSet.new
|
|
end
|
|
|
|
it 'should put passed serialized job to the "dead" sorted set' do
|
|
serialized_job = Sidekiq.dump_json(jid: "123123", class: "SomeWorker", args: [])
|
|
dead_set.kill(serialized_job)
|
|
|
|
assert_equal dead_set.find_job("123123").value, serialized_job
|
|
end
|
|
|
|
it "should remove dead jobs older than Sidekiq::DeadSet.timeout" do
|
|
old, Sidekiq::Config::DEFAULTS[:dead_timeout_in_seconds] = Sidekiq::Config::DEFAULTS[:dead_timeout_in_seconds], 10
|
|
Time.stub(:now, Time.now - 11) do
|
|
dead_set.kill(Sidekiq.dump_json(jid: "000103", class: "MyWorker3", args: [])) # the oldest
|
|
end
|
|
Time.stub(:now, Time.now - 9) do
|
|
dead_set.kill(Sidekiq.dump_json(jid: "000102", class: "MyWorker2", args: []))
|
|
end
|
|
dead_set.kill(Sidekiq.dump_json(jid: "000101", class: "MyWorker1", args: []))
|
|
|
|
assert_nil dead_set.find_job("000103")
|
|
assert dead_set.find_job("000102")
|
|
assert dead_set.find_job("000101")
|
|
ensure
|
|
Sidekiq::Config::DEFAULTS[:dead_timeout_in_seconds] = old
|
|
end
|
|
|
|
it "should remove all but last Sidekiq::DeadSet.max_jobs-1 jobs" do
|
|
old, Sidekiq::Config::DEFAULTS[:dead_max_jobs] = Sidekiq::Config::DEFAULTS[:dead_max_jobs], 3
|
|
dead_set.kill(Sidekiq.dump_json(jid: "000101", class: "MyWorker1", args: []))
|
|
dead_set.kill(Sidekiq.dump_json(jid: "000102", class: "MyWorker2", args: []))
|
|
dead_set.kill(Sidekiq.dump_json(jid: "000103", class: "MyWorker3", args: []))
|
|
|
|
assert_nil dead_set.find_job("000101")
|
|
assert dead_set.find_job("000102")
|
|
assert dead_set.find_job("000103")
|
|
ensure
|
|
Sidekiq::Config::DEFAULTS[:dead_max_jobs] = old
|
|
end
|
|
end
|