resque-scheduler 4.2.0 → 4.2.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of resque-scheduler might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +18 -9
- data/.travis.yml +6 -13
- data/HISTORY.md +8 -0
- data/README.md +2 -2
- data/examples/config/initializers/resque-web.rb +10 -10
- data/examples/dynamic-scheduling/app/jobs/fix_schedules_job.rb +1 -1
- data/lib/resque/scheduler.rb +6 -5
- data/lib/resque/scheduler/cli.rb +2 -2
- data/lib/resque/scheduler/delaying_extensions.rb +17 -17
- data/lib/resque/scheduler/lock/base.rb +2 -2
- data/lib/resque/scheduler/locking.rb +2 -0
- data/lib/resque/scheduler/server.rb +8 -7
- data/lib/resque/scheduler/server/views/search.erb +1 -1
- data/lib/resque/scheduler/signal_handling.rb +1 -1
- data/lib/resque/scheduler/util.rb +5 -5
- data/lib/resque/scheduler/version.rb +1 -1
- data/resque-scheduler.gemspec +3 -3
- data/test/delayed_queue_test.rb +2 -2
- data/test/multi_process_test.rb +2 -2
- data/test/resque-web_test.rb +39 -5
- data/test/scheduler_args_test.rb +5 -5
- data/test/scheduler_test.rb +4 -4
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81fff7dfc51eb7cddf965e33bb199119c5e89654
|
4
|
+
data.tar.gz: ad07b64387f32238e6d40ddd7a23013909690525
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 352f5afdf0b0298c325e69cd2602e327f43f27a32286c5d07c1a7bab3d68848eabfc01d3d7c2b403c1250eaf1f43cee3fc1b0070bed57da3ff152cc322ee70f4
|
7
|
+
data.tar.gz: 02404afea3608f6280be6f6e7063a08e5eb75177a28506bea7a60960c3792bb68243d4701b76a3a4d62fdc1b052e744eb2c949a23cddc915032a0c137c5df2cb
|
data/.rubocop_todo.yml
CHANGED
@@ -1,18 +1,22 @@
|
|
1
1
|
# This configuration was generated by
|
2
2
|
# `rubocop --auto-gen-config`
|
3
|
-
# on 2016-
|
3
|
+
# on 2016-05-27 14:45:04 -0400 using RuboCop version 0.40.0.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
|
-
# Offense count:
|
9
|
+
# Offense count: 1
|
10
10
|
# Configuration parameters: AllowSafeAssignment.
|
11
11
|
Lint/AssignmentInCondition:
|
12
12
|
Exclude:
|
13
|
-
- 'lib/resque/scheduler/delaying_extensions.rb'
|
14
13
|
- 'lib/resque/scheduler/env.rb'
|
15
14
|
|
15
|
+
# Offense count: 2
|
16
|
+
Lint/UselessAccessModifier:
|
17
|
+
Exclude:
|
18
|
+
- 'lib/resque/scheduler.rb'
|
19
|
+
|
16
20
|
# Offense count: 16
|
17
21
|
Metrics/AbcSize:
|
18
22
|
Max: 36
|
@@ -21,10 +25,11 @@ Metrics/AbcSize:
|
|
21
25
|
Metrics/CyclomaticComplexity:
|
22
26
|
Max: 12
|
23
27
|
|
24
|
-
# Offense count:
|
25
|
-
# Configuration parameters: AllowURI, URISchemes.
|
28
|
+
# Offense count: 6
|
29
|
+
# Configuration parameters: AllowHeredoc, AllowURI, URISchemes.
|
30
|
+
# URISchemes: http, https
|
26
31
|
Metrics/LineLength:
|
27
|
-
Max:
|
32
|
+
Max: 96
|
28
33
|
|
29
34
|
# Offense count: 19
|
30
35
|
# Configuration parameters: CountComments.
|
@@ -47,16 +52,20 @@ Style/EachWithObject:
|
|
47
52
|
- 'lib/resque/scheduler.rb'
|
48
53
|
|
49
54
|
# Offense count: 3
|
50
|
-
# Configuration parameters:
|
55
|
+
# Configuration parameters: ExpectMatchingDefinition, Regex, IgnoreExecutableScripts.
|
51
56
|
Style/FileName:
|
52
57
|
Exclude:
|
53
58
|
- 'examples/config/initializers/resque-web.rb'
|
54
59
|
- 'lib/resque-scheduler.rb'
|
55
60
|
- 'test/resque-web_test.rb'
|
56
61
|
|
57
|
-
# Offense count:
|
62
|
+
# Offense count: 1
|
58
63
|
# Configuration parameters: MinBodyLength.
|
59
64
|
Style/GuardClause:
|
60
65
|
Exclude:
|
61
|
-
- 'lib/resque/scheduler.rb'
|
62
66
|
- 'lib/resque/scheduler/lock/basic.rb'
|
67
|
+
|
68
|
+
# Offense count: 1
|
69
|
+
Style/IfInsideElse:
|
70
|
+
Exclude:
|
71
|
+
- 'lib/resque/scheduler.rb'
|
data/.travis.yml
CHANGED
@@ -2,25 +2,18 @@ language: ruby
|
|
2
2
|
sudo: false
|
3
3
|
rvm:
|
4
4
|
- 1.9.3
|
5
|
-
- 2.3.
|
6
|
-
- jruby-
|
7
|
-
- rbx
|
5
|
+
- 2.3.1
|
6
|
+
- jruby-9.1.1.0
|
8
7
|
env:
|
9
8
|
global:
|
10
|
-
- JRUBY_OPTS='-Xcext.enabled=true'
|
11
9
|
- COVERAGE=1
|
10
|
+
- JRUBY_OPTS=''
|
11
|
+
- RUBYOPT='-W0'
|
12
12
|
matrix:
|
13
13
|
allow_failures:
|
14
|
-
- rvm: jruby-
|
15
|
-
- rvm: rbx
|
14
|
+
- rvm: jruby-9.1.1.0
|
16
15
|
services:
|
17
16
|
- redis-server
|
18
|
-
notifications:
|
19
|
-
irc:
|
20
|
-
channels:
|
21
|
-
- 'chat.freenode.net#resque'
|
22
|
-
on_success: change
|
23
|
-
on_failure: change
|
24
17
|
deploy:
|
25
18
|
provider: rubygems
|
26
19
|
api_key:
|
@@ -29,5 +22,5 @@ deploy:
|
|
29
22
|
on:
|
30
23
|
tags: true
|
31
24
|
repo: resque/resque-scheduler
|
32
|
-
rvm: 2.3.
|
25
|
+
rvm: 2.3.1
|
33
26
|
all_branches: true
|
data/HISTORY.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Resque Scheduler History / ChangeLog / Release Notes
|
2
2
|
|
3
|
+
## 4.2.1 (2016-06-08)
|
4
|
+
* Optimization of `find_delayed_selection`
|
5
|
+
* More defensive code around redis disconnects
|
6
|
+
* Only trap existing signals on given platform
|
7
|
+
* RuboCop auto-fixes
|
8
|
+
* Dependency updates
|
9
|
+
* Docs improvements
|
10
|
+
|
3
11
|
## 4.2.0 (2016-04-29)
|
4
12
|
* Bugfix for a race condition in concurrent restarts
|
5
13
|
* Clean up and simplify the scheduling extension
|
data/README.md
CHANGED
@@ -19,9 +19,9 @@ jobs are resque jobs that you want to run at some point in the future.
|
|
19
19
|
The syntax is pretty explanatory:
|
20
20
|
|
21
21
|
```ruby
|
22
|
-
Resque.enqueue_in(5.days, SendFollowupEmail) #
|
22
|
+
Resque.enqueue_in(5.days, SendFollowupEmail, argument) # runs a job in 5 days, calling SendFollowupEmail.perform(argument)
|
23
23
|
# or
|
24
|
-
Resque.enqueue_at(5.days.from_now, SomeJob) #
|
24
|
+
Resque.enqueue_at(5.days.from_now, SomeJob, argument) # runs a job at a specific time, calling SomeJob.perform(argument)
|
25
25
|
```
|
26
26
|
|
27
27
|
### Documentation
|
@@ -12,20 +12,20 @@ require 'resque/scheduler/server'
|
|
12
12
|
|
13
13
|
schedule_yml = ENV['RESQUE_SCHEDULE_YML']
|
14
14
|
if schedule_yml
|
15
|
-
if File.exist?(schedule_yml)
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
Resque.schedule = if File.exist?(schedule_yml)
|
16
|
+
YAML.load_file(schedule_yml)
|
17
|
+
else
|
18
|
+
YAML.load(schedule_yml)
|
19
|
+
end
|
20
20
|
end
|
21
21
|
|
22
22
|
schedule_json = ENV['RESQUE_SCHEDULE_JSON']
|
23
23
|
if schedule_json
|
24
|
-
if File.exist?(schedule_json)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
24
|
+
Resque.schedule = if File.exist?(schedule_json)
|
25
|
+
JSON.parse(File.read(schedule_json))
|
26
|
+
else
|
27
|
+
JSON.parse(schedule_json)
|
28
|
+
end
|
29
29
|
end
|
30
30
|
|
31
31
|
class Putter
|
data/lib/resque/scheduler.rb
CHANGED
@@ -57,13 +57,14 @@ module Resque
|
|
57
57
|
|
58
58
|
# Now start the scheduling part of the loop.
|
59
59
|
loop do
|
60
|
-
|
61
|
-
|
60
|
+
begin
|
61
|
+
if master?
|
62
62
|
handle_delayed_items
|
63
63
|
update_schedule if dynamic
|
64
|
-
rescue Errno::EAGAIN, Errno::ECONNRESET => e
|
65
|
-
log! e.message
|
66
64
|
end
|
65
|
+
rescue Errno::EAGAIN, Errno::ECONNRESET, Redis::CannotConnectError => e
|
66
|
+
log! e.message
|
67
|
+
release_master_lock
|
67
68
|
end
|
68
69
|
poll_sleep
|
69
70
|
end
|
@@ -135,7 +136,7 @@ module Resque
|
|
135
136
|
interval_defined = false
|
136
137
|
interval_types = %w(cron every)
|
137
138
|
interval_types.each do |interval_type|
|
138
|
-
next unless !config[interval_type].nil? && config[interval_type].
|
139
|
+
next unless !config[interval_type].nil? && !config[interval_type].empty?
|
139
140
|
args = optionizate_interval_value(config[interval_type])
|
140
141
|
args = [args, nil, job: true] if args.is_a?(::String)
|
141
142
|
|
data/lib/resque/scheduler/cli.rb
CHANGED
@@ -16,7 +16,7 @@ module Resque
|
|
16
16
|
pidfile: 'PIDFILE',
|
17
17
|
poll_sleep_amount: 'RESQUE_SCHEDULER_INTERVAL',
|
18
18
|
verbose: 'VERBOSE'
|
19
|
-
}
|
19
|
+
}.freeze
|
20
20
|
|
21
21
|
class Cli
|
22
22
|
BANNER = <<-EOF.gsub(/ {6}/, '')
|
@@ -129,7 +129,7 @@ module Resque
|
|
129
129
|
OptionParser.new do |opts|
|
130
130
|
opts.banner = BANNER
|
131
131
|
OPTIONS.each do |opt|
|
132
|
-
opts.on(*opt[:args], &
|
132
|
+
opts.on(*opt[:args], &opt[:callback].call(options))
|
133
133
|
end
|
134
134
|
end
|
135
135
|
end
|
@@ -156,7 +156,7 @@ module Resque
|
|
156
156
|
# This allows for removal of delayed jobs that have arguments matching
|
157
157
|
# certain criteria
|
158
158
|
def remove_delayed_selection(klass = nil)
|
159
|
-
|
159
|
+
raise ArgumentError, 'Please supply a block' unless block_given?
|
160
160
|
|
161
161
|
found_jobs = find_delayed_selection(klass) { |args| yield(args) }
|
162
162
|
found_jobs.reduce(0) do |sum, encoded_job|
|
@@ -169,7 +169,7 @@ module Resque
|
|
169
169
|
# This allows for enqueuing of delayed jobs that have arguments matching
|
170
170
|
# certain criteria
|
171
171
|
def enqueue_delayed_selection(klass = nil)
|
172
|
-
|
172
|
+
raise ArgumentError, 'Please supply a block' unless block_given?
|
173
173
|
|
174
174
|
found_jobs = find_delayed_selection(klass) { |args| yield(args) }
|
175
175
|
found_jobs.reduce(0) do |sum, encoded_job|
|
@@ -184,24 +184,24 @@ module Resque
|
|
184
184
|
# This allows for finding of delayed jobs that have arguments matching
|
185
185
|
# certain criteria
|
186
186
|
def find_delayed_selection(klass = nil, &block)
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
payload = Resque.redis.lindex(job, index)
|
197
|
-
decoded_payload = decode(payload)
|
198
|
-
if payload_matches_selection?(decoded_payload, klass, &block)
|
199
|
-
found_jobs.push(payload)
|
187
|
+
raise ArgumentError, 'Please supply a block' unless block_given?
|
188
|
+
|
189
|
+
timestamps = redis.zrange(:delayed_queue_schedule, 0, -1)
|
190
|
+
|
191
|
+
# Beyond 100 there's almost no improvement in speed
|
192
|
+
found = timestamps.each_slice(100).map do |ts_group|
|
193
|
+
jobs = redis.pipelined do |r|
|
194
|
+
ts_group.each do |ts|
|
195
|
+
r.lrange("delayed:#{ts}", 0, -1)
|
200
196
|
end
|
201
|
-
|
197
|
+
end
|
198
|
+
|
199
|
+
jobs.flatten.select do |payload|
|
200
|
+
payload_matches_selection?(decode(payload), klass, &block)
|
202
201
|
end
|
203
202
|
end
|
204
|
-
|
203
|
+
|
204
|
+
found.flatten
|
205
205
|
end
|
206
206
|
|
207
207
|
# Given a timestamp and job (klass + args) it removes all instances and
|
@@ -16,7 +16,7 @@ module Resque
|
|
16
16
|
|
17
17
|
# Attempts to acquire the lock. Returns true if successfully acquired.
|
18
18
|
def acquire!
|
19
|
-
|
19
|
+
raise NotImplementedError
|
20
20
|
end
|
21
21
|
|
22
22
|
def value
|
@@ -25,7 +25,7 @@ module Resque
|
|
25
25
|
|
26
26
|
# Returns true if you currently hold the lock.
|
27
27
|
def locked?
|
28
|
-
|
28
|
+
raise NotImplementedError
|
29
29
|
end
|
30
30
|
|
31
31
|
# Releases the lock.
|
@@ -8,7 +8,7 @@ require 'json'
|
|
8
8
|
module Resque
|
9
9
|
module Scheduler
|
10
10
|
module Server
|
11
|
-
TIMESTAMP_FORMAT = '%Y-%m-%d %H:%M:%S %z'
|
11
|
+
TIMESTAMP_FORMAT = '%Y-%m-%d %H:%M:%S %z'.freeze
|
12
12
|
|
13
13
|
unless defined?(::Resque::Scheduler::Server::VIEW_PATH)
|
14
14
|
VIEW_PATH = File.join(File.dirname(__FILE__), 'server', 'views')
|
@@ -158,7 +158,7 @@ module Resque
|
|
158
158
|
dels = delayed_jobs_for_worker(worker)
|
159
159
|
results += dels.select do |j|
|
160
160
|
j['class'].downcase.include?(worker) &&
|
161
|
-
|
161
|
+
j.merge!('where_at' => 'delayed')
|
162
162
|
end
|
163
163
|
|
164
164
|
Resque.queues.each do |queue|
|
@@ -166,7 +166,7 @@ module Resque
|
|
166
166
|
queued = [queued] unless queued.is_a?(Array)
|
167
167
|
results += queued.select do |j|
|
168
168
|
j['class'].downcase.include?(worker) &&
|
169
|
-
|
169
|
+
j.merge!('queue' => queue, 'where_at' => 'queued')
|
170
170
|
end
|
171
171
|
end
|
172
172
|
|
@@ -231,7 +231,7 @@ module Resque
|
|
231
231
|
working = [*Resque.working]
|
232
232
|
work = working.select do |w|
|
233
233
|
w.job && w.job['payload'] &&
|
234
|
-
|
234
|
+
w.job['payload']['class'].downcase.include?(worker)
|
235
235
|
end
|
236
236
|
work.each do |w|
|
237
237
|
results += [
|
@@ -248,9 +248,10 @@ module Resque
|
|
248
248
|
schedule_size = Resque.delayed_queue_schedule_size
|
249
249
|
Resque.delayed_queue_peek(0, schedule_size).each do |d|
|
250
250
|
Resque.delayed_timestamp_peek(
|
251
|
-
d, 0, Resque.delayed_timestamp_size(d)
|
252
|
-
|
253
|
-
|
251
|
+
d, 0, Resque.delayed_timestamp_size(d)
|
252
|
+
).each do |j|
|
253
|
+
dels << j.merge!('timestamp' => d)
|
254
|
+
end
|
254
255
|
end
|
255
256
|
end
|
256
257
|
end
|
@@ -23,7 +23,7 @@
|
|
23
23
|
<form action="<%= u "/delayed/cancel_now" %>" method="post">
|
24
24
|
<input type="hidden" name="timestamp" value="<%= job['timestamp'].to_i %>">
|
25
25
|
<input type="hidden" name="klass" value="<%= job['class'] %>">
|
26
|
-
<input type="hidden" name="args" value="<%= Resque.encode job['args'] %>">
|
26
|
+
<input type="hidden" name="args" value="<%= h(Resque.encode job['args']) %>">
|
27
27
|
<input type="submit" value="Cancel Job">
|
28
28
|
</form>
|
29
29
|
</td>
|
@@ -13,7 +13,7 @@ module Resque
|
|
13
13
|
# poll/enqueing to finish (should be almost instant). In the
|
14
14
|
# case of sleeping, exit immediately.
|
15
15
|
def register_signal_handlers
|
16
|
-
%w(INT TERM USR1 USR2 QUIT).each do |sig|
|
16
|
+
(Signal.list.keys & %w(INT TERM USR1 USR2 QUIT)).each do |sig|
|
17
17
|
trap(sig) do
|
18
18
|
signal_queue << sig
|
19
19
|
# break sleep in the primary scheduler thread, alowing
|
@@ -22,11 +22,11 @@ module Resque
|
|
22
22
|
names.each do |name|
|
23
23
|
args = Module.method(:const_get).arity != 1 ? [false] : []
|
24
24
|
|
25
|
-
if constant.const_defined?(name, *args)
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
constant = if constant.const_defined?(name, *args)
|
26
|
+
constant.const_get(name)
|
27
|
+
else
|
28
|
+
constant.const_missing(name)
|
29
|
+
end
|
30
30
|
end
|
31
31
|
constant
|
32
32
|
end
|
data/resque-scheduler.gemspec
CHANGED
@@ -36,10 +36,10 @@ Gem::Specification.new do |spec|
|
|
36
36
|
|
37
37
|
# We pin rubocop because new cops have a tendency to result in false-y
|
38
38
|
# positives for new contributors, which is not a nice experience.
|
39
|
-
spec.add_development_dependency 'rubocop', '~> 0.
|
39
|
+
spec.add_development_dependency 'rubocop', '~> 0.40.0'
|
40
40
|
|
41
41
|
spec.add_runtime_dependency 'mono_logger', '~> 1.0'
|
42
|
-
spec.add_runtime_dependency 'redis', '~> 3.
|
43
|
-
spec.add_runtime_dependency 'resque', '~> 1.
|
42
|
+
spec.add_runtime_dependency 'redis', '~> 3.3'
|
43
|
+
spec.add_runtime_dependency 'resque', '~> 1.26'
|
44
44
|
spec.add_runtime_dependency 'rufus-scheduler', '~> 3.2'
|
45
45
|
end
|
data/test/delayed_queue_test.rb
CHANGED
@@ -247,7 +247,7 @@ context 'DelayedQueue' do
|
|
247
247
|
test 'calls klass#scheduled when enqueuing jobs if it exists' do
|
248
248
|
t = Time.now - 60
|
249
249
|
FakeCustomJobClassEnqueueAt.expects(:scheduled)
|
250
|
-
|
250
|
+
.once.with(:test, FakeCustomJobClassEnqueueAt.to_s, foo: 'bar')
|
251
251
|
Resque.enqueue_at(t, FakeCustomJobClassEnqueueAt, foo: 'bar')
|
252
252
|
end
|
253
253
|
|
@@ -258,7 +258,7 @@ context 'DelayedQueue' do
|
|
258
258
|
Resque.inline = true
|
259
259
|
t = Time.now - 60
|
260
260
|
FakeCustomJobClassEnqueueAt.expects(:scheduled)
|
261
|
-
|
261
|
+
.once.with(:test, FakeCustomJobClassEnqueueAt.to_s, foo: 'bar')
|
262
262
|
Resque.enqueue_at(t, FakeCustomJobClassEnqueueAt, foo: 'bar')
|
263
263
|
ensure
|
264
264
|
Resque.inline = old_val
|
data/test/multi_process_test.rb
CHANGED
@@ -104,9 +104,9 @@ context 'Multi Process' do
|
|
104
104
|
children.each do |pid, pipe|
|
105
105
|
wait_for_child_process_to_terminate(pid)
|
106
106
|
|
107
|
-
|
107
|
+
raise "forked process failed with #{$CHILD_STATUS}" unless $CHILD_STATUS.success?
|
108
108
|
result, exc = Marshal.load(pipe.read)
|
109
|
-
|
109
|
+
raise exc if exc
|
110
110
|
results << result
|
111
111
|
end
|
112
112
|
results
|
data/test/resque-web_test.rb
CHANGED
@@ -80,7 +80,7 @@ context 'on GET to /delayed' do
|
|
80
80
|
test('is 200') { assert last_response.ok? }
|
81
81
|
end
|
82
82
|
|
83
|
-
context 'on GET to /delayed/jobs/:klass'do
|
83
|
+
context 'on GET to /delayed/jobs/:klass' do
|
84
84
|
setup do
|
85
85
|
@t = Time.now + 3600
|
86
86
|
Resque.enqueue_at(@t, SomeIvarJob, 'foo', 'bar')
|
@@ -144,7 +144,7 @@ module Test
|
|
144
144
|
}
|
145
145
|
}
|
146
146
|
}
|
147
|
-
}
|
147
|
+
}.freeze
|
148
148
|
end
|
149
149
|
|
150
150
|
context 'POST /schedule/requeue' do
|
@@ -157,7 +157,7 @@ context 'POST /schedule/requeue' do
|
|
157
157
|
# Regular jobs without params should redirect to /overview
|
158
158
|
job_name = 'job_without_params'
|
159
159
|
Resque::Scheduler.stubs(:enqueue_from_config)
|
160
|
-
|
160
|
+
.once.with(Resque.schedule[job_name])
|
161
161
|
|
162
162
|
post '/schedule/requeue', 'job_name' => job_name
|
163
163
|
follow_redirect!
|
@@ -220,7 +220,7 @@ end
|
|
220
220
|
context 'on POST to /delayed/search' do
|
221
221
|
setup do
|
222
222
|
t = Time.now + 60
|
223
|
-
Resque.enqueue_at(t, SomeIvarJob)
|
223
|
+
Resque.enqueue_at(t, SomeIvarJob, 'string arg')
|
224
224
|
Resque.enqueue(SomeQuickJob)
|
225
225
|
end
|
226
226
|
|
@@ -230,6 +230,11 @@ context 'on POST to /delayed/search' do
|
|
230
230
|
assert last_response.body.include?('SomeIvarJob')
|
231
231
|
end
|
232
232
|
|
233
|
+
test 'the form should encode string params' do
|
234
|
+
post '/delayed/search', 'search' => 'ivar'
|
235
|
+
assert_match('value="["string arg"]', last_response.body)
|
236
|
+
end
|
237
|
+
|
233
238
|
test 'should find matching queued job' do
|
234
239
|
post '/delayed/search', 'search' => 'quick'
|
235
240
|
assert last_response.status == 200
|
@@ -238,9 +243,38 @@ context 'on POST to /delayed/search' do
|
|
238
243
|
end
|
239
244
|
|
240
245
|
context 'on POST to /delayed/cancel_now' do
|
241
|
-
setup
|
246
|
+
setup do
|
247
|
+
Resque.reset_delayed_queue
|
248
|
+
Resque.enqueue_at(Time.now + 10, SomeIvarJob, 'arg')
|
249
|
+
Resque.enqueue_at(Time.now + 100, SomeQuickJob)
|
250
|
+
end
|
251
|
+
|
252
|
+
test 'removes the specified job' do
|
253
|
+
job_timestamp, *remaining = Resque.delayed_queue_peek(0, 10)
|
254
|
+
assert_equal 1, remaining.size
|
255
|
+
|
256
|
+
post '/delayed/cancel_now',
|
257
|
+
'timestamp' => job_timestamp,
|
258
|
+
'klass' => SomeIvarJob.name,
|
259
|
+
'args' => Resque.encode(['arg'])
|
260
|
+
|
261
|
+
assert_equal 302, last_response.status
|
262
|
+
assert_equal remaining, Resque.delayed_queue_peek(0, 10)
|
263
|
+
end
|
264
|
+
|
265
|
+
test 'does not remove the job if the params do not match' do
|
266
|
+
timestamps = Resque.delayed_queue_peek(0, 10)
|
267
|
+
|
268
|
+
post '/delayed/cancel_now',
|
269
|
+
'timestamp' => timestamps.first,
|
270
|
+
'klass' => SomeIvarJob.name
|
271
|
+
|
272
|
+
assert_equal 302, last_response.status
|
273
|
+
assert_equal timestamps, Resque.delayed_queue_peek(0, 10)
|
274
|
+
end
|
242
275
|
|
243
276
|
test 'redirects to overview' do
|
277
|
+
post '/delayed/cancel_now'
|
244
278
|
assert last_response.status == 302
|
245
279
|
assert last_response.header['Location'].include? '/delayed'
|
246
280
|
end
|
data/test/scheduler_args_test.rb
CHANGED
@@ -14,7 +14,7 @@ context 'scheduling jobs with arguments' do
|
|
14
14
|
|
15
15
|
test 'enqueue_from_config puts stuff in resque without class loaded' do
|
16
16
|
Resque::Job.stubs(:create).once.returns(true)
|
17
|
-
|
17
|
+
.with('joes_queue', 'UndefinedJob', '/tmp')
|
18
18
|
Resque::Scheduler.enqueue_from_config(
|
19
19
|
'cron' => '* * * * *',
|
20
20
|
'class' => 'UndefinedJob',
|
@@ -25,7 +25,7 @@ context 'scheduling jobs with arguments' do
|
|
25
25
|
|
26
26
|
test 'enqueue_from_config with_every_syntax' do
|
27
27
|
Resque::Job.stubs(:create).once.returns(true)
|
28
|
-
|
28
|
+
.with('james_queue', 'JamesJob', '/tmp')
|
29
29
|
Resque::Scheduler.enqueue_from_config(
|
30
30
|
'every' => '1m',
|
31
31
|
'class' => 'JamesJob',
|
@@ -36,7 +36,7 @@ context 'scheduling jobs with arguments' do
|
|
36
36
|
|
37
37
|
test 'enqueue_from_config puts jobs in the resque queue' do
|
38
38
|
Resque::Job.stubs(:create).once.returns(true)
|
39
|
-
|
39
|
+
.with(:ivar, SomeIvarJob, '/tmp')
|
40
40
|
Resque::Scheduler.enqueue_from_config(
|
41
41
|
'cron' => '* * * * *',
|
42
42
|
'class' => 'SomeIvarJob',
|
@@ -46,7 +46,7 @@ context 'scheduling jobs with arguments' do
|
|
46
46
|
|
47
47
|
test 'enqueue_from_config with custom_class_job in resque' do
|
48
48
|
FakeCustomJobClass.stubs(:scheduled).once.returns(true)
|
49
|
-
|
49
|
+
.with(:ivar, 'SomeIvarJob', '/tmp')
|
50
50
|
Resque::Scheduler.enqueue_from_config(
|
51
51
|
'cron' => '* * * * *',
|
52
52
|
'class' => 'SomeIvarJob',
|
@@ -207,7 +207,7 @@ context 'scheduling jobs with arguments' do
|
|
207
207
|
second_key: value
|
208
208
|
YAML
|
209
209
|
SomeIvarJob.expects(:perform).once
|
210
|
-
|
210
|
+
.with('first_key' => { 'second_key' => 'value' })
|
211
211
|
Resque.reserve('ivar').perform
|
212
212
|
end
|
213
213
|
|
data/test/scheduler_test.rb
CHANGED
@@ -442,7 +442,7 @@ context 'Resque::Scheduler' do
|
|
442
442
|
test 'procline omits app_name when absent' do
|
443
443
|
Resque::Scheduler.app_name = nil
|
444
444
|
assert Resque::Scheduler.send(:build_procline, 'bar') =~
|
445
|
-
|
445
|
+
/#{Resque::Scheduler.send(:internal_name)}: bar/
|
446
446
|
end
|
447
447
|
|
448
448
|
test 'procline contains env when present' do
|
@@ -453,7 +453,7 @@ context 'Resque::Scheduler' do
|
|
453
453
|
test 'procline omits env when absent' do
|
454
454
|
Resque::Scheduler.env = nil
|
455
455
|
assert Resque::Scheduler.send(:build_procline, 'cage') =~
|
456
|
-
|
456
|
+
/#{Resque::Scheduler.send(:internal_name)}: cage/
|
457
457
|
end
|
458
458
|
|
459
459
|
context 'printing schedule' do
|
@@ -464,9 +464,9 @@ context 'Resque::Scheduler' do
|
|
464
464
|
test 'prints schedule' do
|
465
465
|
fake_rufus_scheduler = mock
|
466
466
|
fake_rufus_scheduler.expects(:jobs).at_least_once
|
467
|
-
|
467
|
+
.returns(foo: OpenStruct.new(t: nil, last: nil))
|
468
468
|
Resque::Scheduler.expects(:rufus_scheduler).at_least_once
|
469
|
-
|
469
|
+
.returns(fake_rufus_scheduler)
|
470
470
|
Resque::Scheduler.print_schedule
|
471
471
|
end
|
472
472
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-scheduler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.2.
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben VandenBos
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -170,14 +170,14 @@ dependencies:
|
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version: 0.
|
173
|
+
version: 0.40.0
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version: 0.
|
180
|
+
version: 0.40.0
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
182
|
name: mono_logger
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
@@ -198,28 +198,28 @@ dependencies:
|
|
198
198
|
requirements:
|
199
199
|
- - "~>"
|
200
200
|
- !ruby/object:Gem::Version
|
201
|
-
version: '3.
|
201
|
+
version: '3.3'
|
202
202
|
type: :runtime
|
203
203
|
prerelease: false
|
204
204
|
version_requirements: !ruby/object:Gem::Requirement
|
205
205
|
requirements:
|
206
206
|
- - "~>"
|
207
207
|
- !ruby/object:Gem::Version
|
208
|
-
version: '3.
|
208
|
+
version: '3.3'
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
210
|
name: resque
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
213
|
- - "~>"
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version: '1.
|
215
|
+
version: '1.26'
|
216
216
|
type: :runtime
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
220
|
- - "~>"
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version: '1.
|
222
|
+
version: '1.26'
|
223
223
|
- !ruby/object:Gem::Dependency
|
224
224
|
name: rufus-scheduler
|
225
225
|
requirement: !ruby/object:Gem::Requirement
|
@@ -337,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
337
337
|
version: '0'
|
338
338
|
requirements: []
|
339
339
|
rubyforge_project:
|
340
|
-
rubygems_version: 2.
|
340
|
+
rubygems_version: 2.5.1
|
341
341
|
signing_key:
|
342
342
|
specification_version: 4
|
343
343
|
summary: Light weight job scheduling on top of Resque
|
@@ -355,3 +355,4 @@ test_files:
|
|
355
355
|
- test/scheduler_test.rb
|
356
356
|
- test/test_helper.rb
|
357
357
|
- test/util_test.rb
|
358
|
+
has_rdoc:
|