mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Fix tests
This commit is contained in:
parent
752bfc6d8b
commit
89a1914d45
2 changed files with 9 additions and 24 deletions
|
@ -9,31 +9,24 @@ class TestLauncher < Sidekiq::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_manager(opts)
|
def new_manager(opts)
|
||||||
condvar = Minitest::Mock.new
|
Sidekiq::Manager.new(nil, opts)
|
||||||
condvar.expect(:signal, nil, [])
|
|
||||||
Sidekiq::Manager.new(condvar, opts)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'heartbeat' do
|
describe 'heartbeat' do
|
||||||
before do
|
before do
|
||||||
uow = Object.new
|
uow = Object.new
|
||||||
|
|
||||||
@processor = Minitest::Mock.new
|
|
||||||
@processor.expect(:request_process, nil, [uow])
|
|
||||||
@processor.expect(:hash, 1234, [])
|
|
||||||
|
|
||||||
@mgr = new_manager(options)
|
@mgr = new_manager(options)
|
||||||
@launcher = Sidekiq::Launcher.new(options)
|
@launcher = Sidekiq::Launcher.new(options)
|
||||||
@launcher.manager = @mgr
|
@launcher.manager = @mgr
|
||||||
|
|
||||||
@mgr.ready << @processor
|
Sidekiq::Processor::WORKER_STATE['a'] = {'b' => 1}
|
||||||
@mgr.assign(uow)
|
|
||||||
|
|
||||||
@processor.verify
|
|
||||||
@proctitle = $0
|
@proctitle = $0
|
||||||
end
|
end
|
||||||
|
|
||||||
after do
|
after do
|
||||||
|
Sidekiq::Processor::WORKER_STATE.clear
|
||||||
$0 = @proctitle
|
$0 = @proctitle
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -58,23 +51,17 @@ class TestLauncher < Sidekiq::Test
|
||||||
|
|
||||||
describe 'when manager is stopped' do
|
describe 'when manager is stopped' do
|
||||||
before do
|
before do
|
||||||
@processor.expect(:hash, 1234, [])
|
|
||||||
@processor.expect(:terminate, [])
|
|
||||||
|
|
||||||
@launcher.quiet
|
@launcher.quiet
|
||||||
@launcher.manager.processor_done(@processor)
|
|
||||||
@launcher.heartbeat('identity', heartbeat_data, Sidekiq.dump_json(heartbeat_data))
|
@launcher.heartbeat('identity', heartbeat_data, Sidekiq.dump_json(heartbeat_data))
|
||||||
|
|
||||||
@processor.verify
|
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'indicates stopping status in proctitle' do
|
it 'indicates stopping status in proctitle' do
|
||||||
assert_equal "sidekiq #{Sidekiq::VERSION} myapp [0 of 3 busy] stopping", $0
|
assert_equal "sidekiq #{Sidekiq::VERSION} myapp [1 of 3 busy] stopping", $0
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'stores process info in redis' do
|
it 'stores process info in redis' do
|
||||||
info = Sidekiq.redis { |c| c.hmget('identity', 'busy') }
|
info = Sidekiq.redis { |c| c.hmget('identity', 'busy') }
|
||||||
assert_equal ["0"], info
|
assert_equal ["1"], info
|
||||||
expires = Sidekiq.redis { |c| c.pttl('identity') }
|
expires = Sidekiq.redis { |c| c.pttl('identity') }
|
||||||
assert_in_delta 60000, expires, 50
|
assert_in_delta 60000, expires, 50
|
||||||
end
|
end
|
||||||
|
|
|
@ -172,10 +172,9 @@ class TestProcessor < Sidekiq::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'increments processed stat' do
|
it 'increments processed stat' do
|
||||||
assert_equal 0, Sidekiq::Stats.new.processed
|
Sidekiq::Processor::PROCESSED.value = 0
|
||||||
successful_job
|
successful_job
|
||||||
assert_equal 1, Sidekiq::Stats.new.processed
|
assert_equal 1, Sidekiq::Processor::PROCESSED.value
|
||||||
assert_equal Sidekiq::Processor::STATS_TIMEOUT, Sidekiq.redis { |conn| conn.ttl(processed_today_key) }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -191,10 +190,9 @@ class TestProcessor < Sidekiq::Test
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'increments failed stat' do
|
it 'increments failed stat' do
|
||||||
assert_equal 0, Sidekiq::Stats.new.failed
|
Sidekiq::Processor::FAILURE.value = 0
|
||||||
failed_job
|
failed_job
|
||||||
assert_equal 1, Sidekiq::Stats.new.failed
|
assert_equal 1, Sidekiq::Processor::FAILURE.value
|
||||||
assert_equal Sidekiq::Processor::STATS_TIMEOUT, Sidekiq.redis { |conn| conn.ttl(failed_today_key) }
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue