Sha256: f35ef3a01546ebdfceb848a671fd0e1e1c5499dcb15be4ed0e4a75c467498ed1
Contents?: true
Size: 1.87 KB
Versions: 2
Compression:
Stored size: 1.87 KB
Contents
require 'helper' require 'sidekiq' require 'sidekiq/processor' class TestStats < MiniTest::Unit::TestCase describe 'with redis' do before do @redis = Sidekiq.redis = REDIS Sidekiq.redis {|c| c.flushdb } end class DumbWorker include Sidekiq::Worker def perform(arg) raise 'bang' if arg == nil end end it 'updates global stats in the success case' do msg = { 'class' => DumbWorker.to_s, 'args' => [""] } boss = MiniTest::Mock.new @redis.with do |conn| set = conn.smembers('workers') assert_equal 0, set.size processor = Sidekiq::Processor.new(boss) boss.expect(:processor_done!, nil, [processor]) assert_equal 0, conn.get('stat:failed').to_i assert_equal 0, conn.get('stat:processed').to_i assert_equal 0, conn.get("stat:processed:#{processor}").to_i processor.process(msg, 'xyzzy') processor.process(msg, 'xyzzy') processor.process(msg, 'xyzzy') assert_equal 0, conn.get('stat:failed').to_i assert_equal 3, conn.get('stat:processed').to_i assert_equal 3, conn.get("stat:processed:#{processor}").to_i end end it 'updates global stats in the error case' do msg = { 'class' => DumbWorker.to_s, 'args' => [nil] } boss = MiniTest::Mock.new @redis.with do |conn| assert_equal [], conn.smembers('workers') assert_equal 0, conn.get('stat:failed').to_i assert_equal 0, conn.get('stat:processed').to_i processor = Sidekiq::Processor.new(boss) pstr = processor.to_s assert_raises RuntimeError do processor.process(msg, 'xyzzy') end assert_equal 1, conn.get('stat:failed').to_i assert_equal 1, conn.get('stat:processed').to_i assert_equal nil, conn.get("stat:processed:#{pstr}") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sidekiq-1.2.0 | test/test_stats.rb |
sidekiq-1.1.4 | test/test_stats.rb |