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

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/qa
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-03-30 03:08:32 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-30 03:08:32 +0300
commit70e8b38340b3d6857c709ea2158ef551633ad605 (patch)
treee672e215759faaed82f2f444facc037fd3e124b6 /qa
parent31664a1a5ac22e8c56a471d3afab26e661efcc0e (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/page/project/settings/deploy_keys.rb1
-rw-r--r--qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb3
-rw-r--r--qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb2
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_parent_child_pipelines_spec.rb287
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb150
5 files changed, 172 insertions, 271 deletions
diff --git a/qa/qa/page/project/settings/deploy_keys.rb b/qa/qa/page/project/settings/deploy_keys.rb
index 297d29550e3..b94dbbea533 100644
--- a/qa/qa/page/project/settings/deploy_keys.rb
+++ b/qa/qa/page/project/settings/deploy_keys.rb
@@ -13,6 +13,7 @@ module QA
view 'app/views/shared/deploy_keys/_project_group_form.html.haml' do
element :deploy_key_title_field
element :deploy_key_field
+ element :deploy_key_expires_at_field
element :add_deploy_key_button
end
diff --git a/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb b/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb
index b7d0d72297a..0a9337864ee 100644
--- a/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb
+++ b/qa/qa/specs/features/api/1_manage/user_access_termination_spec.rb
@@ -2,7 +2,8 @@
module QA
RSpec.describe 'Manage' do
- describe 'User', :requires_admin, :reliable, product_group: :authentication_and_authorization do
+ # TODO: `:reliable` should be added back once https://gitlab.com/gitlab-org/gitlab/-/issues/403001 is resolved
+ describe 'User', :requires_admin, product_group: :authentication_and_authorization do
before(:all) do
admin_api_client = Runtime::API::Client.as_admin
diff --git a/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb
index a969b48f0fc..748b989deb8 100644
--- a/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb
+++ b/qa/qa/specs/features/browser_ui/3_create/merge_request/view_merge_request_diff_patch_spec.rb
@@ -15,7 +15,7 @@ module QA
merge_request.visit!
end
- it 'views the merge request email patches', :can_use_large_setup, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347742' do
+ it 'views the merge request patches', :can_use_large_setup, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347742' do
Page::MergeRequest::Show.perform(&:view_email_patches)
expect(page.text).to start_with('From')
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_parent_child_pipelines_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_parent_child_pipelines_spec.rb
index 072c957f4dc..b08a36b0d43 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_parent_child_pipelines_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_parent_child_pipelines_spec.rb
@@ -1,10 +1,7 @@
# frozen_string_literal: true
module QA
- RSpec.describe 'Verify', :runner, product_group: :pipeline_security, quarantine: {
- issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/396855',
- type: :flaky
- } do
+ RSpec.describe 'Verify', :runner, product_group: :pipeline_security do
describe "Unlocking job artifacts across parent-child pipelines" do
let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(number: 8)}" }
@@ -22,15 +19,6 @@ module QA
end
end
- let(:parent_test_job_name) { 'test-job-parent' }
- let(:child_test_job_name) { 'test-job-child' }
-
- let(:previous_successful_pipeline) do
- Resource::Pipeline.fabricate_via_api! do |pipeline|
- pipeline.project = project
- end
- end
-
before do
Flow::Login.sign_in
project.visit!
@@ -40,47 +28,40 @@ module QA
let(:strategy) { nil }
before do
- add_parent_child_ci_files
- Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
- previous_successful_pipeline
+ add_parent_child_ci_files(
+ parent_job_name: 'parent_1', parent_script: 'echo parent',
+ child_job_name: 'child_1', child_script: 'echo child'
+ )
Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
end
context 'when latest pipeline family is successful' do
before do
- update_parent_child_ci_files
+ update_parent_child_ci_files(
+ parent_job_name: 'parent_2', parent_script: 'echo parent',
+ child_job_name: 'child_2', child_script: 'echo child'
+ )
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
end
it 'unlocks job artifacts from previous successful pipeline family',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/395516' do
- project.visit!
-
- Flow::Pipeline.visit_latest_pipeline(status: 'passed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_2').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
- Flow::Pipeline.visit_latest_pipeline(status: 'passed')
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_2').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
- previous_successful_pipeline.visit!
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_unlocked_artifact
end
- previous_successful_pipeline.visit!
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_unlocked_artifact
end
@@ -89,43 +70,31 @@ module QA
context 'when latest parent pipeline failed' do
before do
- update_failed_parent_ci_file
+ update_parent_child_ci_files(
+ parent_job_name: 'parent_2', parent_script: 'exit 1',
+ child_job_name: 'child_2', child_script: 'echo child'
+ )
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'failed')
end
it 'does not unlock job artifacts from previous successful pipeline family',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/396243' do
- project.visit!
-
- Flow::Pipeline.visit_latest_pipeline(status: 'failed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_2').visit!
Page::Project::Job::Show.perform do |job|
- expect(job).to be_failed
- # FIXME: this should be unlocked,
- # to be fixed by https://gitlab.com/gitlab-org/gitlab/-/merge_requests/110575
expect(job).to have_locked_artifact
end
- Flow::Pipeline.visit_latest_pipeline(status: 'failed')
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_2').visit!
Page::Project::Job::Show.perform do |job|
- expect(job).to be_successful
expect(job).to have_locked_artifact
end
- previous_successful_pipeline.visit!
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
- previous_successful_pipeline.visit!
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
@@ -134,41 +103,31 @@ module QA
context 'when latest child pipeline failed' do
before do
- update_failed_child_ci_file
+ update_parent_child_ci_files(
+ parent_job_name: 'parent_2', parent_script: 'echo parent',
+ child_job_name: 'child_2', child_script: 'exit 1'
+ )
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
end
it 'unlocks job artifacts from previous successful pipeline family because the latest parent is successful',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/396244' do
- project.visit!
-
- Flow::Pipeline.visit_latest_pipeline(status: 'passed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_2').visit!
Page::Project::Job::Show.perform do |job|
- expect(job).to be_successful
expect(job).to have_locked_artifact
end
- Flow::Pipeline.visit_latest_pipeline(status: 'passed')
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_2').visit!
Page::Project::Job::Show.perform do |job|
- expect(job).to be_failed
expect(job).to have_locked_artifact
end
- previous_successful_pipeline.visit!
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_unlocked_artifact
end
- previous_successful_pipeline.visit!
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_unlocked_artifact
end
@@ -180,47 +139,40 @@ module QA
let(:strategy) { 'depend' }
before do
- add_parent_child_ci_files
- Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
- previous_successful_pipeline
+ add_parent_child_ci_files(
+ parent_job_name: 'parent_1', parent_script: 'echo parent',
+ child_job_name: 'child_1', child_script: 'echo child'
+ )
Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
end
context 'when latest pipeline family is successful' do
before do
- update_parent_child_ci_files
+ update_parent_child_ci_files(
+ parent_job_name: 'parent_2', parent_script: 'echo parent',
+ child_job_name: 'child_2', child_script: 'echo child'
+ )
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
end
it 'unlocks job artifacts from previous successful pipeline family',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/396245' do
- project.visit!
-
- Flow::Pipeline.visit_latest_pipeline(status: 'passed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_2').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
- Flow::Pipeline.visit_latest_pipeline(status: 'passed')
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_2').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
- previous_successful_pipeline.visit!
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_unlocked_artifact
end
- previous_successful_pipeline.visit!
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_unlocked_artifact
end
@@ -229,43 +181,31 @@ module QA
context 'when latest parent pipeline failed' do
before do
- update_failed_parent_ci_file
+ update_parent_child_ci_files(
+ parent_job_name: 'parent_2', parent_script: 'exit 1',
+ child_job_name: 'child_2', child_script: 'echo child'
+ )
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'failed')
end
it 'does not unlock job artifacts from previous successful pipeline family',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/396246' do
- project.visit!
-
- Flow::Pipeline.visit_latest_pipeline(status: 'failed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_2').visit!
Page::Project::Job::Show.perform do |job|
- # FIXME: this should be unlocked,
- # to be fixed by https://gitlab.com/gitlab-org/gitlab/-/merge_requests/110575
- expect(job).to be_failed
expect(job).to have_locked_artifact
end
- Flow::Pipeline.visit_latest_pipeline(status: 'failed')
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_2').visit!
Page::Project::Job::Show.perform do |job|
- expect(job).to be_successful
expect(job).to have_locked_artifact
end
- previous_successful_pipeline.visit!
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
- previous_successful_pipeline.visit!
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
@@ -274,45 +214,31 @@ module QA
context 'when latest child pipeline failed' do
before do
- update_failed_child_ci_file
+ update_parent_child_ci_files(
+ parent_job_name: 'parent_2', parent_script: 'echo parent',
+ child_job_name: 'child_2', child_script: 'exit 1'
+ )
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'failed')
end
it 'does not unlock job artifacts from previous successful pipeline family',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/396248' do
- project.visit!
-
- Flow::Pipeline.visit_latest_pipeline(status: 'failed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_2').visit!
Page::Project::Job::Show.perform do |job|
- expect(job).to be_successful
- # FIXME: this should be unlocked,
- # to be fixed by https://gitlab.com/gitlab-org/gitlab/-/merge_requests/110575
expect(job).to have_locked_artifact
end
- Flow::Pipeline.visit_latest_pipeline(status: 'failed')
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_2').visit!
Page::Project::Job::Show.perform do |job|
- expect(job).to be_failed
- # FIXME: this should be unlocked,
- # to be fixed by https://gitlab.com/gitlab-org/gitlab/-/merge_requests/110575
expect(job).to have_locked_artifact
end
- previous_successful_pipeline.visit!
- Flow::Pipeline.visit_pipeline_job_page(job_name: parent_test_job_name)
+ find_job('parent_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
- previous_successful_pipeline.visit!
- Page::Project::Pipeline::Show.perform do |pipeline|
- pipeline.expand_child_pipeline
- pipeline.click_job(child_test_job_name)
- end
+ find_job('child_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
@@ -322,78 +248,33 @@ module QA
private
- def update_parent_child_ci_files
+ def update_parent_child_ci_files(parent_job_name:, parent_script:, child_job_name:, child_script:)
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Update parent and child pipelines CI files.'
commit.update_files(
[
- parent_ci_file,
- child_ci_file
- ]
- )
- end
- end
-
- def update_failed_parent_ci_file
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Fail parent pipeline.'
- commit.update_files(
- [
- parent_failed_ci_file
+ parent_ci_file(parent_job_name, parent_script),
+ child_ci_file(child_job_name, child_script)
]
)
end
end
- def update_failed_child_ci_file
- Resource::Repository::Commit.fabricate_via_api! do |commit|
- commit.project = project
- commit.commit_message = 'Fail child pipeline.'
- commit.update_files(
- [
- child_failed_ci_file
- ]
- )
- end
- end
-
- def add_parent_child_ci_files
+ def add_parent_child_ci_files(parent_job_name:, parent_script:, child_job_name:, child_script:)
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add parent and child pipelines CI files.'
commit.add_files(
[
- parent_ci_file,
- child_ci_file
+ parent_ci_file(parent_job_name, parent_script),
+ child_ci_file(child_job_name, child_script)
]
)
end
end
- def parent_ci_file
- {
- file_path: '.gitlab-ci.yml',
- content: <<~YAML
- trigger-child:
- stage: test
- trigger:
- include: ".child-ci.yml"
- strategy: #{strategy}
-
- #{parent_test_job_name}:
- stage: test
- tags: ["#{executor}"]
- script: echo "parent test"
- artifacts:
- paths: ['.gitlab-ci.yml']
- when: always
- YAML
- }
- end
-
- def parent_failed_ci_file
+ def parent_ci_file(job_name, script)
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
@@ -403,10 +284,10 @@ module QA
include: ".child-ci.yml"
strategy: #{strategy}
- #{parent_test_job_name}:
+ #{job_name}:
stage: test
tags: ["#{executor}"]
- script: echo "parent test" && exit 1
+ script: #{script}
artifacts:
paths: ['.gitlab-ci.yml']
when: always
@@ -414,14 +295,14 @@ module QA
}
end
- def child_ci_file
+ def child_ci_file(job_name, script)
{
file_path: '.child-ci.yml',
content: <<~YAML
- #{child_test_job_name}:
+ #{job_name}:
stage: test
tags: ["#{executor}"]
- script: echo "child test"
+ script: #{script}
artifacts:
paths: ['.child-ci.yml']
when: always
@@ -429,19 +310,11 @@ module QA
}
end
- def child_failed_ci_file
- {
- file_path: '.child-ci.yml',
- content: <<~YAML
- #{child_test_job_name}:
- stage: test
- tags: ["#{executor}"]
- script: echo "child test" && exit 1
- artifacts:
- paths: ['.child-ci.yml']
- when: always
- YAML
- }
+ def find_job(job_name)
+ Resource::Job.fabricate_via_api! do |job|
+ job.project = project
+ job.id = project.job_by_name(job_name)[:id]
+ end
end
end
end
diff --git a/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb b/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb
index a954bd16386..24f87f39823 100644
--- a/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb
@@ -19,41 +19,34 @@ module QA
end
end
- let(:test_job_name) { 'test-job' }
-
before do
Flow::Login.sign_in
+ project.visit!
end
context 'when latest pipeline is successful' do
+ before do
+ add_ci_file(job_name: 'job_1', script: 'echo test')
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
+ end
+
it 'unlocks job artifacts from previous successful pipeline',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/394807' do
- add_ci_file
- project.visit!
-
- previous_successful_pipeline = Resource::Pipeline.fabricate! do |pipeline|
- pipeline.project = project
- end
-
- Flow::Pipeline.visit_latest_pipeline(status: 'passed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: test_job_name)
-
+ find_job('job_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
- update_ci_script('echo bye')
- project.visit!
+ update_ci_file(job_name: 'job_2', script: 'echo test')
- Flow::Pipeline.visit_latest_pipeline(status: 'passed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: test_job_name)
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
+ find_job('job_2').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
- Flow::Pipeline.visit_pipeline_job_page(pipeline: previous_successful_pipeline, job_name: test_job_name)
-
+ find_job('job_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_unlocked_artifact
end
@@ -61,57 +54,61 @@ module QA
end
context 'when latest pipeline failed' do
- it 'unlocks job artifacts from failed pipelines, keeps job artifacts from latest successful pipeline',
- testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/394808',
- quarantine: {
- issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/266958',
- type: :bug
- } do
- add_ci_file
- project.visit!
-
- successful_pipeline = Resource::Pipeline.fabricate! do |pipeline|
- pipeline.project = project
- end
+ before do
+ add_ci_file(job_name: 'successful_job_1', script: 'echo test')
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
+ end
+
+ it 'keeps job artifacts from latest failed pipelines and from latest successful pipeline',
+ testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/394808' do
+ update_ci_file(job_name: 'failed_job_1', script: 'exit 1')
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'failed')
- Flow::Pipeline.visit_latest_pipeline(status: 'passed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: test_job_name)
+ update_ci_file(job_name: 'failed_job_2', script: 'exit 2')
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'failed')
+ find_job('failed_job_2').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
- update_ci_script('echo test && exit 1')
-
- failed_pipeline_1 = Resource::Pipeline.fabricate! do |pipeline|
- pipeline.project = project
+ find_job('failed_job_1').visit!
+ Page::Project::Job::Show.perform do |job|
+ expect(job).to have_unlocked_artifact
end
- Flow::Pipeline.visit_latest_pipeline(status: 'failed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: test_job_name)
-
+ find_job('successful_job_1').visit!
Page::Project::Job::Show.perform do |job|
- expect(job).to have_unlocked_artifact
+ expect(job).to have_locked_artifact
end
+ end
+ end
+
+ context 'when latest pipeline is blocked' do
+ before do
+ add_ci_file(job_name: 'successful_job_1', script: 'echo test')
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'passed')
+ end
- update_ci_script('echo bye && exit 1')
- project.visit!
+ it 'keeps job artifacts from the latest blocked pipeline and from latest successful pipeline',
+ testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/395511' do
+ update_ci_with_manual_job(job_name: 'successful_job_with_manual_1', script: 'echo test')
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'blocked')
- Flow::Pipeline.visit_latest_pipeline(status: 'failed')
- Flow::Pipeline.visit_pipeline_job_page(job_name: test_job_name)
+ update_ci_with_manual_job(job_name: 'successful_job_with_manual_2', script: 'echo test')
+ Flow::Pipeline.wait_for_latest_pipeline(status: 'blocked')
+ find_job('successful_job_with_manual_2').visit!
Page::Project::Job::Show.perform do |job|
- expect(job).to have_unlocked_artifact
+ expect(job).to have_locked_artifact
end
- Flow::Pipeline.visit_pipeline_job_page(pipeline: failed_pipeline_1, job_name: test_job_name)
-
+ find_job('successful_job_with_manual_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_unlocked_artifact
end
- Flow::Pipeline.visit_pipeline_job_page(pipeline: successful_pipeline, job_name: test_job_name)
-
+ find_job('successful_job_1').visit!
Page::Project::Job::Show.perform do |job|
expect(job).to have_locked_artifact
end
@@ -120,42 +117,41 @@ module QA
private
- def add_ci_file
- script = 'echo test'
- ci_file = ci_file_with_job_artifact(script)
+ def add_ci_file(job_name:, script:)
+ ci_file = ci_file_with_job_artifact(job_name, script)
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
- commit.commit_message = "Set script #{script}"
+ commit.commit_message = "Set job #{job_name} script #{script}"
commit.add_files([ci_file])
end
end
- def update_ci_script(script)
- ci_file = ci_file_with_job_artifact(script)
+ def update_ci_file(job_name:, script:)
+ ci_file = ci_file_with_job_artifact(job_name, script)
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
- commit.commit_message = "Set script #{script}"
+ commit.commit_message = "Set job #{job_name} script #{script}"
commit.update_files([ci_file])
end
end
- def add_failing_ci_file
- ci_file = ci_file_with_job_artifact('echo test && exit 1')
+ def update_ci_with_manual_job(job_name:, script:)
+ ci_file = ci_file_with_manual_job(job_name, script)
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
- commit.commit_message = 'Add failing CI file.'
- commit.add_files([ci_file])
+ commit.commit_message = "Set job #{job_name} script #{script}"
+ commit.update_files([ci_file])
end
end
- def ci_file_with_job_artifact(script)
+ def ci_file_with_job_artifact(job_name, script)
{
file_path: '.gitlab-ci.yml',
content: <<~YAML
- #{test_job_name}:
+ #{job_name}:
stage: test
tags: ["#{executor}"]
script: #{script}
@@ -165,6 +161,36 @@ module QA
YAML
}
end
+
+ def ci_file_with_manual_job(job_name, script)
+ {
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ #{job_name}:
+ stage: test
+ tags: ["#{executor}"]
+ script: #{script}
+ artifacts:
+ paths: ['.gitlab-ci.yml']
+
+ manual-job:
+ stage: test
+ tags: ["#{executor}"]
+ rules:
+ - when: manual
+ script: "echo 'this job is manual'"
+ artifacts:
+ paths: ['.gitlab-ci.yml']
+ YAML
+ }
+ end
+
+ def find_job(job_name)
+ Resource::Job.fabricate_via_api! do |job|
+ job.project = project
+ job.id = project.job_by_name(job_name)[:id]
+ end
+ end
end
end
end