Commit 5fc50b04 authored by Bob Van Landuyt's avatar Bob Van Landuyt

Mark the ExpirePipelineCacheWorker as idempotent

This worker expires cache, so it is already idempotent: expiring the
cache twice does nothing.
parent b6c5dcd7
......@@ -709,7 +709,7 @@
:urgency: :high
:resource_boundary: :cpu
:weight: 3
:idempotent:
:idempotent: true
- :name: pipeline_creation:create_pipeline
:feature_category: :continuous_integration
:has_external_dependencies:
......
# frozen_string_literal: true
class ExpirePipelineCacheWorker # rubocop:disable Scalability/IdempotentWorker
class ExpirePipelineCacheWorker
include ApplicationWorker
include PipelineQueue
......@@ -8,6 +8,8 @@ class ExpirePipelineCacheWorker # rubocop:disable Scalability/IdempotentWorker
urgency :high
worker_resource_boundary :cpu
idempotent!
# rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id)
pipeline = Ci::Pipeline.find_by(id: pipeline_id)
......
......@@ -11,7 +11,9 @@ describe ExpirePipelineCacheWorker do
describe '#perform' do
it 'executes the service' do
expect_any_instance_of(Ci::ExpirePipelineCacheService).to receive(:execute).with(pipeline).and_call_original
expect_next_instance_of(Ci::ExpirePipelineCacheService) do |instance|
expect(instance).to receive(:execute).with(pipeline).and_call_original
end
subject.perform(pipeline.id)
end
......@@ -31,5 +33,9 @@ describe ExpirePipelineCacheWorker do
subject.perform(pipeline.id)
end
it_behaves_like 'an idempotent worker' do
let(:job_args) { [pipeline.id] }
end
end
end
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