diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2022-04-20 10:00:54 +0000 |
commit | 3cccd102ba543e02725d247893729e5c73b38295 (patch) | |
tree | f36a04ec38517f5deaaacb5acc7d949688d1e187 /qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_dependent_relationship_spec.rb | |
parent | 205943281328046ef7b4528031b90fbda70c75ac (diff) | |
download | gitlab-ce-3cccd102ba543e02725d247893729e5c73b38295.tar.gz |
Add latest changes from gitlab-org/gitlab@14-10-stable-eev14.10.0-rc42
Diffstat (limited to 'qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_dependent_relationship_spec.rb')
-rw-r--r-- | qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_dependent_relationship_spec.rb | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_dependent_relationship_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_dependent_relationship_spec.rb new file mode 100644 index 00000000000..5b7a569fa8a --- /dev/null +++ b/qa/qa/specs/features/browser_ui/4_verify/pipeline/parent_child_pipelines_dependent_relationship_spec.rb @@ -0,0 +1,119 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Verify', :runner, :reliable do + describe 'Parent-child pipelines dependent relationship' do + let!(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'pipelines-dependent-relationship' + end + end + + let!(:runner) do + Resource::Runner.fabricate_via_api! do |runner| + runner.project = project + runner.name = project.name + runner.tags = ["#{project.name}"] + end + end + + before do + Flow::Login.sign_in + end + + after do + runner.remove_via_api! + end + + it( + 'parent pipelines passes if child passes', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/358062' + ) do + add_ci_files(success_child_ci_file) + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |parent_pipeline| + expect(parent_pipeline).to have_child_pipeline + expect { parent_pipeline.has_passed? }.to eventually_be_truthy + end + end + + it( + 'parent pipeline fails if child fails', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/358063' + ) do + add_ci_files(fail_child_ci_file) + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |parent_pipeline| + expect(parent_pipeline).to have_child_pipeline + expect { parent_pipeline.has_failed? }.to eventually_be_truthy + end + end + + private + + def success_child_ci_file + { + file_path: '.child-ci.yml', + content: <<~YAML + child_job: + stage: test + tags: ["#{project.name}"] + script: echo "Child job done!" + + YAML + } + end + + def fail_child_ci_file + { + file_path: '.child-ci.yml', + content: <<~YAML + child_job: + stage: test + tags: ["#{project.name}"] + script: exit 1 + + YAML + } + end + + def parent_ci_file + { + file_path: '.gitlab-ci.yml', + content: <<~YAML + stages: + - test + - deploy + + job1: + stage: test + trigger: + include: ".child-ci.yml" + strategy: depend + + job2: + stage: deploy + tags: ["#{project.name}"] + script: echo "parent deploy done" + + YAML + } + end + + def add_ci_files(child_ci_file) + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.commit_message = 'Add parent and child pipelines CI files.' + commit.add_files( + [ + child_ci_file, + parent_ci_file + ] + ) + end.project.visit! + end + end + end +end |