Welcome to mirror list, hosted at ThFree Co, Russian Federation.

parent_child_pipelines_independent_relationship_spec.rb « pipeline « 4_verify « browser_ui « features « specs « qa « qa - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7735181f748236fc5789cc412f4daa787280e4f0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# frozen_string_literal: true

module QA
  RSpec.describe 'Verify', :runner, :reliable, product_group: :pipeline_execution do
    describe 'Parent-child pipelines independent relationship' do
      let!(:project) { create(:project, name: 'pipeline-independent-relationship') }
      let!(:runner) { create(:project_runner, project: project, name: project.name, tags: [project.name]) }

      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/358059'
      ) 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 passes even if child fails',
        testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/358060'
      ) 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_passed? }.to eventually_be_truthy
        end
      end

      private

      def success_child_ci_file
        {
          action: 'create',
          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
        {
          action: 'create',
          file_path: '.child-ci.yml',
          content: <<~YAML
            child_job:
              stage: test
              tags: ["#{project.name}"]
              script: exit 1

          YAML
        }
      end

      def parent_ci_file
        {
          action: 'create',
          file_path: '.gitlab-ci.yml',
          content: <<~YAML
            stages:
              - test
              - deploy

            job1:
              stage: test
              trigger:
                include: ".child-ci.yml"

            job2:
              stage: deploy
              tags: ["#{project.name}"]
              script: echo "parent deploy done"

          YAML
        }
      end

      def add_ci_files(child_ci_file)
        create(:commit,
          project: project,
          commit_message: 'Add parent and child pipelines CI files.',
          actions: [child_ci_file, parent_ci_file]).project.visit!
      end
    end
  end
end