mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Merge branch 'master' of github.com:mperham/sidekiq
This commit is contained in:
commit
0b7941cafd
2 changed files with 28 additions and 4 deletions
|
@ -28,3 +28,10 @@ pre-start script
|
|||
start sidekiq index=$i
|
||||
done
|
||||
end script
|
||||
|
||||
post-stop script
|
||||
for i in `seq 1 ${NUM_WORKERS}`
|
||||
do
|
||||
stop sidekiq index=$i
|
||||
done
|
||||
end script
|
||||
|
|
|
@ -39,18 +39,35 @@ class TestRetry < Sidekiq::Test
|
|||
it 'allows a numeric retry' do
|
||||
@redis.expect :zadd, 1, ['retry', String, String]
|
||||
msg = { 'class' => 'Bob', 'args' => [1,2,'foo'], 'retry' => 2 }
|
||||
msg2 = msg.dup
|
||||
handler = Sidekiq::Middleware::Server::RetryJobs.new
|
||||
assert_raises RuntimeError do
|
||||
handler.call(worker, msg2, 'default') do
|
||||
handler.call(worker, msg, 'default') do
|
||||
raise "kerblammo!"
|
||||
end
|
||||
end
|
||||
msg2.delete('failed_at')
|
||||
assert_equal({"class"=>"Bob", "args"=>[1, 2, "foo"], "retry"=>2, "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "retry_count"=>0}, msg2)
|
||||
msg.delete('failed_at')
|
||||
assert_equal({"class"=>"Bob", "args"=>[1, 2, "foo"], "retry"=>2, "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "retry_count"=>0}, msg)
|
||||
@redis.verify
|
||||
end
|
||||
|
||||
it 'allows 0 retry => no retry and dead queue' do
|
||||
@redis.expect :zadd, 1, ['dead', Float, String]
|
||||
@redis.expect :zremrangebyscore, 0, ['dead', String, Float]
|
||||
@redis.expect :zremrangebyrank, 0, ['dead', Numeric, Numeric]
|
||||
msg = { 'class' => 'Bob', 'args' => [1,2,'foo'], 'retry' => 0 }
|
||||
msg2 = msg.dup
|
||||
handler = Sidekiq::Middleware::Server::RetryJobs.new
|
||||
assert_raises RuntimeError do
|
||||
handler.call(worker, msg, 'default') do
|
||||
raise "kerblammo!"
|
||||
end
|
||||
end
|
||||
msg.delete('failed_at')
|
||||
expected = msg2.merge "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "retry_count"=>0
|
||||
assert_equal expected, msg
|
||||
@redis.verify # not called
|
||||
end
|
||||
|
||||
it 'handles zany characters in error message, #1705' do
|
||||
skip 'skipped! test requires ruby 2.1+' if RUBY_VERSION <= '2.1.0'
|
||||
@redis.expect :zadd, 1, ['retry', String, String]
|
||||
|
|
Loading…
Reference in a new issue