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

Test handling exceptions during Sidekiq::Shutdown.

This commit is contained in:
Kevin Yank 2014-06-30 16:58:19 +10:00
parent bc63d0bea3
commit 025327c6f4

View file

@ -117,6 +117,60 @@ class TestRetry < Sidekiq::Test
@redis.verify
end
it 'shuts down without retrying work-in-progress, which will resume' do
@redis.expect :zadd, 1, ['retry', String, String]
msg = { 'class' => 'Bob', 'args' => [1,2,'foo'], 'retry' => true }
handler = Sidekiq::Middleware::Server::RetryJobs.new
assert_raises Sidekiq::Shutdown do
handler.call(worker, msg, 'default') do
raise Sidekiq::Shutdown
end
end
assert_raises(MockExpectationError, "zadd should not be called") do
@redis.verify
end
end
it 'shuts down cleanly when shutdown causes exception' do
@redis.expect :zadd, 1, ['retry', String, String]
msg = { 'class' => 'Bob', 'args' => [1,2,'foo'], 'retry' => true }
handler = Sidekiq::Middleware::Server::RetryJobs.new
assert_raises Sidekiq::Shutdown do
handler.call(worker, msg, 'default') do
begin
raise Sidekiq::Shutdown
rescue Interrupt
raise "kerblammo!"
end
end
end
assert_raises(MockExpectationError, "zadd should not be called") do
@redis.verify
end
end
it 'shuts down cleanly when shutdown causes chained exceptions' do
@redis.expect :zadd, 1, ['retry', String, String]
msg = { 'class' => 'Bob', 'args' => [1,2,'foo'], 'retry' => true }
handler = Sidekiq::Middleware::Server::RetryJobs.new
assert_raises Sidekiq::Shutdown do
handler.call(worker, msg, 'default') do
begin
raise Sidekiq::Shutdown
rescue Interrupt
begin
raise "kerblammo!"
rescue
raise "kablooie!"
end
end
end
end
assert_raises(MockExpectationError, "zadd should not be called") do
@redis.verify
end
end
it 'allows a retry queue' do
@redis.expect :zadd, 1, ['retry', String, String]
msg = { 'class' => 'Bob', 'args' => [1,2,'foo'], 'retry' => true, 'retry_queue' => 'retry' }