Commit 46a37904 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'jsl-add-geo-maven-spec' into 'master'

Add test for geo replication of Maven package files

See merge request gitlab-org/gitlab!42282
parents f5fd0a69 ca302769
...@@ -166,6 +166,10 @@ module QA ...@@ -166,6 +166,10 @@ module QA
module PathLocks module PathLocks
autoload :Index, 'qa/ee/page/project/path_locks/index' autoload :Index, 'qa/ee/page/project/path_locks/index'
end end
module Packages
autoload :Index, 'qa/ee/page/project/packages/index'
end
end end
module MergeRequest module MergeRequest
......
# frozen_string_literal: true
module QA
module EE
module Page
module Project
module Packages
module Index
extend QA::Page::PageConcern
def wait_for_package_replication(name)
QA::Runtime::Logger.debug(%Q[#{self.class.name} - wait_for_package_replication])
wait_until(max_duration: Runtime::Geo.max_file_replication_time) do
has_package?(name)
end
end
end
end
end
end
end
end
...@@ -23,6 +23,7 @@ module QA ...@@ -23,6 +23,7 @@ module QA
# Alias QA::Runtime::Scenario.gitlab_address to @address since # Alias QA::Runtime::Scenario.gitlab_address to @address since
# some components depends on QA::Runtime::Scenario.gitlab_address. # some components depends on QA::Runtime::Scenario.gitlab_address.
QA::Runtime::Scenario.define(:gitlab_address, QA::Runtime::Scenario.geo_primary_address) QA::Runtime::Scenario.define(:gitlab_address, QA::Runtime::Scenario.geo_primary_address)
QA::Runtime::Scenario.define(:network, 'geo')
unless options[:geo_skip_setup?] unless options[:geo_skip_setup?]
Geo::Primary.act do Geo::Primary.act do
......
...@@ -26,3 +26,5 @@ module QA ...@@ -26,3 +26,5 @@ module QA
end end
end end
end end
QA::Page::Project::Packages::Index.prepend_if_ee('QA::EE::Page::Project::Packages::Index')
# frozen_string_literal: true
module QA
RSpec.describe 'Geo', :orchestrated, :geo do
describe 'Maven package' do
include Runtime::Fixtures
let(:group_id) { 'com.gitlab.qa' }
let(:artifact_id) { 'maven' }
let(:package_name) { "#{group_id}/#{artifact_id}".tr('.', '/') }
let(:auth_token) do
unless Page::Main::Menu.perform(&:signed_in?)
Flow::Login.sign_in
end
Resource::PersonalAccessToken.fabricate!.access_token
end
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'geo-maven-package-project'
end
end
let(:uri) { URI.parse(Runtime::Scenario.gitlab_address) }
let(:gitlab_address_with_port) { "#{uri.scheme}://#{uri.host}:#{uri.port}" }
it 'replicates to the secondary site', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1025' do
pom_xml = {
file_path: 'pom.xml',
content: <<~XML
<project>
<groupId>#{group_id}</groupId>
<artifactId>#{artifact_id}</artifactId>
<version>1.0</version>
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>#{project.name}</id>
<url>#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>#{project.name}</id>
<url>#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/maven</url>
</repository>
<snapshotRepository>
<id>#{project.name}</id>
<url>#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/maven</url>
</snapshotRepository>
</distributionManagement>
</project>
XML
}
settings_xml = {
file_path: 'settings.xml',
content: <<~XML
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
<servers>
<server>
<id>#{project.name}</id>
<configuration>
<httpHeaders>
<property>
<name>Private-Token</name>
<value>#{auth_token}</value>
</property>
</httpHeaders>
</configuration>
</server>
</servers>
</settings>
XML
}
# Use a Maven Docker container to deploy the package
with_fixtures([pom_xml, settings_xml]) do |dir|
Service::DockerRun::Maven.new(dir).publish!
end
QA::Runtime::Logger.debug('Visiting the secondary Geo site')
QA::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
# Validate the content has been replicated
Page::Project::Menu.perform(&:click_packages_link)
Page::Project::Packages::Index.perform do |index|
index.wait_for_package_replication(package_name)
index.click_package(package_name)
end
Page::Project::Packages::Show.perform do |show|
expect(show).to have_package_info(package_name, "1.0")
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