allq_rest 1.5.2 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +36 -97
  3. data/lib/allq_rest/client.rb +168 -0
  4. data/lib/allq_rest/configuration.rb +7 -192
  5. data/lib/allq_rest/errors.rb +17 -0
  6. data/lib/allq_rest/job.rb +10 -0
  7. data/lib/allq_rest/version.rb +2 -14
  8. data/lib/allq_rest.rb +21 -46
  9. data/swagger.yaml +706 -0
  10. metadata +32 -116
  11. data/Gemfile +0 -7
  12. data/Gemfile.lock +0 -42
  13. data/Rakefile +0 -8
  14. data/allq_rest-1.2.92.gem +0 -0
  15. data/allq_rest-1.2.93.gem +0 -0
  16. data/allq_rest-1.3.0.gem +0 -0
  17. data/allq_rest-1.4.0.gem +0 -0
  18. data/allq_rest-1.5.0.gem +0 -0
  19. data/allq_rest-1.5.1.gem +0 -0
  20. data/allq_rest.gemspec +0 -28
  21. data/deploy.sh +0 -4
  22. data/docs/ActionsApi.md +0 -544
  23. data/docs/AdminApi.md +0 -98
  24. data/docs/BasicPayload.md +0 -11
  25. data/docs/BasicResponse.md +0 -8
  26. data/docs/JobRef.md +0 -8
  27. data/docs/JobResponse.md +0 -12
  28. data/docs/NewJob.md +0 -13
  29. data/docs/NewParentJob.md +0 -16
  30. data/docs/StatsInfo.md +0 -9
  31. data/docs/StatsResults.md +0 -10
  32. data/docs/StatsTube.md +0 -14
  33. data/docs/Throttle.md +0 -9
  34. data/docs/TubeRef.md +0 -8
  35. data/git_push.sh +0 -55
  36. data/lib/.DS_Store +0 -0
  37. data/lib/allq_rest/.DS_Store +0 -0
  38. data/lib/allq_rest/api/actions_api.rb +0 -763
  39. data/lib/allq_rest/api/admin_api.rb +0 -181
  40. data/lib/allq_rest/api_client.rb +0 -395
  41. data/lib/allq_rest/api_error.rb +0 -38
  42. data/lib/allq_rest/models/basic_payload.rb +0 -218
  43. data/lib/allq_rest/models/basic_response.rb +0 -188
  44. data/lib/allq_rest/models/job_ref.rb +0 -190
  45. data/lib/allq_rest/models/job_response.rb +0 -260
  46. data/lib/allq_rest/models/multiple_job_response.rb +0 -187
  47. data/lib/allq_rest/models/new_job.rb +0 -281
  48. data/lib/allq_rest/models/new_parent_job.rb +0 -312
  49. data/lib/allq_rest/models/stats_info.rb +0 -204
  50. data/lib/allq_rest/models/stats_results.rb +0 -254
  51. data/lib/allq_rest/models/stats_tube.rb +0 -306
  52. data/lib/allq_rest/models/throttle.rb +0 -209
  53. data/lib/allq_rest/models/tube_ref.rb +0 -190
  54. data/spec/.DS_Store +0 -0
  55. data/spec/api/actions_api_spec.rb +0 -600
  56. data/spec/api/admin_api_spec.rb +0 -58
  57. data/spec/api_client_spec.rb +0 -226
  58. data/spec/configuration_spec.rb +0 -42
  59. data/spec/models/basic_payload_spec.rb +0 -60
  60. data/spec/models/basic_response_spec.rb +0 -42
  61. data/spec/models/job_ref_spec.rb +0 -42
  62. data/spec/models/job_response_spec.rb +0 -66
  63. data/spec/models/new_job_spec.rb +0 -72
  64. data/spec/models/new_parent_job_spec.rb +0 -90
  65. data/spec/models/stats_info_spec.rb +0 -48
  66. data/spec/models/stats_results_spec.rb +0 -54
  67. data/spec/models/stats_tube_spec.rb +0 -78
  68. data/spec/models/throttle_spec.rb +0 -48
  69. data/spec/models/tube_ref_spec.rb +0 -42
  70. data/spec/spec_helper.rb +0 -113
