diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-12-19 14:01:45 +0300 |
commit | 9297025d0b7ddf095eb618dfaaab2ff8f2018d8b (patch) | |
tree | 865198c01d1824a9b098127baa3ab980c9cd2c06 /spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb | |
parent | 6372471f43ee03c05a7c1f8b0c6ac6b8a7431dbe (diff) |
Add latest changes from gitlab-org/gitlab@16-7-stable-eev16.7.0-rc42
Diffstat (limited to 'spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb')
-rw-r--r-- | spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb b/spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb index a5dda1d13aa..0d83187f9e4 100644 --- a/spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb +++ b/spec/services/ci/pipeline_creation/cancel_redundant_pipelines_service_spec.rb @@ -207,12 +207,12 @@ RSpec.describe Ci::PipelineCreation::CancelRedundantPipelinesService, feature_ca it 'does not cancel any builds' do expect(build_statuses(prev_pipeline)).to contain_exactly('running', 'success', 'created') - expect(build_statuses(parent_pipeline)).to contain_exactly('running', 'running') + expect(build_statuses(parent_pipeline)).to contain_exactly('created', 'running', 'running') execute expect(build_statuses(prev_pipeline)).to contain_exactly('running', 'success', 'created') - expect(build_statuses(parent_pipeline)).to contain_exactly('running', 'running') + expect(build_statuses(parent_pipeline)).to contain_exactly('created', 'running', 'running') end end @@ -227,6 +227,25 @@ RSpec.describe Ci::PipelineCreation::CancelRedundantPipelinesService, feature_ca end end + context 'when there are trigger jobs' do + before do + create(:ci_bridge, :created, pipeline: prev_pipeline) + create(:ci_bridge, :running, pipeline: prev_pipeline) + create(:ci_bridge, :success, pipeline: prev_pipeline) + create(:ci_bridge, :interruptible, :created, pipeline: prev_pipeline) + create(:ci_bridge, :interruptible, :running, pipeline: prev_pipeline) + create(:ci_bridge, :interruptible, :success, pipeline: prev_pipeline) + end + + it 'still cancels the pipeline because auto-cancel is not affected by non-interruptible started triggers' do + execute + + expect(job_statuses(prev_pipeline)).to contain_exactly( + 'canceled', 'success', 'canceled', 'canceled', 'canceled', 'success', 'canceled', 'canceled', 'success') + expect(job_statuses(pipeline)).to contain_exactly('pending') + end + end + it 'does not cancel future pipelines' do expect(prev_pipeline.id).to be < pipeline.id expect(build_statuses(pipeline)).to contain_exactly('pending') @@ -269,7 +288,8 @@ RSpec.describe Ci::PipelineCreation::CancelRedundantPipelinesService, feature_ca private - def build_statuses(pipeline) - pipeline.builds.pluck(:status) + def job_statuses(pipeline) + pipeline.statuses.pluck(:status) end + alias_method :build_statuses, :job_statuses end |