diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 21:09:08 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-14 21:09:08 +0000 |
commit | 866ca4e49ff74ffadf8e6f6ff663a168489c2aba (patch) | |
tree | cc3135b1bae11dbd1cb3a30cb547473ad89a5551 /spec/services/ci | |
parent | 26a50872e9da9509c52c70f74dc21698fec906db (diff) | |
download | gitlab-ce-866ca4e49ff74ffadf8e6f6ff663a168489c2aba.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/ci')
-rw-r--r-- | spec/services/ci/pipeline_processing/shared_processing_service.rb | 25 | ||||
-rw-r--r-- | spec/services/ci/process_build_service_spec.rb | 31 |
2 files changed, 56 insertions, 0 deletions
diff --git a/spec/services/ci/pipeline_processing/shared_processing_service.rb b/spec/services/ci/pipeline_processing/shared_processing_service.rb index 2349dedf370..ca003299535 100644 --- a/spec/services/ci/pipeline_processing/shared_processing_service.rb +++ b/spec/services/ci/pipeline_processing/shared_processing_service.rb @@ -880,6 +880,31 @@ shared_examples 'Pipeline Processing Service' do end end + context 'when a needed job is skipped', :sidekiq_inline do + let!(:linux_build) { create_build('linux:build', stage: 'build', stage_idx: 0) } + let!(:linux_rspec) { create_build('linux:rspec', stage: 'test', stage_idx: 1) } + let!(:deploy) do + create_build('deploy', stage: 'deploy', stage_idx: 2, scheduling_type: :dag, needs: [ + create(:ci_build_need, name: 'linux:rspec') + ]) + end + + it 'skips the jobs depending on it' do + expect(process_pipeline).to be_truthy + + expect(stages).to eq(%w(pending created created)) + expect(all_builds.pending).to contain_exactly(linux_build) + + linux_build.reset.drop! + + expect(stages).to eq(%w(failed skipped skipped)) + expect(all_builds.failed).to contain_exactly(linux_build) + expect(all_builds.skipped).to contain_exactly(linux_rspec, deploy) + end + end + + private + def all_builds pipeline.builds.order(:stage_idx, :id) end diff --git a/spec/services/ci/process_build_service_spec.rb b/spec/services/ci/process_build_service_spec.rb index 704685417bb..abc5c18a523 100644 --- a/spec/services/ci/process_build_service_spec.rb +++ b/spec/services/ci/process_build_service_spec.rb @@ -22,6 +22,14 @@ describe Ci::ProcessBuildService, '#execute' do end end + context 'when current status is skipped' do + let(:current_status) { 'skipped' } + + it 'changes the build status' do + expect { subject }.to change { build.status }.to('pending') + end + end + context 'when current status is failed' do let(:current_status) { 'failed' } @@ -114,4 +122,27 @@ describe Ci::ProcessBuildService, '#execute' do end end end + + context 'when build is scheduled with DAG' do + let(:pipeline) { create(:ci_pipeline, ref: 'master', project: project) } + let!(:build) { create(:ci_build, :created, when: :on_success, pipeline: pipeline, scheduling_type: :dag) } + let!(:other_build) { create(:ci_build, :created, when: :on_success, pipeline: pipeline) } + let!(:build_on_other_build) { create(:ci_build_need, build: build, name: other_build.name) } + + context 'when current status is success' do + let(:current_status) { 'success' } + + it 'enqueues the build' do + expect { subject }.to change { build.status }.to('pending') + end + end + + context 'when current status is skipped' do + let(:current_status) { 'skipped' } + + it 'skips the build' do + expect { subject }.to change { build.status }.to('skipped') + end + end + end end |