1
0
Fork 0
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:
Mike Perham 2015-07-10 09:29:38 -07:00
commit 0b7941cafd
2 changed files with 28 additions and 4 deletions

View file

@ -28,3 +28,10 @@ pre-start script
start sidekiq index=$i start sidekiq index=$i
done done
end script end script
post-stop script
for i in `seq 1 ${NUM_WORKERS}`
do
stop sidekiq index=$i
done
end script

View file

@ -39,18 +39,35 @@ class TestRetry < Sidekiq::Test
it 'allows a numeric retry' do it 'allows a numeric retry' do
@redis.expect :zadd, 1, ['retry', String, String] @redis.expect :zadd, 1, ['retry', String, String]
msg = { 'class' => 'Bob', 'args' => [1,2,'foo'], 'retry' => 2 } msg = { 'class' => 'Bob', 'args' => [1,2,'foo'], 'retry' => 2 }
msg2 = msg.dup
handler = Sidekiq::Middleware::Server::RetryJobs.new handler = Sidekiq::Middleware::Server::RetryJobs.new
assert_raises RuntimeError do assert_raises RuntimeError do
handler.call(worker, msg2, 'default') do handler.call(worker, msg, 'default') do
raise "kerblammo!" raise "kerblammo!"
end end
end end
msg2.delete('failed_at') 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}, msg2) assert_equal({"class"=>"Bob", "args"=>[1, 2, "foo"], "retry"=>2, "queue"=>"default", "error_message"=>"kerblammo!", "error_class"=>"RuntimeError", "retry_count"=>0}, msg)
@redis.verify @redis.verify
end 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 it 'handles zany characters in error message, #1705' do
skip 'skipped! test requires ruby 2.1+' if RUBY_VERSION <= '2.1.0' skip 'skipped! test requires ruby 2.1+' if RUBY_VERSION <= '2.1.0'
@redis.expect :zadd, 1, ['retry', String, String] @redis.expect :zadd, 1, ['retry', String, String]