resque-cedar 1.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. data/HISTORY.md +354 -0
  2. data/LICENSE +20 -0
  3. data/README.markdown +908 -0
  4. data/Rakefile +70 -0
  5. data/bin/resque +81 -0
  6. data/bin/resque-web +27 -0
  7. data/lib/resque.rb +385 -0
  8. data/lib/resque/coder.rb +27 -0
  9. data/lib/resque/errors.rb +10 -0
  10. data/lib/resque/failure.rb +96 -0
  11. data/lib/resque/failure/airbrake.rb +17 -0
  12. data/lib/resque/failure/base.rb +64 -0
  13. data/lib/resque/failure/hoptoad.rb +33 -0
  14. data/lib/resque/failure/multiple.rb +54 -0
  15. data/lib/resque/failure/redis.rb +51 -0
  16. data/lib/resque/failure/thoughtbot.rb +33 -0
  17. data/lib/resque/helpers.rb +64 -0
  18. data/lib/resque/job.rb +223 -0
  19. data/lib/resque/multi_json_coder.rb +37 -0
  20. data/lib/resque/multi_queue.rb +73 -0
  21. data/lib/resque/plugin.rb +66 -0
  22. data/lib/resque/queue.rb +117 -0
  23. data/lib/resque/server.rb +248 -0
  24. data/lib/resque/server/public/favicon.ico +0 -0
  25. data/lib/resque/server/public/idle.png +0 -0
  26. data/lib/resque/server/public/jquery-1.3.2.min.js +19 -0
  27. data/lib/resque/server/public/jquery.relatize_date.js +95 -0
  28. data/lib/resque/server/public/poll.png +0 -0
  29. data/lib/resque/server/public/ranger.js +73 -0
  30. data/lib/resque/server/public/reset.css +44 -0
  31. data/lib/resque/server/public/style.css +86 -0
  32. data/lib/resque/server/public/working.png +0 -0
  33. data/lib/resque/server/test_helper.rb +19 -0
  34. data/lib/resque/server/views/error.erb +1 -0
  35. data/lib/resque/server/views/failed.erb +67 -0
  36. data/lib/resque/server/views/key_sets.erb +19 -0
  37. data/lib/resque/server/views/key_string.erb +11 -0
  38. data/lib/resque/server/views/layout.erb +44 -0
  39. data/lib/resque/server/views/next_more.erb +10 -0
  40. data/lib/resque/server/views/overview.erb +4 -0
  41. data/lib/resque/server/views/queues.erb +49 -0
  42. data/lib/resque/server/views/stats.erb +62 -0
  43. data/lib/resque/server/views/workers.erb +109 -0
  44. data/lib/resque/server/views/working.erb +72 -0
  45. data/lib/resque/stat.rb +53 -0
  46. data/lib/resque/tasks.rb +61 -0
  47. data/lib/resque/version.rb +3 -0
  48. data/lib/resque/worker.rb +557 -0
  49. data/lib/tasks/redis.rake +161 -0
  50. data/lib/tasks/resque.rake +2 -0
  51. data/test/airbrake_test.rb +26 -0
  52. data/test/hoptoad_test.rb +26 -0
  53. data/test/job_hooks_test.rb +423 -0
  54. data/test/job_plugins_test.rb +230 -0
  55. data/test/multi_queue_test.rb +95 -0
  56. data/test/plugin_test.rb +116 -0
  57. data/test/redis-test-cluster.conf +115 -0
  58. data/test/redis-test.conf +115 -0
  59. data/test/redis_queue_test.rb +133 -0
  60. data/test/resque-web_test.rb +59 -0
  61. data/test/resque_test.rb +284 -0
  62. data/test/test_helper.rb +135 -0
  63. data/test/worker_test.rb +443 -0
  64. metadata +188 -0
