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-09 09:12:08 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-09 09:12:08 +0300
commit06af519348e7254062a7d03ef3e421356ff8c64a (patch)
tree30873ad43170e6c8b3eadc778a63c08a1ac3231c /qa
parent44a883b53a586ff5966adce0aacfaa9d31e80441 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'qa')
-rw-r--r--qa/qa/flow/pipeline.rb8
-rw-r--r--qa/qa/page/project/job/show.rb8
-rw-r--r--qa/qa/page/project/pipeline/show.rb11
-rw-r--r--qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb170
4 files changed, 197 insertions, 0 deletions
diff --git a/qa/qa/flow/pipeline.rb b/qa/qa/flow/pipeline.rb
index fb6a5425a6e..0765a8758ec 100644
--- a/qa/qa/flow/pipeline.rb
+++ b/qa/qa/flow/pipeline.rb
@@ -24,6 +24,14 @@ module QA
index.wait_for_latest_pipeline(status: status, wait: wait)
end
end
+
+ def visit_pipeline_job_page(job_name:, pipeline: nil)
+ pipeline.visit! unless pipeline.nil?
+
+ Page::Project::Pipeline::Show.perform do |pipeline|
+ pipeline.click_job(job_name)
+ end
+ end
end
end
end
diff --git a/qa/qa/page/project/job/show.rb b/qa/qa/page/project/job/show.rb
index 24fd34b4d22..444c67cfe4f 100644
--- a/qa/qa/page/project/job/show.rb
+++ b/qa/qa/page/project/job/show.rb
@@ -68,6 +68,14 @@ module QA
end
end
+ def has_locked_artifact?
+ has_text?('will not be deleted')
+ end
+
+ def has_unlocked_artifact?
+ has_text?('will be removed')
+ end
+
private
def loaded?(wait: 60)
diff --git a/qa/qa/page/project/pipeline/show.rb b/qa/qa/page/project/pipeline/show.rb
index e4511ababfd..25d62ac59af 100644
--- a/qa/qa/page/project/pipeline/show.rb
+++ b/qa/qa/page/project/pipeline/show.rb
@@ -44,6 +44,17 @@ module QA
element :jobs_dropdown_menu
end
+ view 'app/views/layouts/nav/_breadcrumbs.html.haml' do
+ element :breadcrumb_links_content
+ element :breadcrumb_current_link
+ end
+
+ def pipeline_id
+ within_element(:breadcrumb_links_content) do
+ find_element(:breadcrumb_current_link).text.delete_prefix('#')
+ end
+ end
+
def running?(wait: 0)
within_element(:pipeline_header) do
page.has_content?('running', wait: wait)
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
new file mode 100644
index 00000000000..a954bd16386
--- /dev/null
+++ b/qa/qa/specs/features/browser_ui/4_verify/ci_job_artifacts/unlocking_job_artifacts_across_pipelines_spec.rb
@@ -0,0 +1,170 @@
+# frozen_string_literal: true
+
+module QA
+ RSpec.describe 'Verify', :runner, product_group: :pipeline_security do
+ describe "Unlocking job artifacts across pipelines" do
+ let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(number: 8)}" }
+
+ let(:project) do
+ Resource::Project.fabricate_via_api! do |project|
+ project.name = 'unlock-job-artifacts-project'
+ end
+ end
+
+ let!(:runner) do
+ Resource::ProjectRunner.fabricate! do |runner|
+ runner.project = project
+ runner.name = executor
+ runner.tags = [executor]
+ end
+ end
+
+ let(:test_job_name) { 'test-job' }
+
+ before do
+ Flow::Login.sign_in
+ end
+
+ context 'when latest pipeline is successful' do
+ 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)
+
+ Page::Project::Job::Show.perform do |job|
+ expect(job).to have_locked_artifact
+ end
+
+ update_ci_script('echo bye')
+ project.visit!
+
+ Flow::Pipeline.visit_latest_pipeline(status: 'passed')
+ Flow::Pipeline.visit_pipeline_job_page(job_name: test_job_name)
+
+ 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)
+
+ Page::Project::Job::Show.perform do |job|
+ expect(job).to have_unlocked_artifact
+ end
+ end
+ 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
+
+ Flow::Pipeline.visit_latest_pipeline(status: 'passed')
+ Flow::Pipeline.visit_pipeline_job_page(job_name: test_job_name)
+
+ 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
+ end
+
+ Flow::Pipeline.visit_latest_pipeline(status: 'failed')
+ Flow::Pipeline.visit_pipeline_job_page(job_name: test_job_name)
+
+ Page::Project::Job::Show.perform do |job|
+ expect(job).to have_unlocked_artifact
+ end
+
+ update_ci_script('echo bye && exit 1')
+ project.visit!
+
+ Flow::Pipeline.visit_latest_pipeline(status: 'failed')
+ Flow::Pipeline.visit_pipeline_job_page(job_name: test_job_name)
+
+ Page::Project::Job::Show.perform do |job|
+ expect(job).to have_unlocked_artifact
+ end
+
+ Flow::Pipeline.visit_pipeline_job_page(pipeline: failed_pipeline_1, job_name: test_job_name)
+
+ 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)
+
+ Page::Project::Job::Show.perform do |job|
+ expect(job).to have_locked_artifact
+ end
+ end
+ end
+
+ private
+
+ def add_ci_file
+ script = 'echo test'
+ ci_file = ci_file_with_job_artifact(script)
+
+ Resource::Repository::Commit.fabricate_via_api! do |commit|
+ commit.project = project
+ commit.commit_message = "Set script #{script}"
+ commit.add_files([ci_file])
+ end
+ end
+
+ def update_ci_script(script)
+ ci_file = ci_file_with_job_artifact(script)
+
+ Resource::Repository::Commit.fabricate_via_api! do |commit|
+ commit.project = project
+ commit.commit_message = "Set 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')
+
+ Resource::Repository::Commit.fabricate_via_api! do |commit|
+ commit.project = project
+ commit.commit_message = 'Add failing CI file.'
+ commit.add_files([ci_file])
+ end
+ end
+
+ def ci_file_with_job_artifact(script)
+ {
+ file_path: '.gitlab-ci.yml',
+ content: <<~YAML
+ #{test_job_name}:
+ stage: test
+ tags: ["#{executor}"]
+ script: #{script}
+ artifacts:
+ paths: ['.gitlab-ci.yml']
+ when: always
+ YAML
+ }
+ end
+ end
+ end
+end