Commit 48e71aca authored by Matija Čupić's avatar Matija Čupić

Make PipelineUpdateWorker idempotent

parent d9aca16a
...@@ -1018,7 +1018,7 @@ ...@@ -1018,7 +1018,7 @@
:urgency: :high :urgency: :high
:resource_boundary: :unknown :resource_boundary: :unknown
:weight: 5 :weight: 5
:idempotent: :idempotent: true
:tags: [] :tags: []
- :name: pipeline_processing:stage_update - :name: pipeline_processing:stage_update
:feature_category: :continuous_integration :feature_category: :continuous_integration
......
# frozen_string_literal: true # frozen_string_literal: true
class PipelineUpdateWorker # rubocop:disable Scalability/IdempotentWorker class PipelineUpdateWorker
include ApplicationWorker include ApplicationWorker
include PipelineQueue include PipelineQueue
queue_namespace :pipeline_processing queue_namespace :pipeline_processing
urgency :high urgency :high
idempotent!
def perform(pipeline_id) def perform(pipeline_id)
Ci::Pipeline.find_by_id(pipeline_id)&.update_legacy_status Ci::Pipeline.find_by_id(pipeline_id)&.update_legacy_status
end end
......
...@@ -12,6 +12,14 @@ RSpec.describe PipelineUpdateWorker do ...@@ -12,6 +12,14 @@ RSpec.describe PipelineUpdateWorker do
described_class.new.perform(pipeline.id) described_class.new.perform(pipeline.id)
end end
include_examples 'an idempotent worker' do
let(:job_args) { [pipeline.id] }
it 'sets pipeline status to skipped' do
expect { subject }.to change { pipeline.reload.status }.from('pending').to('skipped')
end
end
end end
context 'when pipeline does not exist' do context 'when pipeline does not exist' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment