resque_stuck_queue 0.3.6 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA512:
3
- data.tar.gz: 2055181649b94897f6bfc18817199a35bf9a0324042da9a6ed15653bea22d459a7e5ba062ec57294c557d0ed2ab04df418bdce4b01f53e39ecae6771e7a39e16
4
- metadata.gz: 3fe6ae6af383d55311d5075d85b86b73fe2955c3f7149ab23c5e0adf61a999b4fdd706951efc3e39594786c0f4c20e3208c4037f9e705fe97ac301e4f04edca4
5
2
  SHA1:
6
- data.tar.gz: 3a99f92f2847757bb1db57e7c62bc80bc430f2c4
7
- metadata.gz: 940d63172246826ea3fbf12d883ecf44a5f76e53
3
+ data.tar.gz: 24838251cf63913fd05a55753101def684df1a4f
4
+ metadata.gz: 3d158d30adce28f9d8cde9ea0e26e7af7309c03a
5
+ SHA512:
6
+ data.tar.gz: 6765964aa3fd134a04682037125b45f680d9263221ca7c58d40791ad286a33fd3a3330b39ae1df51ad73f49dd480ecd8b8b990b46360205827af88d75c272122
7
+ metadata.gz: 2fe9d2eadd44d70d24ab2bc2fa18eae87b159f1b30372e7968b7e0c4a04fc43a069b8fe35e4b512101f37056c3535302ce02dd0d6395871aa48db129d739157c
@@ -6,10 +6,10 @@ module Resque
6
6
  attr_accessor :redis
7
7
 
8
8
  def perform(*args)
9
- keyname,host,port,namespace = *args
9
+ keyname,host,port,namespace,new_time = *args
10
10
  @redis = Redis::Namespace.new(namespace, :redis => Redis.new(:host => host, :port => port))
11
- @redis.set(keyname, Time.now.to_i)
12
- Resque::StuckQueue.logger.info "successfully updated key #{keyname}"
11
+ @redis.set(keyname, new_time)
12
+ Resque::StuckQueue.logger.info "successfully updated key #{keyname} to #{new_time} at #{Time.now}"
13
13
  end
14
14
 
15
15
  end
@@ -1,5 +1,5 @@
1
1
  module Resque
2
2
  module StuckQueue
3
- VERSION = "0.3.6"
3
+ VERSION = "0.3.7"
4
4
  end
5
5
  end
@@ -145,7 +145,7 @@ module Resque
145
145
  queues.each do |queue_name|
146
146
  # Redis::Namespace.new support as well as Redis.new
147
147
  namespace = redis.respond_to?(:namespace) ? redis.namespace : nil
148
- Resque.enqueue_to(queue_name, HeartbeatJob, heartbeat_key_for(queue_name), redis.client.host, redis.client.port, namespace )
148
+ Resque.enqueue_to(queue_name, HeartbeatJob, heartbeat_key_for(queue_name), redis.client.host, redis.client.port, namespace, Time.now.to_i )
149
149
  end
150
150
  end
151
151
  end
data/test/test_helper.rb CHANGED
@@ -18,6 +18,12 @@ module TestHelper
18
18
  pid
19
19
  end
20
20
 
21
+ def with_no_resque_failures(&blk)
22
+ Resque::Failure.clear
23
+ blk.call
24
+ assert_nil Resque::Failure.all, "Resque hearbeat job cant fail: #{Resque::Failure.all.inspect}"
25
+ end
26
+
21
27
  def hax_kill_resque
22
28
  # ugly, FIXME how to get pid of forked forked process. run_resque pid is incorrect.
23
29
  `ps aux |grep resque |awk '{print $2}' |xargs kill`
@@ -55,49 +55,51 @@ class TestIntegration < Minitest::Test
55
55
  def test_resque_enqueues_a_job_does_not_trigger
56
56
  puts "#{__method__}"
57
57
 