@@ -1,600 +0,0 @@
1
- =begin
2
- #AllQ
3
-
4
- #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
-
6
- OpenAPI spec version: 1.0
7
-
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.1
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
- require 'json'
15
-
16
- DEFAULT_TUBE = "default"
17
- ALT_TUBE = ""
18
- # Unit tests for Allq::ActionsApi
19
- # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
20
- # Please update as you see appropriate
21
- describe 'ActionsApi' do
22
- before do
23
- # run before each test
24
- allq_conf = Allq::Configuration.new do |config|
25
- config.host = ENV['ALLQ_CLIENT_LOCATION'] || 'localhost:8091'
26
- end
27
- raw_client = Allq::ApiClient.new(allq_conf)
28
- @instance = Allq::ActionsApi.new(raw_client)
29
- @admin_tools = Allq::AdminApi.new(raw_client)
30
-
31
- @allq_tool = AllQTools.new(@instance, @admin_tools)
32
-
33
- stats_result = @allq_tool.get_stats[0]
34
- stats_result.stats.each do |stat|
35
- @instance.tube_delete(stat.tube)
36
- end
37
- end
38
-
39
- after do
40
- # run after each test
41
- end
42
-
43
- describe 'test an instance of ActionsApi' do
44
- it 'should create an instance of ActionsApi' do
45
- expect(@instance).to be_instance_of(Allq::ActionsApi)
46
- end
47
- end
48
-
49
- # unit tests for get_stats
50
- # Bury
51
- # Bury Job
52
- # @param job_id Job ID
53
- # @param [Hash] opts the optional parameters
54
- # @return [BasicResponse]
55
- describe 'get_stats test' do
56
- it "should work" do
57
- @allq_tool.add_job
58
- output = @admin_tools.stats_get[0].stats[0]
59
- data = output.tps
60
- expect(data).not_to be_nil
61
- end
62
- end
63
-
64
- # unit tests for bury_put
65
- # Bury
66
- # Bury Job
67
- # @param job_id Job ID
68
- # @param [Hash] opts the optional parameters
69
- # @return [BasicResponse]
70
- describe 'bury_put test' do
71
- it "should work" do
72
- @allq_tool.add_job
73
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
74
- job = @instance.job_get(DEFAULT_TUBE)
75
- @instance.bury_put(job.id)
76
- expect(@allq_tool.get_buried(DEFAULT_TUBE)).to eq(1)
77
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
78
- end
79
- end
80
-
81
- # unit tests for job_delete
82
- # Delete
83
- # Finished Job
84
- # @param job_id Job ID
85
- # @param [Hash] opts the optional parameters
86
- # @option opts [String] :tube Name of Tube (For deleting \"ready\" objects)
87
- # @return [BasicResponse]
88
- describe 'job_delete test' do
89
- it "should work" do
90
- @allq_tool.add_job
91
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
92
- job = @instance.peek_get(DEFAULT_TUBE)
93
- @instance.job_delete(job.id, tube: DEFAULT_TUBE)
94
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
95
- end
96
- end
97
-
98
- # unit tests for job_get
99
- # Job
100
- # Get job from queue
101
- # @param tube Name of tube
102
- # @param [Hash] opts the optional parameters
103
- # @return [JobResponse]
104
- describe 'job_get test' do
105
- it "should work" do
106
- @allq_tool.add_job
107
- job = @instance.job_get(DEFAULT_TUBE)
108
- expect(@allq_tool.get_reserved(DEFAULT_TUBE)).to eq(1)
109
- expect(job.id).to be_truthy
110
- end
111
- end
112
-
113
- # unit tests for multiple job_get
114
- # Job
115
- # Get job from queue
116
- # @param tube Name of tube
117
- # @param [Hash] opts the optional parameters
118
- # @return [JobResponse]
119
- describe 'mulitple_job_get test' do
120
- it "should work" do
121
- 1.upto(6) do
122
- @allq_tool.add_job
123
- end
124
- multiple_jobs = @instance.multiple_job_get(DEFAULT_TUBE, 4)
125
- expect(multiple_jobs.jobs.length).to eq(4)
126
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(2)
127
- multiple_jobs.jobs.each do |job|
128
- @instance.job_delete(job.id)
129
- end
130
- expect(@allq_tool.get_reserved(DEFAULT_TUBE)).to eq(0)
131
-
132
- multiple_jobs = @instance.multiple_job_get(DEFAULT_TUBE, 4)
133
- expect(multiple_jobs.jobs.length).to eq(2)
134
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
135
- end
136
- end
137
-
138
- # unit tests for job_post
139
- # Job
140
- # Put job into queue
141
- # @param new_job New Job Object
142
- # @param [Hash] opts the optional parameters
143
- # @return [JobRef]
144
- describe 'job_post test' do
145
- it "should work" do
146
- @allq_tool.add_job
147
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
148
- job = @instance.job_get(DEFAULT_TUBE)
149
- expect(job.id).to be_truthy
150
- end
151
- end
152
-
153
- # unit tests for parent_job_post
154
- # Parent Job
155
- # Create a parent job
156
- # @param new_parent_job New Parent Job Data
157
- # @param [Hash] opts the optional parameters
158
- # @return [JobRef]
159
- describe 'parent_job_post test' do
160
- it "should work" do
161
- new_parent_job = Allq::NewParentJob.new(tube: 'default',
162
- body: '<PARENT_BODY>',
163
- ttl: 1200,
164
- delay: 0,
165
- priority: 5,
166
- timeout: 1000,
167
- run_on_timeout: false,
168
- limit: 2)
169
- new_parent_job_response = @instance.parent_job_post(new_parent_job)
170
- expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
171
- job = @allq_tool.new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
172
- @instance.job_post(job)
173
- job = @allq_tool.new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
174
- @instance.job_post(job)
175
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(2)
176
- @allq_tool.get_finish(DEFAULT_TUBE)
177
- @allq_tool.get_finish(DEFAULT_TUBE)
178
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
179
- expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(0)
180
- @allq_tool.get_finish(DEFAULT_TUBE)
181
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
182
- end
183
- end
184
-
185
- # unit tests for parent_job_post
186
- # Parent Job
187
- # Create a parent job
188
- # @param new_parent_job New Parent Job Data
189
- # @param [Hash] opts the optional parameters
190
- # @return [JobRef]
191
- describe 'parent_job_post test with different tubes' do
192
- it "should work" do
193
- new_parent_job = Allq::NewParentJob.new(tube: 'default',
194
- body: '<PARENT_BODY>',
195
- ttl: 1200,
196
- delay: 0,
197
- priority: 5,
198
- timeout: 1000,
199
- run_on_timeout: false,
200
- limit: 2)
201
- new_parent_job_response = @instance.parent_job_post(new_parent_job)
202
- expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
203
-
204
- job = @allq_tool.new_job('foo', nil, new_parent_job_response.job_id)
205
- @instance.job_post(job)
206
- job = @allq_tool.new_job('foo', nil, new_parent_job_response.job_id)
207
- @instance.job_post(job)
208
- expect(@allq_tool.get_ready('foo')).to eq(2)
209
- @allq_tool.get_finish('foo')
210
- @allq_tool.get_finish('foo')
211
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
212
- expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(0)
213
- @allq_tool.get_finish(DEFAULT_TUBE)
214
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
215
- end
216
- end
217
-
218
- # unit tests for parent_job_post
219
- # Parent Job
220
- # Create a parent job
221
- # @param new_parent_job New Parent Job Data
222
- # @param [Hash] opts the optional parameters
223
- # @return [JobRef]
224
- describe 'parent_job_post should timeout if child not completed in time' do
225
- fit "should work" do
226
- new_parent_job = Allq::NewParentJob.new(tube: 'default',
227
- body: '<PARENT_BODY>',
228
- ttl: 1200,
229
- delay: 0,
230
- priority: 5,
231
- timeout: 2,
232
- run_on_timeout: true,
233
- limit: 2)
234
- new_parent_job_response = @instance.parent_job_post(new_parent_job)
235
- expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
236
-
237
- job = @allq_tool.new_job('foo', nil, new_parent_job_response.job_id)
238
- @instance.job_post(job)
239
- expect(@allq_tool.get_ready('foo')).to eq(1)
240
- expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
241
-
242
- sleep(7)
243
- expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(0)
244
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
245
- end
246
- end
247
-
248
- # unit tests for peek_get
249
- # Peek
250
- # Peek at next job
251
- # @param tube Tube name
252
- # @param [Hash] opts the optional parameters
253
- # @option opts [String] :buried Look in buried
254
- # @return [JobResponse]
255
- describe 'peek_get test' do
256
- it "should work" do
257
- @allq_tool.add_job
258
- job = @instance.peek_get(DEFAULT_TUBE)
259
- expect(job.id).to be_truthy
260
- end
261
- end
262
-
263
- describe 'peek_get buried test' do
264
- it "should work" do
265
- @allq_tool.add_job
266
- job = @instance.peek_get(DEFAULT_TUBE, buried: true)
267
- expect(job.id).to be_falsey
268
- job = @instance.job_get(DEFAULT_TUBE)
269
- @instance.bury_put(job.id)
270
- job = @instance.peek_get(DEFAULT_TUBE, buried: true)
271
- expect(job.id).to be_truthy
272
-
273
- end
274
- end
275
-
276
- # unit tests for peek_get
277
- # Peek
278
- # Peek at next job
279
- # @param tube Tube name
280
- # @param [Hash] opts the optional parameters
281
- # @option opts [String] :buried Look in buried
282
- # @return [JobResponse]
283
- describe 'peek_get test(no jobs)' do
284
- it "should work" do
285
- job = @instance.peek_get(DEFAULT_TUBE)
286
- expect(job.id).to be_falsey
287
- end
288
- end
289
-
290
- # unit tests for release_put
291
- # Release
292
- # Releases job back into queue
293
- # @param job_id Job ID
294
- # @param [Hash] opts the optional parameters
295
- # @return [BasicResponse]
296
- describe 'release_put test' do
297
- it "should work" do
298
- @allq_tool.add_job
299
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
300
- job = @instance.job_get(DEFAULT_TUBE)
301
- expect(@allq_tool.get_reserved(DEFAULT_TUBE)).to eq(1)
302
- expect(job.id).to be_truthy
303
- @instance.release_put(job.id)
304
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
305
- end
306
- end
307
-
308
- describe 'release should increment release' do
309
- it "should work" do
310
- @allq_tool.add_job
311
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
312
- job = @instance.job_get(DEFAULT_TUBE)
313
- expect(job.releases).to eq(0)
314
- @instance.release_put(job.id)
315
- sleep(1)
316
- job = @instance.job_get(DEFAULT_TUBE)
317
- expect(job.releases).to eq(1)
318
- @instance.release_put(job.id)
319
- sleep(1)
320
- job = @instance.job_get(DEFAULT_TUBE)
321
- expect(job.releases).to eq(2)
322
-
323
- end
324
- end
325
-
326
- # unit tests for set_children_started_put
327
- # Set Children Started
328
- # When a parent job doesn&#39;t know how many children are going to be added, this is the event that sets the final children count on the parent_job, allowing it to run when the children are done.
329
- # @param job_id Job ID
330
- # @param [Hash] opts the optional parameters
331
- # @return [BasicResponse]
332
- describe 'set_children_started_put test' do
333
- it "should work" do
334
- new_parent_job = Allq::NewParentJob.new(tube: 'default',
335
- body: '<PARENT_BODY>',
336
- ttl: 1200,
337
- delay: 0,
338
- priority: 5,
339
- timeout: 1000,
340
- run_on_timeout: false,
341
- limit: nil)
342
- new_parent_job_response = @instance.parent_job_post(new_parent_job)
343
- expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
344
- job = @allq_tool.new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
345
- @instance.job_post(job)
346
- job = @allq_tool.new_job(DEFAULT_TUBE, nil, new_parent_job_response.job_id)
347
- @instance.job_post(job)
348
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(2)
349
- @allq_tool.get_finish(DEFAULT_TUBE)
350
- @allq_tool.get_finish(DEFAULT_TUBE)
351
- # After jobs have already finished
352
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
353
- # Parent still waiting
354
- expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(1)
355
- # Set limit on parent
356
- @instance.set_children_started_put(new_parent_job_response.job_id)
357
- # Now parent gets moved to ready
358
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
359
- expect(@allq_tool.get_parents(DEFAULT_TUBE)).to eq(0)
360
- @allq_tool.get_finish(DEFAULT_TUBE)
361
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0)
362
- end
363
- end
364
-
365
- # unit tests for throttle_post
366
- # Throttle
367
- # Creates a throttle on a tube
368
- # @param throttle Throttle info
369
- # @param [Hash] opts the optional parameters
370
- # @return [TubeRef]
371
- describe 'throttle_post test' do
372
- it "should work" do
373
- throttle = Allq::Throttle.new(tps: 5, tube: "throttled")
374
- @instance.throttle_post(throttle)
375
- end
376
- end
377
-
378
- # unit tests for stats
379
- # Stats Action Count
380
- # Checks action count
381
- # @param throttle Throttle info
382
- # @param [Hash] opts the optional parameters
383
- # @return [TubeRef]
384
- describe 'throttle_post test' do
385
- it "should work" do
386
- @allq_tool.add_job
387
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
388
- @instance.job_get(DEFAULT_TUBE)
389
- stats_result = @allq_tool.get_stats[0]
390
- expect(stats_result.action_count > 1).to eq(true)
391
- end
392
- end
393
-
394
- # unit tests for touch_put
395
- # Touch
396
- # Touch job
397
- # @param job_id Job ID
398
- # @param [Hash] opts the optional parameters
399
- # @return [BasicResponse]
400
- describe 'touch_put test' do
401
- it "should work" do
402
- @allq_tool.add_job
403
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1)
404
- job = @instance.job_get(DEFAULT_TUBE)
405
- @instance.touch_put(job.id)
406
- end
407
- end
408
-
409
- # unit tests for tube_delete
410
- # Clear Tube
411
- # Delete all contents of tube
412
- # @param tube Tube Name
413
- # @param [Hash] opts the optional parameters
414
- # @return [BasicResponse]
415
- describe 'tube_delete test' do
416
- it "should work" do
417
- alt_tube_name = "alt_tube"
418
- new_job = Allq::NewJob.new(tube: alt_tube_name,
419
- body: "Some body",
420
- ttl: 1200,
421
- delay: 0,
422
- priority: 5,
423
- parent_id: nil)
424
- @instance.job_post(new_job)
425
- new_job = Allq::NewJob.new(tube: alt_tube_name,
426
- body: "Some body",
427
- ttl: 1200,
428
- delay: 0,
429
- priority: 5,
430
- parent_id: nil)
431
- @instance.job_post(new_job)
432
- new_job = Allq::NewJob.new(tube: alt_tube_name,
433
- body: "Some body",
434
- ttl: 1200,
435
- delay: 0,
436
- priority: 5,
437
- parent_id: nil)
438
- @instance.job_post(new_job)
439
- new_job = Allq::NewJob.new(tube: "alt_tube2",
440
- body: "Some body",
441
- ttl: 1200,
442
- delay: 0,
443
- priority: 5,
444
- parent_id: nil)
445
- @instance.job_post(new_job)
446
- new_job = Allq::NewJob.new(tube: "alt_tube2",
447
- body: "Some body",
448
- ttl: 1200,
449
- delay: 0,
450
- priority: 5,
451
- parent_id: nil)
452
- @instance.job_post(new_job)
453
- expect(@allq_tool.get_ready("alt_tube2")).to eq(2) # OK..it's there
454
- reserved_job = @instance.job_get("alt_tube2")
455
-
456
- # Other tube has 1 ready, 1 reserved
457
- expect(@allq_tool.get_ready("alt_tube2")).to eq(1)
458
- expect(@allq_tool.get_reserved("alt_tube2")).to eq(1)
459
-
460
- # Get 1 into buried, 1 into reserved, and 1 in ready so we can clear it
461
- expect(@allq_tool.get_ready(alt_tube_name)).to eq(3) # OK..it's there
462
- reserved_job = @instance.job_get(alt_tube_name)
463
- expect(@allq_tool.get_reserved(alt_tube_name)).to eq(1) # OK..it's there
464
- reserved_job = @instance.job_get(alt_tube_name)
465
- expect(@allq_tool.get_reserved(alt_tube_name)).to eq(2) # OK..it's there
466
- @instance.bury_put(reserved_job.id)
467
- expect(@allq_tool.get_buried(alt_tube_name)).to eq(1)
468
-
469
- # Now check that first tube is empty
470
- @instance.tube_delete(alt_tube_name)
471
- expect(@allq_tool.get_buried(alt_tube_name)).to eq(0)
472
- expect(@allq_tool.get_reserved(alt_tube_name)).to eq(0) # OK..it's there
473
- expect(@allq_tool.get_ready(alt_tube_name)).to eq(0)
474
-
475
- # ..and other tubes are fine
476
- expect(@allq_tool.get_ready("alt_tube2")).to eq(1)
477
- expect(@allq_tool.get_reserved("alt_tube2")).to eq(1)
478
- end
479
- end
480
-
481
- # unit tests for delay
482
- # Delay
483
- describe 'delay test' do
484
- it "should work" do
485
- new_job = Allq::NewJob.new(tube: DEFAULT_TUBE,
486
- body: "Some body",
487
- ttl: 1200,
488
- delay: 1,
489
- priority: 5,
490
- parent_id: nil)
491
- @instance.job_post(new_job)
492
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(0) # Too soon to show up
493
- sleep(4)
494
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1) # OK..it's there
495
- end
496
- end
497
-
498
- # unit tests for expire
499
- # Expire
500
- describe 'expire test' do
501
- it "should work" do
502
- new_job = Allq::NewJob.new(tube: DEFAULT_TUBE,
503
- body: "Some body",
504
- ttl: 1,
505
- delay: 0,
506
- priority: 5,
507
- parent_id: nil)
508
- @instance.job_post(new_job)
509
- sleep(1)
510
- @instance.job_get(DEFAULT_TUBE)
511
- expect(@allq_tool.get_reserved(DEFAULT_TUBE)).to eq(1)
512
- sleep(5)
513
- expect(@allq_tool.get_reserved(DEFAULT_TUBE)).to eq(0) # Should expire
514
- expect(@allq_tool.get_ready(DEFAULT_TUBE)).to eq(1) # ..and be back in ready
515
- end
516
- end
517
-
518
- end
519
-
520
-
521
- class AllQTools
522
- def initialize(action_client, admin_client)
523
- @action_client = action_client
524
- @admin_client = admin_client
525
- end
526
-
527
- def new_job(tube = 'default', body = nil, parent_id = nil)
528
- body = (0...8).map { (65 + rand(26)).chr }.join unless body
529
-
530
- new_job = Allq::NewJob.new(tube: tube,
531
- body: body,
532
- ttl: 1200,
533
- delay: 0,
534
- priority: 5,
535
- parent_id:parent_id)
536
- return new_job
537
- end
538
-
539
- def add_job(tube = DEFAULT_TUBE)
540
- client = @action_client
541
- job = new_job(tube)
542
- job = client.job_post(new_job)
543
- return job
544
- end
545
-
546
- def get_finish(tube)
547
- client = @action_client
548
- job = client.job_get(tube)
549
- client.job_delete(job.id)
550
- end
551
-
552
- def get_stats
553
- client = @admin_client
554
- client.stats_get
555
- end
556
-
557
- def get_ready(tube)
558
- stats = get_stats
559
- count = 0
560
- find_tueq(stats, tube) do |found_stat|
561
- count += found_stat.ready.to_i
562
- end
563
- return count
564
- end
565
-
566
- def get_reserved(tube)
567
- stats = get_stats
568
- count = 0
569
- find_tueq(stats, tube) do |found_stat|
570
- count += found_stat.reserved.to_i
571
- end
572
- return count
573
- end
574
-
575
- def get_buried(tube)
576
- stats = get_stats
577
- count = 0
578
- find_tueq(stats, tube) do |found_stat|
579
- count += found_stat.buried.to_i
580
- end
581
- return count
582
- end
583
-
584
- def get_parents(tube)
585
- stats = get_stats
586
- count = 0
587
- find_tueq(stats, tube) do |found_stat|
588
- count += found_stat.parents.to_i
589
- end
590
- return count
591
- end
592
-
593
- def find_tueq(all_stats, tube)
594
- all_stats.each do |server_stat|
595
- server_stat.stats.each do |stat|
596
- yield stat if stat.tube == tube
597
- end
598
- end
599
- end
600
- end
@@ -1,58 +0,0 @@
1
- =begin
2
- #AllQ
3
-
4
- #No description provided (generated by Swagger Codegen https://github.com/swagger-api/swagger-codegen)
5
-
6
- OpenAPI spec version: 1.0
7
-
8
- Generated by: https://github.com/swagger-api/swagger-codegen.git
9
- Swagger Codegen version: 2.3.1
10
-
11
- =end
12
-
13
- require 'spec_helper'
14
- require 'json'
15
-
16
- # Unit tests for Allq::AdminApi
17
- # Automatically generated by swagger-codegen (github.com/swagger-api/swagger-codegen)
18
- # Please update as you see appropriate
19
- describe 'AdminApi' do
20
- before do
21
- # run before each test
22
- @instance = Allq::AdminApi.new
23
- end
24
-
25
- after do
26
- # run after each test
27
- end
28
-
29
- describe 'test an instance of AdminApi' do
30
- it 'should create an instance of AdminApi' do
31
- expect(@instance).to be_instance_of(Allq::AdminApi)
32
- end
33
- end
34
-
35
- # unit tests for stats_get
36
- # Stats
37
- # Get Stats
38
- # @param [Hash] opts the optional parameters
39
- # @return [Array<StatsResults>]
40
- describe 'stats_get test' do
41
- it "should work" do
42
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
43
- end
44
- end
45
-
46
- # unit tests for update_servers_put
47
- # Reset Server Urls
48
- # Change server URLs
49
- # @param server_urls Comma Separated List URL String
50
- # @param [Hash] opts the optional parameters
51
- # @return [BasicResponse]
52
- describe 'update_servers_put test' do
53
- it "should work" do
54
- # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers
55
- end
56
- end
57
-
58
- end