summaryrefslogtreecommitdiff
path: root/spec/services
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-01-18 00:24:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2022-01-18 00:24:03 +0000
commitcfa5faaae0d9ac9a3c1fafb1a41e07b298029f48 (patch)
treeb7ce1807d00c85cb94cbdc4a031562623e5343d6 /spec/services
parentab5b519cca2356dd2b84a7fffc6ddbd6dc43a0ab (diff)
downloadgitlab-ce-cfa5faaae0d9ac9a3c1fafb1a41e07b298029f48.tar.gz
Add latest changes from gitlab-org/gitlab@14-6-stable-ee
Diffstat (limited to 'spec/services')
-rw-r--r--spec/services/ci/after_requeue_job_service_spec.rb60
-rw-r--r--spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb57
2 files changed, 92 insertions, 25 deletions
diff --git a/spec/services/ci/after_requeue_job_service_spec.rb b/spec/services/ci/after_requeue_job_service_spec.rb
index 2a5a971fdac..2465bac7d10 100644
--- a/spec/services/ci/after_requeue_job_service_spec.rb
+++ b/spec/services/ci/after_requeue_job_service_spec.rb
@@ -8,46 +8,56 @@ RSpec.describe Ci::AfterRequeueJobService do
let(:pipeline) { create(:ci_pipeline, project: project) }
- let!(:build) { create(:ci_build, pipeline: pipeline, stage_idx: 0, name: 'build') }
- let!(:test1) { create(:ci_build, :success, pipeline: pipeline, stage_idx: 1) }
- let!(:test2) { create(:ci_build, :skipped, pipeline: pipeline, stage_idx: 1) }
- let!(:test3) { create(:ci_build, :skipped, :dependent, pipeline: pipeline, stage_idx: 1, needed: build) }
- let!(:deploy) { create(:ci_build, :skipped, :dependent, pipeline: pipeline, stage_idx: 2, needed: test3) }
-
- subject(:execute_service) { described_class.new(project, user).execute(build) }
-
- it 'marks subsequent skipped jobs as processable' do
- expect(test1.reload).to be_success
- expect(test2.reload).to be_skipped
- expect(test3.reload).to be_skipped
- expect(deploy.reload).to be_skipped
-
- execute_service
-
- expect(test1.reload).to be_success
- expect(test2.reload).to be_created
- expect(test3.reload).to be_created
- expect(deploy.reload).to be_created
+ let!(:build1) { create(:ci_build, name: 'build1', pipeline: pipeline, stage_idx: 0) }
+ let!(:test1) { create(:ci_build, :success, name: 'test1', pipeline: pipeline, stage_idx: 1) }
+ let!(:test2) { create(:ci_build, :skipped, name: 'test2', pipeline: pipeline, stage_idx: 1) }
+ let!(:test3) { create(:ci_build, :skipped, :dependent, name: 'test3', pipeline: pipeline, stage_idx: 1, needed: build1) }
+ let!(:deploy) { create(:ci_build, :skipped, :dependent, name: 'deploy', pipeline: pipeline, stage_idx: 2, needed: test3) }
+
+ subject(:execute_service) { described_class.new(project, user).execute(build1) }
+
+ shared_examples 'processing subsequent skipped jobs' do
+ it 'marks subsequent skipped jobs as processable' do
+ expect(test1.reload).to be_success
+ expect(test2.reload).to be_skipped
+ expect(test3.reload).to be_skipped
+ expect(deploy.reload).to be_skipped
+
+ execute_service
+
+ expect(test1.reload).to be_success
+ expect(test2.reload).to be_created
+ expect(test3.reload).to be_created
+ expect(deploy.reload).to be_created
+ end
end
+ it_behaves_like 'processing subsequent skipped jobs'
+
context 'when there is a job need from the same stage' do
- let!(:test4) do
+ let!(:build2) do
create(:ci_build,
:skipped,
:dependent,
+ name: 'build2',
pipeline: pipeline,
stage_idx: 0,
scheduling_type: :dag,
- needed: build)
+ needed: build1)
end
- it 'marks subsequent skipped jobs as processable' do
- expect { execute_service }.to change { test4.reload.status }.from('skipped').to('created')
+ shared_examples 'processing the same stage job' do
+ it 'marks subsequent skipped jobs as processable' do
+ expect { execute_service }.to change { build2.reload.status }.from('skipped').to('created')
+ end
end
+
+ it_behaves_like 'processing subsequent skipped jobs'
+ it_behaves_like 'processing the same stage job'
end
context 'when the pipeline is a downstream pipeline and the bridge is depended' do
- let!(:trigger_job) { create(:ci_bridge, :strategy_depend, status: 'success') }
+ let!(:trigger_job) { create(:ci_bridge, :strategy_depend, name: 'trigger_job', status: 'success') }
before do
create(:ci_sources_pipeline, pipeline: pipeline, source_job: trigger_job)
diff --git a/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb b/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb
index 02f8f2dd99f..31e1b0a896d 100644
--- a/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb
+++ b/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb
@@ -1004,6 +1004,63 @@ RSpec.describe Ci::PipelineProcessing::AtomicProcessingService do
end
end
+ context 'when the dependency is stage-independent', :sidekiq_inline do
+ let(:config) do
+ <<-EOY
+ stages: [A, B]
+
+ A1:
+ stage: A
+ script: exit 0
+ when: manual
+
+ A2:
+ stage: A
+ script: exit 0
+ needs: [A1]
+
+ B:
+ stage: B
+ needs: [A2]
+ script: exit 0
+ EOY
+ end
+
+ let(:pipeline) do
+ Ci::CreatePipelineService.new(project, user, { ref: 'master' }).execute(:push).payload
+ end
+
+ before do
+ stub_ci_pipeline_yaml_file(config)
+ end
+
+ it 'processes subsequent jobs in the correct order when playing first job' do
+ expect(all_builds_names).to eq(%w[A1 A2 B])
+ expect(all_builds_statuses).to eq(%w[manual skipped skipped])
+
+ play_manual_action('A1')
+
+ expect(all_builds_names).to eq(%w[A1 A2 B])
+ expect(all_builds_statuses).to eq(%w[pending created created])
+ end
+
+ context 'when the FF ci_order_subsequent_jobs_by_stage is disabled' do
+ before do
+ stub_feature_flags(ci_order_subsequent_jobs_by_stage: false)
+ end
+
+ it 'processes subsequent jobs in an incorrect order when playing first job' do
+ expect(all_builds_names).to eq(%w[A1 A2 B])
+ expect(all_builds_statuses).to eq(%w[manual skipped skipped])
+
+ play_manual_action('A1')
+
+ expect(all_builds_names).to eq(%w[A1 A2 B])
+ expect(all_builds_statuses).to eq(%w[pending created skipped])
+ end
+ end
+ end
+
private
def all_builds