diff options
author | Kamil Trzciński <ayufan@ayufan.eu> | 2019-08-21 12:03:42 +0200 |
---|---|---|
committer | Kamil Trzciński <ayufan@ayufan.eu> | 2019-08-21 13:21:55 +0200 |
commit | 8d17c4dae6b4662dddffe9e2ddca8100e8cd3d0b (patch) | |
tree | f13731d3bdb703e868517403afd83f92d965ea7e /spec | |
parent | cb193cd6b54ee9ac0cf87650100585293540abfa (diff) | |
download | gitlab-ce-8d17c4dae6b4662dddffe9e2ddca8100e8cd3d0b.tar.gz |
Properly handle `sidekiq` skipsidekiq-interrupt-running-jobs
Transform `CancelledError` into `JobRetry::Skip`
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/gitlab/sidekiq_monitor_spec.rb | 14 |
2 files changed, 19 insertions, 7 deletions
diff --git a/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb b/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb index 3ca2ddf3cb1..2933d26a387 100644 --- a/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb +++ b/spec/lib/gitlab/sidekiq_middleware/monitor_spec.rb @@ -25,5 +25,17 @@ describe Gitlab::SidekiqMiddleware::Monitor do expect(result).to eq('value') end + + context 'when cancel happens' do + subject do + monitor.call(worker, job, queue) do + raise Gitlab::SidekiqMonitor::CancelledError + end + end + + it 'does skip this job' do + expect { subject }.to raise_error(Sidekiq::JobRetry::Skip) + end + end end end diff --git a/spec/lib/gitlab/sidekiq_monitor_spec.rb b/spec/lib/gitlab/sidekiq_monitor_spec.rb index 62baa326887..bbd7bf90217 100644 --- a/spec/lib/gitlab/sidekiq_monitor_spec.rb +++ b/spec/lib/gitlab/sidekiq_monitor_spec.rb @@ -54,7 +54,7 @@ describe Gitlab::SidekiqMonitor do it 'logs start message' do expect(Sidekiq.logger).to receive(:info) .with( - class: described_class, + class: described_class.to_s, action: 'start', message: 'Starting Monitor Daemon') @@ -66,7 +66,7 @@ describe Gitlab::SidekiqMonitor do it 'logs stop message' do expect(Sidekiq.logger).to receive(:warn) .with( - class: described_class, + class: described_class.to_s, action: 'stop', message: 'Stopping Monitor Daemon') @@ -78,7 +78,7 @@ describe Gitlab::SidekiqMonitor do it 'logs StandardError message' do expect(Sidekiq.logger).to receive(:warn) .with( - class: described_class, + class: described_class.to_s, action: 'exception', message: 'My Exception') @@ -91,7 +91,7 @@ describe Gitlab::SidekiqMonitor do it 'logs and raises Exception message' do expect(Sidekiq.logger).to receive(:warn) .with( - class: described_class, + class: described_class.to_s, action: 'exception', message: 'My Exception') @@ -131,13 +131,13 @@ describe Gitlab::SidekiqMonitor do expect(Sidekiq.logger).to receive(:info) .with( - class: described_class, + class: described_class.to_s, action: 'start', message: 'Starting Monitor Daemon') expect(Sidekiq.logger).to receive(:info) .with( - class: described_class, + class: described_class.to_s, channel: described_class::NOTIFICATION_CHANNEL, message: 'Received payload on channel', payload: payload @@ -215,7 +215,7 @@ describe Gitlab::SidekiqMonitor do it 'does log cancellation message' do expect(Sidekiq.logger).to receive(:warn) .with( - class: described_class, + class: described_class.to_s, action: 'cancel', message: 'Canceling thread with CancelledError', jid: 'my-jid', |