canvas_sync 0.17.1 → 0.17.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +58 -0
- data/lib/canvas_sync/job_batches/batch.rb +101 -115
- data/lib/canvas_sync/job_batches/callback.rb +29 -34
- data/lib/canvas_sync/job_batches/context_hash.rb +13 -5
- data/lib/canvas_sync/job_batches/hincr_max.lua +5 -0
- data/lib/canvas_sync/job_batches/jobs/managed_batch_job.rb +99 -0
- data/lib/canvas_sync/job_batches/jobs/serial_batch_job.rb +6 -65
- data/lib/canvas_sync/job_batches/pool.rb +213 -0
- data/lib/canvas_sync/job_batches/redis_model.rb +69 -0
- data/lib/canvas_sync/job_batches/redis_script.rb +163 -0
- data/lib/canvas_sync/job_batches/sidekiq.rb +24 -1
- data/lib/canvas_sync/job_batches/sidekiq/web.rb +114 -0
- data/lib/canvas_sync/job_batches/sidekiq/web/helpers.rb +41 -0
- data/lib/canvas_sync/job_batches/sidekiq/web/views/_batches_table.erb +42 -0
- data/lib/canvas_sync/job_batches/sidekiq/web/views/_pagination.erb +26 -0
- data/lib/canvas_sync/job_batches/sidekiq/web/views/batch.erb +138 -0
- data/lib/canvas_sync/job_batches/sidekiq/web/views/batches.erb +23 -0
- data/lib/canvas_sync/job_batches/sidekiq/web/views/pool.erb +85 -0
- data/lib/canvas_sync/job_batches/sidekiq/web/views/pools.erb +47 -0
- data/lib/canvas_sync/job_batches/status.rb +9 -5
- data/lib/canvas_sync/jobs/begin_sync_chain_job.rb +3 -1
- data/lib/canvas_sync/version.rb +1 -1
- data/spec/dummy/log/test.log +140455 -0
- data/spec/job_batching/batch_aware_job_spec.rb +1 -0
- data/spec/job_batching/batch_spec.rb +72 -16
- data/spec/job_batching/callback_spec.rb +1 -1
- data/spec/job_batching/context_hash_spec.rb +54 -0
- data/spec/job_batching/flow_spec.rb +5 -11
- data/spec/job_batching/integration/fail_then_succeed.rb +42 -0
- data/spec/job_batching/integration_helper.rb +6 -4
- data/spec/job_batching/sidekiq_spec.rb +1 -0
- data/spec/job_batching/status_spec.rb +4 -20
- data/spec/spec_helper.rb +3 -7
- metadata +19 -16
@@ -69,6 +69,7 @@ RSpec.describe CanvasSync::JobBatches::BatchAwareJob do
|
|
69
69
|
Thread.current[:batch] = CanvasSync::JobBatches::Batch.new(bid)
|
70
70
|
Thread.current[:batch].instance_variable_set(:@open, true)
|
71
71
|
end
|
72
|
+
after { Thread.current[:batch] = nil }
|
72
73
|
|
73
74
|
it 'yields' do
|
74
75
|
expect {
|
@@ -193,6 +193,7 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
193
193
|
|
194
194
|
context 'success' do
|
195
195
|
before { batch.on(:complete, Object) }
|
196
|
+
|
196
197
|
it 'tries to call complete callback' do
|
197
198
|
expect(CanvasSync::JobBatches::Batch).to receive(:enqueue_callbacks).with(:complete, bid).ordered
|
198
199
|
expect(CanvasSync::JobBatches::Batch).to receive(:enqueue_callbacks).with(:success, bid).ordered
|
@@ -208,6 +209,61 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
208
209
|
CanvasSync::JobBatches::Batch.process_successful_job(bid, jid)
|
209
210
|
end
|
210
211
|
|
212
|
+
it 'triggers callbacks as expected' do
|
213
|
+
ActiveJob::Base.queue_adapter = :sidekiq
|
214
|
+
CanvasSync::JobBatches::Batch::Callback.worker_class = CanvasSync::JobBatches::Sidekiq::SidekiqCallbackWorker
|
215
|
+
|
216
|
+
callback_instance = double('SampleCallback')
|
217
|
+
expect(SampleCallback).to receive(:new).at_least(1).times.and_return(callback_instance)
|
218
|
+
expect(callback_instance).to receive(:on_complete)
|
219
|
+
expect(callback_instance).to receive(:on_success)
|
220
|
+
|
221
|
+
batch.on(:complete, SampleCallback)
|
222
|
+
batch.on(:success, SampleCallback)
|
223
|
+
|
224
|
+
Sidekiq::Testing.inline! do
|
225
|
+
CanvasSync::JobBatches::Batch.process_failed_job(bid, jid)
|
226
|
+
CanvasSync::JobBatches::Batch.process_successful_job(bid, jid)
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
it 'triggers callbacks as expected' do
|
231
|
+
ActiveJob::Base.queue_adapter = :sidekiq
|
232
|
+
CanvasSync::JobBatches::Batch.redis { |r| r.hset("BID-#{bid}", 'pending', 0) }
|
233
|
+
|
234
|
+
class RetryingJob < BatchTestJobBase
|
235
|
+
@@failed = false
|
236
|
+
|
237
|
+
def perform
|
238
|
+
unless @@failed
|
239
|
+
@@failed = true
|
240
|
+
raise "A Failure"
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|
244
|
+
|
245
|
+
callback_instance = double('SampleCallback')
|
246
|
+
expect(SampleCallback).to receive(:new).at_least(1).times.and_return(callback_instance)
|
247
|
+
expect(callback_instance).to receive(:on_complete)
|
248
|
+
expect(callback_instance).to receive(:on_success)
|
249
|
+
|
250
|
+
batch.on(:complete, SampleCallback)
|
251
|
+
batch.on(:success, SampleCallback)
|
252
|
+
|
253
|
+
batch.jobs do
|
254
|
+
RetryingJob.perform_later
|
255
|
+
end
|
256
|
+
|
257
|
+
job_def = Sidekiq::Worker.jobs[0]
|
258
|
+
int_job_class = job_def["class"].constantize
|
259
|
+
|
260
|
+
begin
|
261
|
+
int_job_class.process_job(job_def)
|
262
|
+
rescue
|
263
|
+
end
|
264
|
+
Sidekiq::Worker.drain_all
|
265
|
+
end
|
266
|
+
|
211
267
|
it 'cleanups redis key' do
|
212
268
|
CanvasSync::JobBatches::Batch.process_successful_job(bid, jid)
|
213
269
|
expect(CanvasSync::JobBatches::Batch.redis { |r| r.get("BID-#{bid}-pending") }.to_i).to eq(0)
|
@@ -216,7 +272,6 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
216
272
|
end
|
217
273
|
|
218
274
|
describe '#increment_job_queue' do
|
219
|
-
let(:bid) { 'BID' }
|
220
275
|
let(:batch) { CanvasSync::JobBatches::Batch.new }
|
221
276
|
|
222
277
|
it 'increments pending' do
|
@@ -224,12 +279,6 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
224
279
|
pending = CanvasSync::JobBatches::Batch.redis { |r| r.hget("BID-#{batch.bid}", 'pending') }
|
225
280
|
expect(pending).to eq('1')
|
226
281
|
end
|
227
|
-
|
228
|
-
it 'increments total' do
|
229
|
-
batch.jobs do TestWorker.perform_async end
|
230
|
-
total = CanvasSync::JobBatches::Batch.redis { |r| r.hget("BID-#{batch.bid}", 'total') }
|
231
|
-
expect(total).to eq('1')
|
232
|
-
end
|
233
282
|
end
|
234
283
|
|
235
284
|
describe '#enqueue_callbacks' do
|
@@ -241,6 +290,7 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
241
290
|
context 'when no callbacks are defined' do
|
242
291
|
it 'clears redis keys' do
|
243
292
|
batch = CanvasSync::JobBatches::Batch.new
|
293
|
+
batch.jobs {}
|
244
294
|
expect(CanvasSync::JobBatches::Batch).to receive(:cleanup_redis).with(batch.bid)
|
245
295
|
CanvasSync::JobBatches::Batch.enqueue_callbacks(event, batch.bid)
|
246
296
|
end
|
@@ -260,8 +310,7 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
260
310
|
|
261
311
|
context 'With ActiveJob Adapter' do
|
262
312
|
around(:all) do |block|
|
263
|
-
CanvasSync::JobBatches::Batch::Callback.
|
264
|
-
CanvasSync::JobBatches::Batch::Callback.const_set(:Worker, CanvasSync::JobBatches::Batch::Callback::ActiveJobCallbackWorker)
|
313
|
+
CanvasSync::JobBatches::Batch::Callback.worker_class = CanvasSync::JobBatches::Batch::Callback::ActiveJobCallbackWorker
|
265
314
|
block.run
|
266
315
|
end
|
267
316
|
|
@@ -279,12 +328,15 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
279
328
|
let(:opts) { { 'a' => 'b' } }
|
280
329
|
|
281
330
|
it 'calls it passing options' do
|
331
|
+
ActiveJob::Base.queue_adapter = :test
|
332
|
+
|
282
333
|
batch = CanvasSync::JobBatches::Batch.new
|
283
334
|
batch.on(event, SampleCallback, opts)
|
335
|
+
batch.jobs {}
|
284
336
|
|
285
337
|
CanvasSync::JobBatches::Batch.enqueue_callbacks(event, batch.bid)
|
286
338
|
|
287
|
-
expect(CanvasSync::JobBatches::Batch::Callback
|
339
|
+
expect(CanvasSync::JobBatches::Batch::Callback.worker_class).to have_been_enqueued.with(
|
288
340
|
'SampleCallback', event.to_s, opts, batch.bid, nil
|
289
341
|
)
|
290
342
|
end
|
@@ -295,15 +347,18 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
295
347
|
let(:opts2) { { 'b' => 'a' } }
|
296
348
|
|
297
349
|
it 'enqueues each callback passing their options' do
|
350
|
+
ActiveJob::Base.queue_adapter = :test
|
351
|
+
|
298
352
|
batch = CanvasSync::JobBatches::Batch.new
|
299
353
|
batch.on(event, SampleCallback, opts)
|
300
354
|
batch.on(event, SampleCallback2, opts2)
|
355
|
+
batch.jobs{}
|
301
356
|
|
302
357
|
CanvasSync::JobBatches::Batch.enqueue_callbacks(event, batch.bid)
|
303
|
-
expect(CanvasSync::JobBatches::Batch::Callback
|
358
|
+
expect(CanvasSync::JobBatches::Batch::Callback.worker_class).to have_been_enqueued.with(
|
304
359
|
'SampleCallback2', event.to_s, opts2, batch.bid, nil
|
305
360
|
)
|
306
|
-
expect(CanvasSync::JobBatches::Batch::Callback
|
361
|
+
expect(CanvasSync::JobBatches::Batch::Callback.worker_class).to have_been_enqueued.with(
|
307
362
|
'SampleCallback', event.to_s, opts, batch.bid, nil
|
308
363
|
)
|
309
364
|
end
|
@@ -313,8 +368,7 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
313
368
|
|
314
369
|
context 'With Sidekiq Adapter' do
|
315
370
|
around(:all) do |block|
|
316
|
-
CanvasSync::JobBatches::Batch::Callback.
|
317
|
-
CanvasSync::JobBatches::Batch::Callback.const_set(:Worker, CanvasSync::JobBatches::Batch::Callback::SidekiqCallbackWorker)
|
371
|
+
CanvasSync::JobBatches::Batch::Callback.worker_class = CanvasSync::JobBatches::Sidekiq::SidekiqCallbackWorker
|
318
372
|
block.run
|
319
373
|
end
|
320
374
|
|
@@ -334,9 +388,10 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
334
388
|
it 'calls it passing options' do
|
335
389
|
batch = CanvasSync::JobBatches::Batch.new
|
336
390
|
batch.on(event, SampleCallback, opts)
|
391
|
+
batch.jobs{}
|
337
392
|
|
338
393
|
expect(Sidekiq::Client).to receive(:push_bulk).with(
|
339
|
-
'class' => Sidekiq::Batch::Callback
|
394
|
+
'class' => Sidekiq::Batch::Callback.worker_class,
|
340
395
|
'args' => [['SampleCallback', event.to_s, opts, batch.bid, nil]],
|
341
396
|
'queue' => 'default'
|
342
397
|
)
|
@@ -353,9 +408,10 @@ RSpec.describe CanvasSync::JobBatches::Batch do
|
|
353
408
|
batch = CanvasSync::JobBatches::Batch.new
|
354
409
|
batch.on(event, SampleCallback, opts)
|
355
410
|
batch.on(event, SampleCallback2, opts2)
|
411
|
+
batch.jobs{}
|
356
412
|
|
357
413
|
expect(Sidekiq::Client).to receive(:push_bulk).with(
|
358
|
-
'class' => Sidekiq::Batch::Callback
|
414
|
+
'class' => Sidekiq::Batch::Callback.worker_class,
|
359
415
|
'args' => [
|
360
416
|
['SampleCallback2', event.to_s, opts2, batch.bid, nil],
|
361
417
|
['SampleCallback', event.to_s, opts, batch.bid, nil]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
RSpec.describe CanvasSync::JobBatches::Batch::Callback
|
3
|
+
RSpec.describe CanvasSync::JobBatches::Batch::Callback.worker_class do
|
4
4
|
describe '#perform' do
|
5
5
|
it 'does not do anything if it cannot find the callback class' do
|
6
6
|
subject.perform('SampleCallback', 'complete', {}, 'ABCD', 'EFGH')
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
RSpec.describe CanvasSync::JobBatches::ContextHash do
|
4
|
+
|
5
|
+
class ContextedJob < BatchTestJobBase
|
6
|
+
def perform
|
7
|
+
was_performed(batch_context.flatten)
|
8
|
+
end
|
9
|
+
|
10
|
+
def was_performed(*args); end
|
11
|
+
|
12
|
+
def self.callback_perform(*args)
|
13
|
+
perform_later
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
it "works with first-level jobs" do
|
18
|
+
ActiveJob::Base.queue_adapter = :sidekiq
|
19
|
+
b = CanvasSync::JobBatches::Batch.new
|
20
|
+
b.context = { hello: 'world' }
|
21
|
+
expect_any_instance_of(ContextedJob).to receive(:was_performed).with({ 'hello' => 'world' })
|
22
|
+
b.jobs do
|
23
|
+
ContextedJob.perform_later
|
24
|
+
end
|
25
|
+
Sidekiq::Worker.drain_all
|
26
|
+
end
|
27
|
+
|
28
|
+
it "works with nested-batch jobs" do
|
29
|
+
ActiveJob::Base.queue_adapter = :sidekiq
|
30
|
+
b = CanvasSync::JobBatches::Batch.new
|
31
|
+
b.context = { hello: 'world', foo: 'bar' }
|
32
|
+
expect_any_instance_of(ContextedJob).to receive(:was_performed).with({ 'hello' => 'world', 'foo' => 'baz', 'some' => 'other' })
|
33
|
+
b.jobs do
|
34
|
+
b2 = CanvasSync::JobBatches::Batch.new
|
35
|
+
b2.context = { some: 'other', foo: 'baz' }
|
36
|
+
b2.jobs do
|
37
|
+
ContextedJob.perform_later
|
38
|
+
end
|
39
|
+
end
|
40
|
+
Sidekiq::Worker.drain_all
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'works with a callback batch' do
|
44
|
+
ActiveJob::Base.queue_adapter = :sidekiq
|
45
|
+
b = CanvasSync::JobBatches::Batch.new
|
46
|
+
b.context = { hello: 'world' }
|
47
|
+
b.on(:success, "ContextedJob.callback_perform")
|
48
|
+
expect_any_instance_of(ContextedJob).to receive(:was_performed).with({ 'hello' => 'world' })
|
49
|
+
b.jobs do
|
50
|
+
BatchTestJobBase.perform_later
|
51
|
+
end
|
52
|
+
Sidekiq::Worker.drain_all
|
53
|
+
end
|
54
|
+
end
|
@@ -21,30 +21,24 @@ RSpec.describe 'Batch flow' do
|
|
21
21
|
before { batch.on(:complete, SampleCallback, :id => 42) }
|
22
22
|
before { batch.description = 'describing the batch' }
|
23
23
|
let(:status) { CanvasSync::JobBatches::Batch::Status.new(batch.bid) }
|
24
|
-
let(:jids) { batch.jobs do 3.times do TestWorker.perform_async end end }
|
25
24
|
let(:queue) { Sidekiq::Queue.new }
|
26
25
|
|
27
26
|
it 'correctly initializes' do
|
28
|
-
expect(jids.size).to eq(3)
|
29
|
-
|
30
27
|
expect(batch.bid).not_to be_nil
|
31
28
|
expect(batch.description).to eq('describing the batch')
|
32
29
|
|
33
|
-
batch.jobs
|
30
|
+
batch.jobs do
|
31
|
+
3.times do
|
32
|
+
TestWorker.perform_async
|
33
|
+
end
|
34
|
+
end
|
34
35
|
|
35
|
-
expect(status.total).to eq(3)
|
36
36
|
expect(status.pending).to eq(3)
|
37
37
|
expect(status.failures).to eq(0)
|
38
38
|
expect(status.complete?).to be false
|
39
39
|
expect(status.created_at).not_to be_nil
|
40
40
|
expect(status.bid).to eq(batch.bid)
|
41
41
|
end
|
42
|
-
|
43
|
-
it 'handles an empty batch' do
|
44
|
-
batch = CanvasSync::JobBatches::Batch.new
|
45
|
-
jids = batch.jobs do nil end
|
46
|
-
expect(jids.size).to eq(0)
|
47
|
-
end
|
48
42
|
end
|
49
43
|
|
50
44
|
context 'when handling a nested batch' do
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require_relative '../integration_helper'
|
2
|
+
|
3
|
+
# Workflow when a Job fails, retries, and then succeeds
|
4
|
+
|
5
|
+
class Worker1
|
6
|
+
include Sidekiq::Worker
|
7
|
+
sidekiq_options retry: 5
|
8
|
+
|
9
|
+
@@failed = false
|
10
|
+
|
11
|
+
def perform
|
12
|
+
Sidekiq.logger.info "Work 1"
|
13
|
+
|
14
|
+
unless @@failed
|
15
|
+
@@failed = true
|
16
|
+
raise "One Failure"
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class MyCallback
|
22
|
+
def on_success(status, options)
|
23
|
+
Sidekiq.logger.info "Overall Success #{options} #{status.data}"
|
24
|
+
end
|
25
|
+
alias_method :multi, :on_success
|
26
|
+
|
27
|
+
def on_complete(status, options)
|
28
|
+
Sidekiq.logger.info "Overall Complete #{options} #{status.data}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
overall = CanvasSync::JobBatches::Batch.new
|
33
|
+
overall.on(:success, MyCallback, to: 'success@gmail.com')
|
34
|
+
overall.on(:complete, MyCallback, to: 'success@gmail.com')
|
35
|
+
overall.jobs do
|
36
|
+
Worker1.perform_async
|
37
|
+
end
|
38
|
+
|
39
|
+
puts "Overall bid #{overall.bid}"
|
40
|
+
|
41
|
+
output, keys = process_tests
|
42
|
+
overall_tests(output, keys, file: __FILE__)
|
@@ -1,9 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'sidekiq/batch'
|
3
2
|
require 'sidekiq/testing'
|
4
3
|
|
5
4
|
Sidekiq::Testing.server_middleware do |chain|
|
6
|
-
chain.add CanvasSync::JobBatches::
|
5
|
+
chain.add CanvasSync::JobBatches::Sidekiq::ServerMiddleware
|
7
6
|
end
|
8
7
|
|
9
8
|
Sidekiq.redis { |r| r.flushdb }
|
@@ -31,8 +30,11 @@ def process_tests
|
|
31
30
|
[output, keys]
|
32
31
|
end
|
33
32
|
|
34
|
-
def overall_tests
|
35
|
-
|
33
|
+
def overall_tests(output, keys, file: nil)
|
34
|
+
test_name = "Batch Integration Test"
|
35
|
+
test_name = File.basename(file, ".*") if file
|
36
|
+
|
37
|
+
Rspec.describe test_name do
|
36
38
|
it "runs overall complete callback" do
|
37
39
|
expect(output).to include "Overall Complete"
|
38
40
|
end
|
@@ -58,6 +58,7 @@ RSpec.describe CanvasSync::JobBatches::Sidekiq do
|
|
58
58
|
let(:bid) { 'SAMPLEBID' }
|
59
59
|
let(:jid) { 'SAMPLEJID' }
|
60
60
|
before { Thread.current[:batch] = CanvasSync::JobBatches::Batch.new(bid) }
|
61
|
+
after { Thread.current[:batch] = nil }
|
61
62
|
|
62
63
|
it 'yields' do
|
63
64
|
yielded = false
|
@@ -1,8 +1,8 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
RSpec.describe CanvasSync::JobBatches::Batch::Status do
|
4
|
-
let(:
|
5
|
-
let(:
|
4
|
+
let(:batch) { CanvasSync::JobBatches::Batch.new() }
|
5
|
+
let(:bid) { batch.bid }
|
6
6
|
subject { described_class.new(bid) }
|
7
7
|
|
8
8
|
describe '#join' do
|
@@ -51,7 +51,7 @@ RSpec.describe CanvasSync::JobBatches::Batch::Status do
|
|
51
51
|
end
|
52
52
|
|
53
53
|
context 'when with error' do
|
54
|
-
before { CanvasSync::JobBatches::Batch.process_failed_job(bid, 'jid123') }
|
54
|
+
before { batch.jobs{}; CanvasSync::JobBatches::Batch.process_failed_job(bid, 'jid123') }
|
55
55
|
|
56
56
|
it 'returns array with failed jids' do
|
57
57
|
expect(subject.failure_info).to eq(['jid123'])
|
@@ -59,25 +59,9 @@ RSpec.describe CanvasSync::JobBatches::Batch::Status do
|
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
|
-
describe '#total' do
|
63
|
-
context 'when not initalized' do
|
64
|
-
it 'returns 0 failed jobs' do
|
65
|
-
expect(subject.total).to eq(0)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'when more than 0' do
|
70
|
-
before { batch.jobs do TestWorker.perform_async end }
|
71
|
-
|
72
|
-
it 'returns failed jobs' do
|
73
|
-
expect(subject.total).to eq(1)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
62
|
describe '#data' do
|
79
63
|
it 'returns batch description' do
|
80
|
-
expect(subject.data).to include(
|
64
|
+
expect(subject.data).to include(failures: 0, pending: 0, created_at: nil, complete: false, failure_info: [], parent_bid: nil)
|
81
65
|
end
|
82
66
|
end
|
83
67
|
|
data/spec/spec_helper.rb
CHANGED
@@ -15,17 +15,13 @@ require 'pry-nav'
|
|
15
15
|
|
16
16
|
require 'sidekiq/testing'
|
17
17
|
Sidekiq::Testing.fake!
|
18
|
+
Sidekiq::Testing.server_middleware do |chain|
|
19
|
+
chain.add CanvasSync::JobBatches::Sidekiq::ServerMiddleware
|
20
|
+
end
|
18
21
|
|
19
22
|
require 'fakeredis/rspec'
|
20
23
|
Dir[File.dirname(__FILE__) + "/job_batching/support/**/*.rb"].each {|f| require f }
|
21
24
|
|
22
|
-
# Fix an issue with fakeredis with Redis >=4.2
|
23
|
-
class Redis::Connection::Memory
|
24
|
-
def exists(*keys)
|
25
|
-
keys.count { |key| data.key?(key) }
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
25
|
ActiveRecord::Migration.maintain_test_schema!
|
30
26
|
|
31
27
|
RSpec.configure do |config|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: canvas_sync
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.17.
|
4
|
+
version: 0.17.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nate Collings
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-11-
|
11
|
+
date: 2020-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -234,20 +234,6 @@ dependencies:
|
|
234
234
|
- - ">="
|
235
235
|
- !ruby/object:Gem::Version
|
236
236
|
version: '0'
|
237
|
-
- !ruby/object:Gem::Dependency
|
238
|
-
name: fakeredis
|
239
|
-
requirement: !ruby/object:Gem::Requirement
|
240
|
-
requirements:
|
241
|
-
- - ">="
|
242
|
-
- !ruby/object:Gem::Version
|
243
|
-
version: '0'
|
244
|
-
type: :development
|
245
|
-
prerelease: false
|
246
|
-
version_requirements: !ruby/object:Gem::Requirement
|
247
|
-
requirements:
|
248
|
-
- - ">="
|
249
|
-
- !ruby/object:Gem::Version
|
250
|
-
version: '0'
|
251
237
|
- !ruby/object:Gem::Dependency
|
252
238
|
name: sidekiq
|
253
239
|
requirement: !ruby/object:Gem::Requirement
|
@@ -427,10 +413,23 @@ files:
|
|
427
413
|
- lib/canvas_sync/job_batches/callback.rb
|
428
414
|
- lib/canvas_sync/job_batches/chain_builder.rb
|
429
415
|
- lib/canvas_sync/job_batches/context_hash.rb
|
416
|
+
- lib/canvas_sync/job_batches/hincr_max.lua
|
430
417
|
- lib/canvas_sync/job_batches/jobs/base_job.rb
|
431
418
|
- lib/canvas_sync/job_batches/jobs/concurrent_batch_job.rb
|
419
|
+
- lib/canvas_sync/job_batches/jobs/managed_batch_job.rb
|
432
420
|
- lib/canvas_sync/job_batches/jobs/serial_batch_job.rb
|
421
|
+
- lib/canvas_sync/job_batches/pool.rb
|
422
|
+
- lib/canvas_sync/job_batches/redis_model.rb
|
423
|
+
- lib/canvas_sync/job_batches/redis_script.rb
|
433
424
|
- lib/canvas_sync/job_batches/sidekiq.rb
|
425
|
+
- lib/canvas_sync/job_batches/sidekiq/web.rb
|
426
|
+
- lib/canvas_sync/job_batches/sidekiq/web/helpers.rb
|
427
|
+
- lib/canvas_sync/job_batches/sidekiq/web/views/_batches_table.erb
|
428
|
+
- lib/canvas_sync/job_batches/sidekiq/web/views/_pagination.erb
|
429
|
+
- lib/canvas_sync/job_batches/sidekiq/web/views/batch.erb
|
430
|
+
- lib/canvas_sync/job_batches/sidekiq/web/views/batches.erb
|
431
|
+
- lib/canvas_sync/job_batches/sidekiq/web/views/pool.erb
|
432
|
+
- lib/canvas_sync/job_batches/sidekiq/web/views/pools.erb
|
434
433
|
- lib/canvas_sync/job_batches/status.rb
|
435
434
|
- lib/canvas_sync/jobs/begin_sync_chain_job.rb
|
436
435
|
- lib/canvas_sync/jobs/report_checker.rb
|
@@ -597,7 +596,9 @@ files:
|
|
597
596
|
- spec/job_batching/batch_aware_job_spec.rb
|
598
597
|
- spec/job_batching/batch_spec.rb
|
599
598
|
- spec/job_batching/callback_spec.rb
|
599
|
+
- spec/job_batching/context_hash_spec.rb
|
600
600
|
- spec/job_batching/flow_spec.rb
|
601
|
+
- spec/job_batching/integration/fail_then_succeed.rb
|
601
602
|
- spec/job_batching/integration/integration.rb
|
602
603
|
- spec/job_batching/integration/nested.rb
|
603
604
|
- spec/job_batching/integration/simple.rb
|
@@ -789,7 +790,9 @@ test_files:
|
|
789
790
|
- spec/job_batching/batch_aware_job_spec.rb
|
790
791
|
- spec/job_batching/batch_spec.rb
|
791
792
|
- spec/job_batching/callback_spec.rb
|
793
|
+
- spec/job_batching/context_hash_spec.rb
|
792
794
|
- spec/job_batching/flow_spec.rb
|
795
|
+
- spec/job_batching/integration/fail_then_succeed.rb
|
793
796
|
- spec/job_batching/integration/integration.rb
|
794
797
|
- spec/job_batching/integration/nested.rb
|
795
798
|
- spec/job_batching/integration/simple.rb
|