Commit fe64fd67 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Mark the StageUpdateWorker as idempotent

This worker was already idempotent, it updates the status of a stage
based on the jobs inside it.

This also means we can safely deduplicate it.
parent a256e32a
......@@ -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