Sha256: 1dda65cf5d808d6da4aec36c2c58c72b1d8d7c2f47944bb9435bebfd0b8d287d
Contents?: true
Size: 1.55 KB
Versions: 4
Compression:
Stored size: 1.55 KB
Contents
require 'test_helper' class RetryTest < Minitest::Test def setup Resque.redis.flushall @worker = Resque::Worker.new(:testing) @worker.register_worker end def test_retry_delay_per_exception_single_delay # store start time for later comparison with retry delay. start_time = Time.now.to_i # work the job a couple of times to build up some delayed jobs. 3.times do Resque.enqueue(PerExceptionClassRetryCountJob) perform_next_job(@worker) end # double check job counts. assert_equal 3, Resque.info[:failed], 'failed jobs' assert_equal 3, Resque.info[:processed], 'processed job' assert_equal 0, Resque.info[:pending], 'zero pending jobs as their delayed' # now lets see if the delays are correct? delayed = Resque.delayed_queue_peek(0, 3) assert_in_delta (start_time + 7), delayed[0], 1.00, 'retry delay timestamp' end def test_retry_delay_per_exception_multiple_delay # store start time for later comparison with retry delay. start_time = Time.now.to_i # work the job a couple of times to build up some delayed jobs. 3.times do Resque.enqueue(PerExceptionClassRetryCountArrayJob) perform_next_job(@worker) end # now lets see if the delays are correct? delayed = Resque.delayed_queue_peek(0, 3) assert_in_delta (start_time + 5), delayed[0], 1.00, '1st retry delay timestamp' assert_in_delta (start_time + 10), delayed[1], 1.00, '2nd retry delay timestamp' assert_in_delta (start_time + 15), delayed[2], 1.00, '3rd retry delay timestamp' end end
Version data entries
4 entries across 4 versions & 1 rubygems