@@ -0,0 +1,115 @@
1
+ # Redis configuration file example
2
+
3
+ # By default Redis does not run as a daemon. Use 'yes' if you need it.
4
+ # Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
5
+ daemonize yes
6
+
7
+ # When run as a daemon, Redis write a pid file in /var/run/redis.pid by default.
8
+ # You can specify a custom pid file location here.
9
+ pidfile ./test/redis-test.pid
10
+
11
+ # Accept connections on the specified port, default is 6379
12
+ port 9736
13
+
14
+ # If you want you can bind a single interface, if the bind option is not
15
+ # specified all the interfaces will listen for connections.
16
+ #
17
+ # bind 127.0.0.1
18
+
19
+ # Close the connection after a client is idle for N seconds (0 to disable)
20
+ timeout 300
21
+
22
+ # Save the DB on disk:
23
+ #
24
+ # save <seconds> <changes>
25
+ #
26
+ # Will save the DB if both the given number of seconds and the given
27
+ # number of write operations against the DB occurred.
28
+ #
29
+ # In the example below the behaviour will be to save:
30
+ # after 900 sec (15 min) if at least 1 key changed
31
+ # after 300 sec (5 min) if at least 10 keys changed
32
+ # after 60 sec if at least 10000 keys changed
33
+ save 900 1
34
+ save 300 10
35
+ save 60 10000
36
+
37
+ # The filename where to dump the DB
38
+ dbfilename dump.rdb
39
+
40
+ # For default save/load DB in/from the working directory
41
+ # Note that you must specify a directory not a file name.
42
+ dir ./test/
43
+
44
+ # Set server verbosity to 'debug'
45
+ # it can be one of:
46
+ # debug (a lot of information, useful for development/testing)
47
+ # notice (moderately verbose, what you want in production probably)
48
+ # warning (only very important / critical messages are logged)
49
+ loglevel debug
50
+
51
+ # Specify the log file name. Also 'stdout' can be used to force
52
+ # the demon to log on the standard output. Note that if you use standard
53
+ # output for logging but daemonize, logs will be sent to /dev/null
54
+ logfile stdout
55
+
56
+ # Set the number of databases. The default database is DB 0, you can select
57
+ # a different one on a per-connection basis using SELECT <dbid> where
58
+ # dbid is a number between 0 and 'databases'-1
59
+ databases 16
60
+
61
+ ################################# REPLICATION #################################
62
+
63
+ # Master-Slave replication. Use slaveof to make a Redis instance a copy of
64
+ # another Redis server. Note that the configuration is local to the slave
65
+ # so for example it is possible to configure the slave to save the DB with a
66
+ # different interval, or to listen to another port, and so on.
67
+
68
+ # slaveof <masterip> <masterport>
69
+
70
+ ################################## SECURITY ###################################
71
+
72
+ # Require clients to issue AUTH <PASSWORD> before processing any other
73
+ # commands. This might be useful in environments in which you do not trust
74
+ # others with access to the host running redis-server.
75
+ #
76
+ # This should stay commented out for backward compatibility and because most
77
+ # people do not need auth (e.g. they run their own servers).
78
+
79
+ # requirepass foobared
80
+
81
+ ################################### LIMITS ####################################
82
+
83
+ # Set the max number of connected clients at the same time. By default there
84
+ # is no limit, and it's up to the number of file descriptors the Redis process
85
+ # is able to open. The special value '0' means no limts.
86
+ # Once the limit is reached Redis will close all the new connections sending
87
+ # an error 'max number of clients reached'.
88
+
89
+ # maxclients 128
90
+
91
+ # Don't use more memory than the specified amount of bytes.
92
+ # When the memory limit is reached Redis will try to remove keys with an
93
+ # EXPIRE set. It will try to start freeing keys that are going to expire
94
+ # in little time and preserve keys with a longer time to live.
95
+ # Redis will also try to remove objects from free lists if possible.
96
+ #
97
+ # If all this fails, Redis will start to reply with errors to commands
98
+ # that will use more memory, like SET, LPUSH, and so on, and will continue
99
+ # to reply to most read-only commands like GET.
100
+ #
101
+ # WARNING: maxmemory can be a good idea mainly if you want to use Redis as a
102
+ # 'state' server or cache, not as a real DB. When Redis is used as a real
103
+ # database the memory usage will grow over the weeks, it will be obvious if
104
+ # it is going to use too much memory in the long run, and you'll have the time
105
+ # to upgrade. With maxmemory after the limit is reached you'll start to get
106
+ # errors for write operations, and this may even lead to DB inconsistency.
107
+
108
+ # maxmemory <bytes>
109
+
110
+ ############################### ADVANCED CONFIG ###############################
111
+
112
+ # Glue small output buffers together in order to send small replies in a
113
+ # single TCP packet. Uses a bit more CPU but most of the times it is a win
114
+ # in terms of number of queries per second. Use 'yes' if unsure.
115
+ glueoutputbuf yes
@@ -0,0 +1,133 @@
1
+ require 'test_helper'
2
+ require 'resque/queue'
3
+
4
+ describe "Resque::Queue" do
5
+ include Test::Unit::Assertions
6
+
7
+ class Thing
8
+ attr_reader :inside
9
+
10
+ def initialize
11
+ @inside = "x"
12
+ end
13
+
14
+ def == other
15
+ super || @inside == other.inside
16
+ end
17
+ end
18
+
19
+ before do
20
+ Resque.redis.flushall
21
+ end
22
+
23
+ it "generates a redis_name" do
24
+ assert_equal "queue:foo", q.redis_name
25
+ end
26
+
27
+ it "acts sanely" do
28
+ queue = q
29
+ x = Thing.new
30
+ queue.push x
31
+ assert_equal x, queue.pop
32
+ end
33
+
34
+ it "blocks on pop" do
35
+ queue1 = q
36
+ queue2 = q
37
+
38
+ t = Thread.new { queue1.pop }
39
+ x = Thing.new
40
+
41
+ queue2.push x
42
+ assert_equal x, t.join.value
43
+ end
44
+
45
+ it "nonblocking pop works" do
46
+ queue1 = q
47
+ x = Thing.new
48
+
49
+ queue1 << x
50
+ assert_equal x, queue1.pop
51
+ end
52
+
53
+ it "nonblocking pop doesn't block" do
54
+ queue1 = q
55
+
56
+ assert_raises ThreadError do
57
+ queue1.pop(true)
58
+ end
59
+ end
60
+
61
+ it "blocks forever on pop" do
62
+ queue1 = q
63
+ assert_raises Timeout::Error do
64
+ Timeout.timeout(2) { queue1.pop }
65
+ end
66
+ end
67
+
68
+ it "#size" do
69
+ queue = q
70
+
71
+ begin
72
+ assert_equal 0, queue.size
73
+
74
+ queue << Thing.new
75
+ assert_equal 1, queue.size
76
+ ensure
77
+ queue.pop
78
+ end
79
+ end
80
+
81
+ it "#empty?" do
82
+ queue = q
83
+
84
+ begin
85
+ assert queue.empty?
86
+
87
+ queue << Thing.new
88
+ refute queue.empty?
89
+ ensure
90
+ queue.pop
91
+ end
92
+ end
93
+
94
+ it "registers itself with Resque" do
95
+ q
96
+
97
+ assert_equal ["foo"], Resque.queues
98
+ end
99
+
100
+ it "cleans up after itself when destroyed" do
101
+ queue = q
102
+ queue << Thing.new
103
+ q.destroy
104
+
105
+ assert_equal [], Resque.queues
106
+ assert !Resque.redis.exists(queue.redis_name)
107
+ end
108
+
109
+ it "returns false if a queue is not destroyed" do
110
+ assert !q.destroyed?
111
+ end
112
+
113
+ it "returns true if a queue is destroyed" do
114
+ queue1 = q
115
+ queue1.destroy
116
+ assert queue1.destroyed?
117
+ end
118
+
119
+ it "can't push to queue after destroying it" do
120
+ queue1 = q
121
+ x = Thing.new
122
+ queue1 << x
123
+ queue1.destroy
124
+
125
+ assert_raise Resque::QueueDestroyed do
126
+ queue1 << x
127
+ end
128
+ end
129
+
130
+ def q
131
+ Resque::Queue.new 'foo', Resque.redis
132
+ end
133
+ end
@@ -0,0 +1,59 @@
1
+ require 'test_helper'
2
+ require 'resque/server/test_helper'
3
+
4
+ # Root path test
5
+ describe "on GET to /" do
6
+ before { get "/" }
7
+
8
+ it "redirect to overview" do
9
+ follow_redirect!
10
+ end
11
+ end
12
+
13
+ # Global overview
14
+ describe "on GET to /overview" do
15
+ before { get "/overview" }
16
+
17
+ it "should at least display 'queues'" do
18
+ assert last_response.body.include?('Queues')
19
+ end
20
+ end
21
+
22
+ # Working jobs
23
+ describe "on GET to /working" do
24
+ before { get "/working" }
25
+
26
+ should_respond_with_success
27
+ end
28
+
29
+ # Failed
30
+ describe "on GET to /failed" do
31
+ before { get "/failed" }
32
+
33
+ should_respond_with_success
34
+ end
35
+
36
+ # Stats
37
+ describe "on GET to /stats/resque" do
38
+ before { get "/stats/resque" }
39
+
40
+ should_respond_with_success
41
+ end
42
+
43
+ describe "on GET to /stats/redis" do
44
+ before { get "/stats/redis" }
45
+
46
+ should_respond_with_success
47
+ end
48
+
49
+ describe "on GET to /stats/resque" do
50
+ before { get "/stats/keys" }
51
+
52
+ should_respond_with_success
53
+ end
54
+
55
+ describe "also works with slash at the end" do
56
+ before { get "/working/" }
57
+
58
+ should_respond_with_success
59
+ end
@@ -0,0 +1,284 @@
1
+ require 'test_helper'
2
+
3
+ describe "Resque" do
4
+ include Test::Unit::Assertions
5
+
6
+ before do
7
+ Resque.redis.flushall
8
+
9
+ Resque.push(:people, { 'name' => 'chris' })
10
+ Resque.push(:people, { 'name' => 'bob' })
11
+ Resque.push(:people, { 'name' => 'mark' })
12
+ @original_redis = Resque.redis
13
+ end
14
+
15
+ after do
16
+ Resque.redis = @original_redis
17
+ end
18
+
19
+ it "can set a namespace through a url-like string" do
20
+ assert Resque.redis
21
+ assert_equal :resque, Resque.redis.namespace
22
+ Resque.redis = 'localhost:9736/namespace'
23
+ assert_equal 'namespace', Resque.redis.namespace
24
+ end
25
+
26
+ it "redis= works correctly with a Redis::Namespace param" do
27
+ new_redis = Redis.new(:host => "localhost", :port => 9736)
28
+ new_namespace = Redis::Namespace.new("namespace", :redis => new_redis)
29
+ Resque.redis = new_namespace
30
+ assert_equal new_namespace, Resque.redis
31
+
32
+ Resque.redis = 'localhost:9736/namespace'
33
+ end
34
+
35
+ it "can put jobs on a queue" do
36
+ assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
37
+ assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
38
+ end
39
+
40
+ it "can grab jobs off a queue" do
41
+ Resque::Job.create(:jobs, 'some-job', 20, '/tmp')
42
+
43
+ job = Resque.reserve(:jobs)
44
+
45
+ assert_kind_of Resque::Job, job
46
+ assert_equal SomeJob, job.payload_class
47
+ assert_equal 20, job.args[0]
48
+ assert_equal '/tmp', job.args[1]
49
+ end
50
+
51
+ it "can re-queue jobs" do
52
+ Resque::Job.create(:jobs, 'some-job', 20, '/tmp')
53
+
54
+ job = Resque.reserve(:jobs)
55
+ job.recreate
56
+
57
+ assert_equal job, Resque.reserve(:jobs)
58
+ end
59
+
60
+ it "can put jobs on a queue by way of an ivar" do
61
+ assert_equal 0, Resque.size(:ivar)
62
+ assert Resque.enqueue(SomeIvarJob, 20, '/tmp')
63
+ assert Resque.enqueue(SomeIvarJob, 20, '/tmp')
64
+
65
+ job = Resque.reserve(:ivar)
66
+
67
+ assert_kind_of Resque::Job, job
68
+ assert_equal SomeIvarJob, job.payload_class
69
+ assert_equal 20, job.args[0]
70
+ assert_equal '/tmp', job.args[1]
71
+
72
+ assert Resque.reserve(:ivar)
73
+ assert_equal nil, Resque.reserve(:ivar)
74
+ end
75
+
76
+ it "can remove jobs from a queue by way of an ivar" do
77
+ assert_equal 0, Resque.size(:ivar)
78
+ assert Resque.enqueue(SomeIvarJob, 20, '/tmp')
79
+ assert Resque.enqueue(SomeIvarJob, 30, '/tmp')
80
+ assert Resque.enqueue(SomeIvarJob, 20, '/tmp')
81
+ assert Resque::Job.create(:ivar, 'blah-job', 20, '/tmp')
82
+ assert Resque.enqueue(SomeIvarJob, 20, '/tmp')
83
+ assert_equal 5, Resque.size(:ivar)
84
+
85
+ assert Resque.dequeue(SomeIvarJob, 30, '/tmp')
86
+ assert_equal 4, Resque.size(:ivar)
87
+ assert Resque.dequeue(SomeIvarJob)
88
+ assert_equal 1, Resque.size(:ivar)
89
+ end
90
+
91
+ it "jobs have a nice #inspect" do
92
+ assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
93
+ job = Resque.reserve(:jobs)
94
+ assert_equal '(Job{jobs} | SomeJob | [20, "/tmp"])', job.inspect
95
+ end
96
+
97
+ it "jobs can be destroyed" do
98
+ assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
99
+ assert Resque::Job.create(:jobs, 'BadJob', 20, '/tmp')
100
+ assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
101
+ assert Resque::Job.create(:jobs, 'BadJob', 30, '/tmp')
102
+ assert Resque::Job.create(:jobs, 'BadJob', 20, '/tmp')
103
+
104
+ assert_equal 5, Resque.size(:jobs)
105
+ assert_equal 2, Resque::Job.destroy(:jobs, 'SomeJob')
106
+ assert_equal 3, Resque.size(:jobs)
107
+ assert_equal 1, Resque::Job.destroy(:jobs, 'BadJob', 30, '/tmp')
108
+ assert_equal 2, Resque.size(:jobs)
109
+ end
110
+
111
+ it "jobs can it for equality" do
112
+ assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
113
+ assert Resque::Job.create(:jobs, 'some-job', 20, '/tmp')
114
+ assert_equal Resque.reserve(:jobs), Resque.reserve(:jobs)
115
+
116
+ assert Resque::Job.create(:jobs, 'SomeMethodJob', 20, '/tmp')
117
+ assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
118
+ assert_not_equal Resque.reserve(:jobs), Resque.reserve(:jobs)
119
+
120
+ assert Resque::Job.create(:jobs, 'SomeJob', 20, '/tmp')
121
+ assert Resque::Job.create(:jobs, 'SomeJob', 30, '/tmp')
122
+ assert_not_equal Resque.reserve(:jobs), Resque.reserve(:jobs)
123
+ end
124
+
125
+ it "can put jobs on a queue by way of a method" do
126
+ assert_equal 0, Resque.size(:method)
127
+ assert Resque.enqueue(SomeMethodJob, 20, '/tmp')
128
+ assert Resque.enqueue(SomeMethodJob, 20, '/tmp')
129
+
130
+ job = Resque.reserve(:method)
131
+
132
+ assert_kind_of Resque::Job, job
133
+ assert_equal SomeMethodJob, job.payload_class
134
+ assert_equal 20, job.args[0]
135
+ assert_equal '/tmp', job.args[1]
136
+
137
+ assert Resque.reserve(:method)
138
+ assert_equal nil, Resque.reserve(:method)
139
+ end
140
+
141
+ it "can define a queue for jobs by way of a method" do
142
+ assert_equal 0, Resque.size(:method)
143
+ assert Resque.enqueue_to(:new_queue, SomeMethodJob, 20, '/tmp')
144
+
145
+ job = Resque.reserve(:new_queue)
146
+ assert_equal SomeMethodJob, job.payload_class
147
+ assert_equal 20, job.args[0]
148
+ assert_equal '/tmp', job.args[1]
149
+ end
150
+
151
+ it "needs to infer a queue with enqueue" do
152
+ assert_raises Resque::NoQueueError do
153
+ Resque.enqueue(SomeJob, 20, '/tmp')
154
+ end
155
+ end
156
+
157
+ it "validates job for queue presence" do
158
+ assert_raises Resque::NoQueueError do
159
+ Resque.validate(SomeJob)
160
+ end
161
+ end
162
+
163
+ it "can put items on a queue" do
164
+ assert Resque.push(:people, { 'name' => 'jon' })
165
+ end
166
+
167
+ it "can pull items off a queue" do
168
+ assert_equal({ 'name' => 'chris' }, Resque.pop(:people))
169
+ assert_equal({ 'name' => 'bob' }, Resque.pop(:people))
170
+ assert_equal({ 'name' => 'mark' }, Resque.pop(:people))
171
+ assert_equal nil, Resque.pop(:people)
172
+ end
173
+
174
+ it "knows how big a queue is" do
175
+ assert_equal 3, Resque.size(:people)
176
+
177
+ assert_equal({ 'name' => 'chris' }, Resque.pop(:people))
178
+ assert_equal 2, Resque.size(:people)
179
+
180
+ assert_equal({ 'name' => 'bob' }, Resque.pop(:people))
181
+ assert_equal({ 'name' => 'mark' }, Resque.pop(:people))
182
+ assert_equal 0, Resque.size(:people)
183
+ end
184
+
185
+ it "can peek at a queue" do
186
+ assert_equal({ 'name' => 'chris' }, Resque.peek(:people))
187
+ assert_equal 3, Resque.size(:people)
188
+ end
189
+
190
+ it "can peek multiple items on a queue" do
191
+ assert_equal({ 'name' => 'bob' }, Resque.peek(:people, 1, 1))
192
+
193
+ assert_equal([{ 'name' => 'bob' }, { 'name' => 'mark' }], Resque.peek(:people, 1, 2))
194
+ assert_equal([{ 'name' => 'chris' }, { 'name' => 'bob' }], Resque.peek(:people, 0, 2))
195
+ assert_equal([{ 'name' => 'chris' }, { 'name' => 'bob' }, { 'name' => 'mark' }], Resque.peek(:people, 0, 3))
196
+ assert_equal({ 'name' => 'mark' }, Resque.peek(:people, 2, 1))
197
+ assert_equal nil, Resque.peek(:people, 3)
198
+ assert_equal [], Resque.peek(:people, 3, 2)
199
+ end
200
+
201
+ it "knows what queues it is managing" do
202
+ assert_equal %w( people ), Resque.queues
203
+ Resque.push(:cars, { 'make' => 'bmw' })
204
+ assert_equal %w( cars people ), Resque.queues
205
+ end
206
+
207
+ it "queues are always a list" do
208
+ Resque.redis.flushall
209
+ assert_equal [], Resque.queues
210
+ end
211
+
212
+ it "can delete a queue" do
213
+ Resque.push(:cars, { 'make' => 'bmw' })
214
+ assert_equal %w( cars people ), Resque.queues
215
+ Resque.remove_queue(:people)
216
+ assert_equal %w( cars ), Resque.queues
217
+ assert_equal nil, Resque.pop(:people)
218
+ end
219
+
220
+ it "keeps track of resque keys" do
221
+ assert_equal ["queue:people", "queues"].sort, Resque.keys.sort
222
+ end
223
+
224
+ it "badly wants a class name, too" do
225
+ assert_raises Resque::NoClassError do
226
+ Resque::Job.create(:jobs, nil)
227
+ end
228
+ end
229
+
230
+ it "keeps stats" do
231
+ Resque::Job.create(:jobs, SomeJob, 20, '/tmp')
232
+ Resque::Job.create(:jobs, BadJob)
233
+ Resque::Job.create(:jobs, GoodJob)
234
+
235
+ Resque::Job.create(:others, GoodJob)
236
+ Resque::Job.create(:others, GoodJob)
237
+
238
+ stats = Resque.info
239
+ assert_equal 8, stats[:pending]
240
+
241
+ @worker = Resque::Worker.new(:jobs)
242
+ @worker.register_worker
243
+ 2.times { @worker.process }
244
+
245
+ job = @worker.reserve
246
+ @worker.working_on job
247
+
248
+ stats = Resque.info
249
+ assert_equal 1, stats[:working]
250
+ assert_equal 1, stats[:workers]
251
+
252
+ @worker.done_working
253
+
254
+ stats = Resque.info
255
+ assert_equal 3, stats[:queues]
256
+ assert_equal 3, stats[:processed]
257
+ assert_equal 1, stats[:failed]
258
+ if ENV.key? 'RESQUE_DISTRIBUTED'
259
+ assert_equal [Resque.redis.respond_to?(:server) ? 'localhost:9736, localhost:9737' : 'redis://localhost:9736/0, redis://localhost:9737/0'], stats[:servers]
260
+ else
261
+ assert_equal [Resque.redis.respond_to?(:server) ? 'localhost:9736' : 'redis://localhost:9736/0'], stats[:servers]
262
+ end
263
+ end
264
+
265
+ it "decode bad json" do
266
+ assert_raises Resque::DecodeException do
267
+ Resque.coder.decode("{\"error\":\"Module not found \\u002\"}")
268
+ end
269
+ end
270
+
271
+ it "inlining jobs" do
272
+ begin
273
+ Resque.inline = true
274
+ Resque.enqueue(SomeIvarJob, 20, '/tmp')
275
+ assert_equal 0, Resque.size(:ivar)
276
+ ensure
277
+ Resque.inline = false
278
+ end
279
+ end
280
+
281
+ it 'treats symbols and strings the same' do
282
+ assert_equal Resque.queue(:people), Resque.queue('people')
283
+ end
284
+ end