From 872213880e8ff86caaec48095a8dabecba80d216 Mon Sep 17 00:00:00 2001 From: Tiffany Rea <trea@gitlab.com> Date: Thu, 8 Apr 2021 06:57:18 +0000 Subject: [PATCH] E2E test pipeline for group owned project subscription --- ...scription_with_group_owned_project_spec.rb | 105 ++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100644 qa/qa/specs/features/ee/browser_ui/4_verify/pipeline_subscription_with_group_owned_project_spec.rb diff --git a/qa/qa/specs/features/ee/browser_ui/4_verify/pipeline_subscription_with_group_owned_project_spec.rb b/qa/qa/specs/features/ee/browser_ui/4_verify/pipeline_subscription_with_group_owned_project_spec.rb new file mode 100644 index 0000000000000..54c30ed3d8749 --- /dev/null +++ b/qa/qa/specs/features/ee/browser_ui/4_verify/pipeline_subscription_with_group_owned_project_spec.rb @@ -0,0 +1,105 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Verify' do + describe 'Pipeline subscription with a group owned project', :runner do + let(:executor) { "qa-runner-#{SecureRandom.hex(3)}" } + let(:tag_name) { "awesome-tag-#{SecureRandom.hex(3)}" } + + let(:upstream_project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'upstream-project-for-subscription' + project.description = 'Project with CI subscription' + end + end + + let(:downstream_project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'project-with-pipeline-subscription' + project.description = 'Project with CI subscription' + end + end + + let!(:runner) do + Resource::Runner.fabricate! do |runner| + runner.project = upstream_project + runner.token = upstream_project.group.sandbox.runners_token + runner.name = executor + runner.tags = [executor] + end + end + + before do + [downstream_project, upstream_project].each do |project| + add_ci_file(project) + end + + Flow::Login.sign_in + downstream_project.visit! + + EE::Resource::PipelineSubscriptions.fabricate_via_browser_ui! do |subscription| + subscription.project_path = upstream_project.path_with_namespace + end + end + + after do + [runner, upstream_project, downstream_project].each do |item| + item.remove_via_api! + end + end + + context 'when upstream project new tag pipeline finishes' do + it 'triggers pipeline in downstream project', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1729' do + # Downstream project should have one pipeline at this time + unless downstream_project.pipelines.size == 1 + raise "[ERROR] Downstream project should have 1 pipeline - pipelines count #{downstream_project.pipelines.size}" + end + + Resource::Tag.fabricate_via_api! do |tag| + tag.project = upstream_project + tag.ref = upstream_project.default_branch + tag.name = tag_name + end + + downstream_project.visit! + + # Wait for upstream new tag pipeline to succeed + # And downstream project to have 2 pipelines + Support::Waiter.wait_until do + new_pipeline = upstream_project.pipelines.find { |pipeline| pipeline[:ref] == tag_name } + new_pipeline[:status] == 'success' && downstream_project.pipelines.size == 2 + end + + # expect new downstream pipeline to also succeed + Page::Project::Menu.perform(&:click_ci_cd_pipelines) + Page::Project::Pipeline::Index.perform do |index| + expect(index.wait_for_latest_pipeline_succeeded).to be_truthy, 'Downstream pipeline did not succeed as expected.' + end + end + end + + private + + def add_ci_file(project) + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = project + commit.commit_message = 'Add .gitlab-ci.yml' + commit.add_files( + [ + { + file_path: '.gitlab-ci.yml', + content: <<~YAML + job: + tags: + - #{executor} + script: + - echo DONE! + YAML + } + ] + ) + end + end + end + end +end -- GitLab