Skip to content
Snippets Groups Projects
Unverified Commit 8f3d6dd6 authored by Marius Bobin's avatar Marius Bobin Committed by GitLab
Browse files

Merge branch 'add-flexible-params-to-cancel-redundant-pipelines-worker' into 'master'

Add options hash param to CancelRedundantPipelinesWorker

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/168261



Merged-by: default avatarMarius Bobin <mbobin@gitlab.com>
Approved-by: default avatarPanos Kanellidis <pkanellidis@gitlab.com>
Approved-by: default avatarMarius Bobin <mbobin@gitlab.com>
Reviewed-by: default avatarPanos Kanellidis <pkanellidis@gitlab.com>
Co-authored-by: default avatardrew <dscimino@gmail.com>
parents ef9658f6 48dce725
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -10,11 +10,12 @@ class CancelRedundantPipelinesWorker
deduplicate :until_executed
urgency :high
 
def perform(pipeline_id)
Ci::Pipeline.find_by_id(pipeline_id).try do |pipeline|
Ci::PipelineCreation::CancelRedundantPipelinesService
.new(pipeline)
.execute
def perform(pipeline_id, options = {})
relation = Ci::Pipeline.all
relation = relation.in_partition(options['partition_id']) if options['partition_id'].present?
relation.find_by_id(pipeline_id).try do |pipeline|
Ci::PipelineCreation::CancelRedundantPipelinesService.new(pipeline).execute
end
end
end
Loading
Loading
Loading
Loading
@@ -24,6 +24,24 @@
perform
end
 
context 'with a passed partition_id' do
subject(:perform) { described_class.new.perform(pipeline.id, { 'partition_id' => pipeline.partition_id }) }
it 'finds the passed pipeline in the correct partition and passes it to the service' do
expect(Ci::PipelineCreation::CancelRedundantPipelinesService)
.to receive(:new)
.with(pipeline)
.and_return(service)
expect(service).to receive(:execute)
recorder = ActiveRecord::QueryRecorder.new { perform }
expect(recorder.count).to eq(1)
expect(recorder.log.first).to match(/^SELECT "ci_pipelines".*"partition_id" = #{pipeline.partition_id}/)
end
end
context 'if pipeline is deleted' do
subject(:perform) { described_class.new.perform(non_existing_record_id) }
 
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment