Commit cfea7834 authored by Rémy Coutable's avatar Rémy Coutable

Merge branch 'bvl-mark-expire-pipeline-cache-worker-idempotent' into 'master'

Mark the ExpirePipelineCacheWorker as idempotent

See merge request gitlab-org/gitlab!29489
parents 0a348ab3 5fc50b04
...@@ -709,7 +709,7 @@ ...@@ -709,7 +709,7 @@
:urgency: :high :urgency: :high
:resource_boundary: :cpu :resource_boundary: :cpu
:weight: 3 :weight: 3
:idempotent: :idempotent: true
- :name: pipeline_creation:create_pipeline - :name: pipeline_creation:create_pipeline
:feature_category: :continuous_integration :feature_category: :continuous_integration
:has_external_dependencies: :has_external_dependencies:
......
# frozen_string_literal: true # frozen_string_literal: true
class ExpirePipelineCacheWorker # rubocop:disable Scalability/IdempotentWorker class ExpirePipelineCacheWorker
include ApplicationWorker include ApplicationWorker
include PipelineQueue include PipelineQueue
...@@ -8,6 +8,8 @@ class ExpirePipelineCacheWorker # rubocop:disable Scalability/IdempotentWorker ...@@ -8,6 +8,8 @@ class ExpirePipelineCacheWorker # rubocop:disable Scalability/IdempotentWorker
urgency :high urgency :high
worker_resource_boundary :cpu worker_resource_boundary :cpu
idempotent!
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def perform(pipeline_id) def perform(pipeline_id)
pipeline = Ci::Pipeline.find_by(id: pipeline_id) pipeline = Ci::Pipeline.find_by(id: pipeline_id)
......
...@@ -11,7 +11,9 @@ describe ExpirePipelineCacheWorker do ...@@ -11,7 +11,9 @@ describe ExpirePipelineCacheWorker do
describe '#perform' do describe '#perform' do
it 'executes the service' 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) subject.perform(pipeline.id)
end end
...@@ -31,5 +33,9 @@ describe ExpirePipelineCacheWorker do ...@@ -31,5 +33,9 @@ describe ExpirePipelineCacheWorker do
subject.perform(pipeline.id) subject.perform(pipeline.id)
end end
it_behaves_like 'an idempotent worker' do
let(:job_args) { [pipeline.id] }
end
end 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