summaryrefslogtreecommitdiff
path: root/spec/services/ci
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 12:09:03 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2020-02-14 12:09:03 +0000
commit5366964a10484c2783a646b35a6da9eece01b242 (patch)
tree4a5a7a289d44e63d96a50a6a64db6e16b871f19c /spec/services/ci
parent733befe96ad19f5a02e442c4a9cc8059d3aabbda (diff)
downloadgitlab-ce-5366964a10484c2783a646b35a6da9eece01b242.tar.gz
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/ci')
-rw-r--r--spec/services/ci/create_pipeline_service/needs_spec.rb62
-rw-r--r--spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb6
-rw-r--r--spec/services/ci/pipeline_processing/legacy_processing_service_spec.rb6
-rw-r--r--spec/services/ci/pipeline_processing/shared_processing_service.rb53
-rw-r--r--spec/services/ci/process_pipeline_service_spec.rb19
-rw-r--r--spec/services/ci/retry_pipeline_service_spec.rb17
6 files changed, 154 insertions, 9 deletions
diff --git a/spec/services/ci/create_pipeline_service/needs_spec.rb b/spec/services/ci/create_pipeline_service/needs_spec.rb
index 757c076f9e6..17b9cf80cc1 100644
--- a/spec/services/ci/create_pipeline_service/needs_spec.rb
+++ b/spec/services/ci/create_pipeline_service/needs_spec.rb
@@ -175,5 +175,67 @@ describe Ci::CreatePipelineService do
.to eq('jobs:test_a:needs:need artifacts should be a boolean value')
end
end
+
+ context 'when needs is empty array' do
+ let(:config) do
+ <<~YAML
+ build_a:
+ stage: build
+ script: ls
+ test_a:
+ stage: test
+ script: ls
+ test_b:
+ stage: test
+ script: ls
+ needs: []
+ deploy_a:
+ stage: deploy
+ script: ls
+ needs: [test_a]
+ deploy_b:
+ stage: deploy
+ script: ls
+ when: manual
+ needs: []
+ YAML
+ end
+
+ it 'creates a pipeline with build_a and test_b pending; deploy_b manual' do
+ processables = pipeline.processables
+
+ build_a = processables.find { |processable| processable.name == 'build_a' }
+ test_a = processables.find { |processable| processable.name == 'test_a' }
+ test_b = processables.find { |processable| processable.name == 'test_b' }
+ deploy_a = processables.find { |processable| processable.name == 'deploy_a' }
+ deploy_b = processables.find { |processable| processable.name == 'deploy_b' }
+
+ expect(pipeline).to be_persisted
+ expect(build_a.status).to eq('pending')
+ expect(test_a.status).to eq('created')
+ expect(test_b.status).to eq('pending')
+ expect(deploy_a.status).to eq('created')
+ expect(deploy_b.status).to eq('manual')
+ end
+ end
+
+ context 'when needs is empty hash' do
+ let(:config) do
+ <<~YAML
+ regular_job:
+ stage: build
+ script: echo 'hello'
+ invalid_dag_job:
+ stage: test
+ script: ls
+ needs: {}
+ YAML
+ end
+
+ it 'raises error' do
+ expect(pipeline.yaml_errors)
+ .to eq('jobs:invalid_dag_job:needs config can not be an empty hash')
+ end
+ end
end
end
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 38686b41a22..cbeb45b92ff 100644
--- a/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb
+++ b/spec/services/ci/pipeline_processing/atomic_processing_service_spec.rb
@@ -9,4 +9,10 @@ describe Ci::PipelineProcessing::AtomicProcessingService do
end
it_behaves_like 'Pipeline Processing Service'
+
+ private
+
+ def process_pipeline(initial_process: false)
+ described_class.new(pipeline).execute
+ end
end
diff --git a/spec/services/ci/pipeline_processing/legacy_processing_service_spec.rb b/spec/services/ci/pipeline_processing/legacy_processing_service_spec.rb
index 2da1eb19818..09b462b7600 100644
--- a/spec/services/ci/pipeline_processing/legacy_processing_service_spec.rb
+++ b/spec/services/ci/pipeline_processing/legacy_processing_service_spec.rb
@@ -9,4 +9,10 @@ describe Ci::PipelineProcessing::LegacyProcessingService do
end
it_behaves_like 'Pipeline Processing Service'
+
+ private
+
+ def process_pipeline(initial_process: false)
+ described_class.new(pipeline).execute(initial_process: initial_process)
+ end
end
diff --git a/spec/services/ci/pipeline_processing/shared_processing_service.rb b/spec/services/ci/pipeline_processing/shared_processing_service.rb
index cae5ae3f09d..2349dedf370 100644
--- a/spec/services/ci/pipeline_processing/shared_processing_service.rb
+++ b/spec/services/ci/pipeline_processing/shared_processing_service.rb
@@ -710,10 +710,10 @@ shared_examples 'Pipeline Processing Service' do
context 'when pipeline with needs is created', :sidekiq_inline do
let!(:linux_build) { create_build('linux:build', stage: 'build', stage_idx: 0) }
let!(:mac_build) { create_build('mac:build', stage: 'build', stage_idx: 0) }
- let!(:linux_rspec) { create_build('linux:rspec', stage: 'test', stage_idx: 1) }
- let!(:linux_rubocop) { create_build('linux:rubocop', stage: 'test', stage_idx: 1) }
- let!(:mac_rspec) { create_build('mac:rspec', stage: 'test', stage_idx: 1) }
- let!(:mac_rubocop) { create_build('mac:rubocop', stage: 'test', stage_idx: 1) }
+ let!(:linux_rspec) { create_build('linux:rspec', stage: 'test', stage_idx: 1, scheduling_type: :dag) }
+ let!(:linux_rubocop) { create_build('linux:rubocop', stage: 'test', stage_idx: 1, scheduling_type: :dag) }
+ let!(:mac_rspec) { create_build('mac:rspec', stage: 'test', stage_idx: 1, scheduling_type: :dag) }
+ let!(:mac_rubocop) { create_build('mac:rubocop', stage: 'test', stage_idx: 1, scheduling_type: :dag) }
let!(:deploy) { create_build('deploy', stage: 'deploy', stage_idx: 2) }
let!(:linux_rspec_on_build) { create(:ci_build_need, build: linux_rspec, name: 'linux:build') }
@@ -795,7 +795,7 @@ shared_examples 'Pipeline Processing Service' do
end
context 'when one of the jobs is run on a failure' do
- let!(:linux_notify) { create_build('linux:notify', stage: 'deploy', stage_idx: 2, when: 'on_failure') }
+ let!(:linux_notify) { create_build('linux:notify', stage: 'deploy', stage_idx: 2, when: 'on_failure', scheduling_type: :dag) }
let!(:linux_notify_on_build) { create(:ci_build_need, build: linux_notify, name: 'linux:build') }
@@ -837,10 +837,47 @@ shared_examples 'Pipeline Processing Service' do
end
end
end
- end
- def process_pipeline
- described_class.new(pipeline).execute
+ context 'when there is a job scheduled with dag but no need (needs: [])' do
+ let!(:deploy_pages) { create_build('deploy_pages', stage: 'deploy', stage_idx: 2, scheduling_type: :dag) }
+
+ it 'runs deploy_pages without waiting prior stages' do
+ # Ci::PipelineProcessing::LegacyProcessingService requires :initial_process parameter
+ expect(process_pipeline(initial_process: true)).to be_truthy
+
+ expect(stages).to eq(%w(pending created pending))
+ expect(builds.pending).to contain_exactly(linux_build, mac_build, deploy_pages)
+
+ linux_build.reset.success!
+ deploy_pages.reset.success!
+
+ expect(stages).to eq(%w(running pending running))
+ expect(builds.success).to contain_exactly(linux_build, deploy_pages)
+ expect(builds.pending).to contain_exactly(mac_build, linux_rspec, linux_rubocop)
+
+ linux_rspec.reset.success!
+ linux_rubocop.reset.success!
+ mac_build.reset.success!
+ mac_rspec.reset.success!
+ mac_rubocop.reset.success!
+
+ expect(stages).to eq(%w(success success running))
+ expect(builds.pending).to contain_exactly(deploy)
+ end
+
+ context 'when ci_dag_support is disabled' do
+ before do
+ stub_feature_flags(ci_dag_support: false)
+ end
+
+ it 'does run deploy_pages at the start' do
+ expect(process_pipeline).to be_truthy
+
+ expect(stages).to eq(%w(pending created created))
+ expect(builds.pending).to contain_exactly(linux_build, mac_build)
+ end
+ end
+ end
end
def all_builds
diff --git a/spec/services/ci/process_pipeline_service_spec.rb b/spec/services/ci/process_pipeline_service_spec.rb
index 40ae1c4029b..6f5a070d73d 100644
--- a/spec/services/ci/process_pipeline_service_spec.rb
+++ b/spec/services/ci/process_pipeline_service_spec.rb
@@ -33,6 +33,25 @@ describe Ci::ProcessPipelineService do
end
end
+ context 'with a pipeline which has processables with nil scheduling_type', :clean_gitlab_redis_shared_state do
+ let!(:build1) { create_build('build1') }
+ let!(:build2) { create_build('build2') }
+ let!(:build3) { create_build('build3', scheduling_type: :dag) }
+ let!(:build3_on_build2) { create(:ci_build_need, build: build3, name: 'build2') }
+
+ before do
+ pipeline.processables.update_all(scheduling_type: nil)
+ end
+
+ it 'populates scheduling_type before processing' do
+ process_pipeline
+
+ expect(build1.scheduling_type).to eq('stage')
+ expect(build2.scheduling_type).to eq('stage')
+ expect(build3.scheduling_type).to eq('dag')
+ end
+ end
+
def process_pipeline
described_class.new(pipeline).execute
end
diff --git a/spec/services/ci/retry_pipeline_service_spec.rb b/spec/services/ci/retry_pipeline_service_spec.rb
index e7a241ed335..7db871adc9a 100644
--- a/spec/services/ci/retry_pipeline_service_spec.rb
+++ b/spec/services/ci/retry_pipeline_service_spec.rb
@@ -95,7 +95,7 @@ describe Ci::RetryPipelineService, '#execute' do
before do
create_build('build', :success, 0)
create_build('build2', :success, 0)
- test_build = create_build('test', :failed, 1)
+ test_build = create_build('test', :failed, 1, scheduling_type: :dag)
create(:ci_build_need, build: test_build, name: 'build')
create(:ci_build_need, build: test_build, name: 'build2')
end
@@ -108,6 +108,21 @@ describe Ci::RetryPipelineService, '#execute' do
expect(build('test')).to be_pending
expect(build('test').needs.map(&:name)).to match_array(%w(build build2))
end
+
+ context 'when there is a failed DAG test without needs' do
+ before do
+ create_build('deploy', :failed, 2, scheduling_type: :dag)
+ end
+
+ it 'retries the test' do
+ service.execute(pipeline)
+
+ expect(build('build')).to be_success
+ expect(build('build2')).to be_success
+ expect(build('test')).to be_pending
+ expect(build('deploy')).to be_pending
+ end
+ end
end
context 'when the last stage was skipepd' do