mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
I'm a TDD master.
This commit is contained in:
parent
79687c9910
commit
0e19aee7bf
2 changed files with 14 additions and 3 deletions
|
@ -72,7 +72,7 @@ module Sidekiq
|
|||
end
|
||||
|
||||
def self.bulk_requeue(inprogress)
|
||||
logger.debug { "Re-queueing terminated jobs" }
|
||||
Sidekiq.logger.debug { "Re-queueing terminated jobs" }
|
||||
jobs_to_requeue = {}
|
||||
inprogress.each do |unit_of_work|
|
||||
jobs_to_requeue[unit_of_work.queue] ||= []
|
||||
|
@ -84,7 +84,7 @@ module Sidekiq
|
|||
conn.rpush(queue, jobs)
|
||||
end
|
||||
end
|
||||
logger.info("Pushed #{inprogress.size} messages back to Redis")
|
||||
Sidekiq.logger.info("Pushed #{inprogress.size} messages back to Redis")
|
||||
end
|
||||
|
||||
UnitOfWork = Struct.new(:queue, :message) do
|
||||
|
|
|
@ -5,7 +5,7 @@ class TestFetcher < MiniTest::Unit::TestCase
|
|||
|
||||
def setup
|
||||
Sidekiq.redis do |conn|
|
||||
conn.del('queue:basic')
|
||||
conn.flushdb
|
||||
conn.rpush('queue:basic', 'msg')
|
||||
end
|
||||
end
|
||||
|
@ -28,4 +28,15 @@ class TestFetcher < MiniTest::Unit::TestCase
|
|||
cmd = fetch.queues_cmd
|
||||
assert_equal cmd, ['queue:basic', 'queue:bar', 1]
|
||||
end
|
||||
|
||||
def test_basic_fetch_bulk_requeue
|
||||
q1 = Sidekiq::Queue.new('foo')
|
||||
q2 = Sidekiq::Queue.new('bar')
|
||||
assert_equal 0, q1.size
|
||||
assert_equal 0, q2.size
|
||||
uow = Sidekiq::BasicFetch::UnitOfWork
|
||||
Sidekiq::BasicFetch.bulk_requeue([uow.new('queue:foo', 'bob'), uow.new('queue:foo', 'bar'), uow.new('queue:bar', 'widget')])
|
||||
assert_equal 2, q1.size
|
||||
assert_equal 1, q2.size
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue