Commit fab9de33 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch 'bvl-make-stage-update-worker-idempotent' into 'master'

Mark the StageUpdateWorker as idempotent

See merge request gitlab-org/gitlab!29803
parents 3178a722 fe64fd67
......@@ -849,7 +849,7 @@
:urgency: :high
:resource_boundary: :unknown
:weight: 5
:idempotent:
:idempotent: true
- :name: pipeline_processing:update_head_pipeline_for_merge_request
:feature_category: :continuous_integration
:has_external_dependencies:
......
# frozen_string_literal: true
class StageUpdateWorker # rubocop:disable Scalability/IdempotentWorker
class StageUpdateWorker
include ApplicationWorker
include PipelineQueue
queue_namespace :pipeline_processing
urgency :high
idempotent!
def perform(stage_id)
Ci::Stage.find_by_id(stage_id)&.update_legacy_status
end
......
......@@ -12,6 +12,15 @@ describe StageUpdateWorker do
described_class.new.perform(stage.id)
end
it_behaves_like 'an idempotent worker' do
let(:job_args) { [stage.id] }
it 'results in the stage getting the skipped status' do
expect { subject }.to change { stage.reload.status }.from('pending').to('skipped')
expect { subject }.not_to change { stage.reload.status }
end
end
end
context 'when stage 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