diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-15 18:09:07 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2021-03-15 18:09:07 +0300 |
commit | f5c3f32975addd56fe8659f1c346d0e56f0b23d9 (patch) | |
tree | 9d6594793e656c52341a98d22d882d96d240433f /spec/services/ci/pipeline_processing | |
parent | c8b7a349bc50cff1e8ef18204042978476527b0b (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/services/ci/pipeline_processing')
-rw-r--r-- | spec/services/ci/pipeline_processing/shared_processing_service.rb | 78 | ||||
-rw-r--r-- | spec/services/ci/pipeline_processing/shared_processing_service_tests_with_yaml.rb | 8 |
2 files changed, 70 insertions, 16 deletions
diff --git a/spec/services/ci/pipeline_processing/shared_processing_service.rb b/spec/services/ci/pipeline_processing/shared_processing_service.rb index 215f33a42a3..13c924a3089 100644 --- a/spec/services/ci/pipeline_processing/shared_processing_service.rb +++ b/spec/services/ci/pipeline_processing/shared_processing_service.rb @@ -1,21 +1,13 @@ # frozen_string_literal: true RSpec.shared_examples 'Pipeline Processing Service' do - let(:user) { create(:user) } - let(:project) { create(:project) } + let(:project) { create(:project, :repository) } + let(:user) { project.owner } let(:pipeline) do create(:ci_empty_pipeline, ref: 'master', project: project) end - before do - stub_ci_pipeline_to_return_yaml_file - - stub_not_protect_default_branch - - project.add_developer(user) - end - context 'when simple pipeline is defined' do before do create_build('linux', stage_idx: 0) @@ -866,10 +858,74 @@ RSpec.shared_examples 'Pipeline Processing Service' do end end + context 'when a bridge job has parallel:matrix config', :sidekiq_inline do + let(:parent_config) do + <<-EOY + test: + stage: test + script: echo test + + deploy: + stage: deploy + trigger: + include: .child.yml + parallel: + matrix: + - PROVIDER: ovh + STACK: [monitoring, app] + EOY + end + + let(:child_config) do + <<-EOY + test: + stage: test + script: echo test + EOY + end + + let(:pipeline) do + Ci::CreatePipelineService.new(project, user, { ref: 'master' }).execute(:push) + end + + before do + allow_next_instance_of(Repository) do |repository| + allow(repository) + .to receive(:blob_data_at) + .with(an_instance_of(String), '.gitlab-ci.yml') + .and_return(parent_config) + + allow(repository) + .to receive(:blob_data_at) + .with(an_instance_of(String), '.child.yml') + .and_return(child_config) + end + end + + it 'creates pipeline with bridges, then passes the matrix variables to downstream jobs' do + expect(all_builds_names).to contain_exactly('test', 'deploy: [ovh, monitoring]', 'deploy: [ovh, app]') + expect(all_builds_statuses).to contain_exactly('pending', 'created', 'created') + + succeed_pending + + # bridge jobs directly transition to success + expect(all_builds_statuses).to contain_exactly('success', 'success', 'success') + + bridge1 = all_builds.find_by(name: 'deploy: [ovh, monitoring]') + bridge2 = all_builds.find_by(name: 'deploy: [ovh, app]') + + downstream_job1 = bridge1.downstream_pipeline.processables.first + downstream_job2 = bridge2.downstream_pipeline.processables.first + + expect(downstream_job1.scoped_variables.to_hash).to include('PROVIDER' => 'ovh', 'STACK' => 'monitoring') + expect(downstream_job2.scoped_variables.to_hash).to include('PROVIDER' => 'ovh', 'STACK' => 'app') + end + end + private def all_builds - pipeline.builds.order(:stage_idx, :id) + pipeline.processables.order(:stage_idx, :id) end def builds diff --git a/spec/services/ci/pipeline_processing/shared_processing_service_tests_with_yaml.rb b/spec/services/ci/pipeline_processing/shared_processing_service_tests_with_yaml.rb index 2936d6fae4d..a9f9db8c689 100644 --- a/spec/services/ci/pipeline_processing/shared_processing_service_tests_with_yaml.rb +++ b/spec/services/ci/pipeline_processing/shared_processing_service_tests_with_yaml.rb @@ -1,21 +1,19 @@ # frozen_string_literal: true RSpec.shared_context 'Pipeline Processing Service Tests With Yaml' do + let_it_be(:project) { create(:project, :repository) } + let_it_be(:user) { project.owner } + where(:test_file_path) do Dir.glob(Rails.root.join('spec/services/ci/pipeline_processing/test_cases/*.yml')) end with_them do let(:test_file) { YAML.load_file(test_file_path) } - - let(:user) { create(:user) } - let(:project) { create(:project, :repository) } let(:pipeline) { Ci::CreatePipelineService.new(project, user, ref: 'master').execute(:pipeline) } before do stub_ci_pipeline_yaml_file(YAML.dump(test_file['config'])) - stub_not_protect_default_branch - project.add_developer(user) end it 'follows transitions' do |