Commit 2beb3881 authored by Dan Davison's avatar Dan Davison

Merge branch 'jsl-tc186-geo-ci-artifact-spec' into 'master'

Add tests for Geo replication of CI job logs and artifacts

See merge request gitlab-org/gitlab!42403
parents fdf8fe0d 212ef9da
...@@ -153,6 +153,7 @@ module QA ...@@ -153,6 +153,7 @@ module QA
module Pipeline module Pipeline
autoload :Show, 'qa/ee/page/project/pipeline/show' autoload :Show, 'qa/ee/page/project/pipeline/show'
autoload :Index, 'qa/ee/page/project/pipeline/index'
end end
module Secure module Secure
...@@ -174,6 +175,10 @@ module QA ...@@ -174,6 +175,10 @@ module QA
module Snippet module Snippet
autoload :Index, 'qa/ee/page/project/snippet/index' autoload :Index, 'qa/ee/page/project/snippet/index'
end end
module Job
autoload :Show, 'qa/ee/page/project/job/show'
end
end end
module MergeRequest module MergeRequest
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Job
module Show
extend QA::Page::PageConcern
# These wait times cover both the time for pipeline job to complete and time for log and artifact to Geo replicate, so the max duration has been doubled
def wait_for_job_log_replication
QA::Runtime::Logger.debug(%Q[#{self.class.name} - wait_for_job_log_replication])
wait_until(max_duration: 2 * Runtime::Geo.max_file_replication_time) do
has_job_log?
end
end
def wait_for_job_artifact_replication
QA::Runtime::Logger.debug(%Q[#{self.class.name} - wait_for_job_artifact_replication])
wait_until(max_duration: 2 * Runtime::Geo.max_file_replication_time) do
has_browse_button?
end
end
end
end
end
end
end
end
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Pipeline
module Index
extend QA::Page::PageConcern
def wait_for_latest_pipeline_replication
QA::Runtime::Logger.debug(%Q[#{self.class.name} - wait_for_latest_pipeline_replication])
wait_until(max_duration: Runtime::Geo.max_file_replication_time) do
within_element_by_index(:pipeline_commit_status, 0) { has_text?('passed') || has_text?('failed') }
end
end
end
end
end
end
end
end
...@@ -34,6 +34,13 @@ module QA ...@@ -34,6 +34,13 @@ module QA
def has_license_count_of?(count) def has_license_count_of?(count)
find_element(:licenses_counter).has_content?(count) find_element(:licenses_counter).has_content?(count)
end end
def wait_for_pipeline_job_replication(name)
QA::Runtime::Logger.debug(%Q[#{self.class.name} - wait_for_pipeline_job_replication])
wait_until(max_duration: Runtime::Geo.max_file_replication_time) do
has_job?(name)
end
end
end end
end end
end end
......
...@@ -58,6 +58,10 @@ module QA ...@@ -58,6 +58,10 @@ module QA
click_element :retry_button click_element :retry_button
end end
def has_job_log?
has_element? :job_log_content
end
private private
def loaded?(wait: 60) def loaded?(wait: 60)
...@@ -70,3 +74,5 @@ module QA ...@@ -70,3 +74,5 @@ module QA
end end
end end
end end
QA::Page::Project::Job::Show.prepend_if_ee('QA::EE::Page::Project::Job::Show')
...@@ -57,3 +57,5 @@ module QA ...@@ -57,3 +57,5 @@ module QA
end end
end end
end end
QA::Page::Project::Pipeline::Index.prepend_if_ee('QA::EE::Page::Project::Pipeline::Index')
# frozen_string_literal: true
module QA
RSpec.describe 'Geo', :orchestrated, :runner, :requires_admin, :geo do
describe 'CI job' do
before(:all) do
@file_name = 'geo_artifact.txt'
@directory_name = 'geo_artifacts'
@pipeline_job_name = 'test-artifacts'
executor = "qa-runner-#{Time.now.to_i}"
@project = Resource::Project.fabricate_via_api! do |project|
project.name = 'geo-project-with-artifacts'
end
@runner = Resource::Runner.fabricate! do |runner|
runner.project = @project
runner.name = executor
runner.tags = [executor]
end
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
test-artifacts:
tags:
- '#{executor}'
artifacts:
paths:
- '#{@directory_name}'
expire_in: 1000 seconds
script:
- |
mkdir #{@directory_name}
echo "CONTENTS" > #{@directory_name}/#{@file_name}
YAML
}
]
)
end
end
after(:all) do
@runner.remove_via_api!
end
# Test code is based on qa/specs/features/ee/browser_ui/4_verify/locked_artifacts_spec.rb
it 'replicates the job log to the secondary Geo site', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/908' do
Runtime::Logger.debug('Visiting the secondary Geo site')
Flow::Login.while_signed_in(address: :geo_secondary) do
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(@project.name)
dashboard.go_to_project(@project.name)
end
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform do |index|
index.wait_for_latest_pipeline_replication
index.click_on_latest_pipeline
end
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.wait_for_pipeline_job_replication(@pipeline_job_name)
pipeline.click_job(@pipeline_job_name)
end
Page::Project::Job::Show.perform do |pipeline_job|
pipeline_job.wait_for_job_log_replication
expect(pipeline_job).to have_job_log
end
end
end
it 'replicates the job artifact to the secondary Geo site', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/186' do
Runtime::Logger.debug('Visiting the secondary Geo site')
Flow::Login.while_signed_in(address: :geo_secondary) do
EE::Page::Main::Banner.perform do |banner|
expect(banner).to have_secondary_read_only_banner
end
Page::Main::Menu.perform(&:go_to_projects)
Page::Dashboard::Projects.perform do |dashboard|
dashboard.wait_for_project_replication(@project.name)
dashboard.go_to_project(@project.name)
end
Page::Project::Menu.perform(&:click_ci_cd_pipelines)
Page::Project::Pipeline::Index.perform do |index|
index.wait_for_latest_pipeline_replication
index.click_on_latest_pipeline
end
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.wait_for_pipeline_job_replication(@pipeline_job_name)
pipeline.click_job(@pipeline_job_name)
end
Page::Project::Job::Show.perform do |pipeline_job|
pipeline_job.wait_for_job_artifact_replication
pipeline_job.click_browse_button
end
EE::Page::Project::Artifact::Show.perform do |artifact|
artifact.go_to_directory(@directory_name)
expect(artifact).to have_content(@file_name)
end
end
end
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment