canvas_sync 0.17.3.beta2 → 0.17.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/canvas_sync/job_batches/batch.rb +43 -31
- data/lib/canvas_sync/job_batches/batch_aware_job.rb +1 -1
- data/lib/canvas_sync/job_batches/callback.rb +22 -17
- data/lib/canvas_sync/job_batches/context_hash.rb +6 -1
- data/lib/canvas_sync/job_batches/pool.rb +39 -19
- data/lib/canvas_sync/job_batches/redis_model.rb +2 -0
- data/lib/canvas_sync/job_batches/sidekiq.rb +5 -2
- 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 -0
- data/lib/canvas_sync/version.rb +1 -1
- data/spec/dummy/log/test.log +65305 -0
- data/spec/job_batching/batch_spec.rb +0 -1
- data/spec/job_batching/context_hash_spec.rb +54 -0
- data/spec/job_batching/status_spec.rb +3 -3
- data/spec/spec_helper.rb +3 -7
- metadata +14 -18
@@ -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
|
@@ -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'])
|
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.5
|
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
|
+
date: 2020-12-02 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
|
@@ -436,6 +422,14 @@ files:
|
|
436
422
|
- lib/canvas_sync/job_batches/redis_model.rb
|
437
423
|
- lib/canvas_sync/job_batches/redis_script.rb
|
438
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
|
439
433
|
- lib/canvas_sync/job_batches/status.rb
|
440
434
|
- lib/canvas_sync/jobs/begin_sync_chain_job.rb
|
441
435
|
- lib/canvas_sync/jobs/report_checker.rb
|
@@ -602,6 +596,7 @@ files:
|
|
602
596
|
- spec/job_batching/batch_aware_job_spec.rb
|
603
597
|
- spec/job_batching/batch_spec.rb
|
604
598
|
- spec/job_batching/callback_spec.rb
|
599
|
+
- spec/job_batching/context_hash_spec.rb
|
605
600
|
- spec/job_batching/flow_spec.rb
|
606
601
|
- spec/job_batching/integration/fail_then_succeed.rb
|
607
602
|
- spec/job_batching/integration/integration.rb
|
@@ -649,9 +644,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
649
644
|
version: '0'
|
650
645
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
651
646
|
requirements:
|
652
|
-
- - "
|
647
|
+
- - ">="
|
653
648
|
- !ruby/object:Gem::Version
|
654
|
-
version:
|
649
|
+
version: '0'
|
655
650
|
requirements: []
|
656
651
|
rubygems_version: 3.0.3
|
657
652
|
signing_key:
|
@@ -795,6 +790,7 @@ test_files:
|
|
795
790
|
- spec/job_batching/batch_aware_job_spec.rb
|
796
791
|
- spec/job_batching/batch_spec.rb
|
797
792
|
- spec/job_batching/callback_spec.rb
|
793
|
+
- spec/job_batching/context_hash_spec.rb
|
798
794
|
- spec/job_batching/flow_spec.rb
|
799
795
|
- spec/job_batching/integration/fail_then_succeed.rb
|
800
796
|
- spec/job_batching/integration/integration.rb
|