58
- Resque::Failure.clear
59
- Resque::StuckQueue.config[:trigger_timeout] = 10
60
- Resque::StuckQueue.config[:heartbeat] = 1
61
- @triggered = false
62
- Resque::StuckQueue.config[:triggered_handler] = proc { @triggered = true }
63
- start_and_stop_loops_after(5)
64
- Resque::StuckQueue.redis.del(SetRedisKey::NAME)
65
- Resque.enqueue_to(:app, SetRedisKey)
66
- sleep 3 # job ran successfully, so don't trigger
67
- assert_nil Resque::Failure.all, "Resque hearbeat job cant fail: #{Resque::Failure.all.inspect}"
68
- assert_equal @triggered, false
58
+ with_no_resque_failures do
59
+ Resque::StuckQueue.config[:trigger_timeout] = 10
60
+ Resque::StuckQueue.config[:heartbeat] = 1
61
+ @triggered = false
62
+ Resque::StuckQueue.config[:triggered_handler] = proc { @triggered = true }
63
+ start_and_stop_loops_after(5)
64
+ sleep 3 # job ran successfully, so don't trigger
65
+ assert_equal @triggered, false
66
+ end
69
67
  end
70
68
 
71
69
  def test_resque_does_not_enqueues_a_job_does_trigger
72
70
  puts "#{__method__}"
73
71
 
74
- Resque::StuckQueue.config[:trigger_timeout] = 0
75
- Resque::StuckQueue.config[:heartbeat] = 1
76
- @triggered = false
77
- Resque::StuckQueue.config[:triggered_handler] = proc { @triggered = true }
78
- start_and_stop_loops_after(2)
79
- # check handler did get called
80
- assert_equal @triggered, true
72
+ with_no_resque_failures do
73
+ Resque::StuckQueue.config[:trigger_timeout] = 0
74
+ Resque::StuckQueue.config[:heartbeat] = 1
75
+ @triggered = false
76
+ Resque::StuckQueue.config[:triggered_handler] = proc { @triggered = true }
77
+ start_and_stop_loops_after(2)
78
+ # check handler did get called
79
+ assert_equal @triggered, true
80
+ end
81
81
  end
82
82
 
83
83
  def test_has_settable_custom_hearbeat_job
84
84
  puts "#{__method__}"
85
85
 
86
- Resque::StuckQueue.config[:trigger_timeout] = 2 # won't allow waiting too much and will complain (eg trigger) sooner than later
87
- Resque::StuckQueue.config[:heartbeat] = 1
88
- Resque::StuckQueue.config[:redis] = Redis::Namespace.new(nil, :redis => Redis.new)
89
-
90
- begin
91
- Resque::StuckQueue.config[:heartbeat_job] = proc { Resque.enqueue_to(:app, Resque::StuckQueue::HeartbeatJob, Resque::StuckQueue.heartbeat_key_for(:app)) }
92
- @triggered = false
93
- Resque::StuckQueue.config[:triggered_handler] = proc { @triggered = true }
94
- start_and_stop_loops_after(4)
95
-
96
- sleep 3 # allow trigger
97
- assert true, "should not have raised"
98
- assert @triggered, "should have triggered"
99
- rescue => e
100
- assert false, "should have succeeded with good refresh_job.\n #{e.inspect}"
86
+ with_no_resque_failures do
87
+ Resque::StuckQueue.config[:trigger_timeout] = 2 # won't allow waiting too much and will complain (eg trigger) sooner than later
88
+ Resque::StuckQueue.config[:heartbeat] = 1
89
+ Resque::StuckQueue.config[:redis] = Redis::Namespace.new(nil, :redis => Redis.new)
90
+
91
+ begin
92
+ Resque::StuckQueue.config[:heartbeat_job] = proc { Resque.enqueue_to(:app, Resque::StuckQueue::HeartbeatJob, Resque::StuckQueue.heartbeat_key_for(:app)) }
93
+ @triggered = false
94
+ Resque::StuckQueue.config[:triggered_handler] = proc { @triggered = true }
95
+ start_and_stop_loops_after(4)
96
+
97
+ sleep 3 # allow trigger
98
+ assert true, "should not have raised"
99
+ assert @triggered, "should have triggered"
100
+ rescue => e
101
+ assert false, "should have succeeded with good refresh_job.\n #{e.inspect}"
102
+ end
101
103
  end
102
104
  end
103
105
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque_stuck_queue
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shai Rosenfeld