Commit 3498fc91 authored by Sanad Liaquat's avatar Sanad Liaquat

Merge branch 'maven-pull-test' into 'master'

Add install test for Maven

See merge request gitlab-org/gitlab!59177
parents dc5fd97b 36050607
......@@ -9,6 +9,7 @@ module QA
let(:group_id) { 'com.gitlab.qa' }
let(:artifact_id) { "maven-#{SecureRandom.hex(8)}" }
let(:another_artifact_id) { "maven-#{SecureRandom.hex(8)}" }
let(:package_name) { "#{group_id}/#{artifact_id}".tr('.', '/') }
let(:auth_token) do
unless Page::Main::Menu.perform(&:signed_in?)
......@@ -64,7 +65,7 @@ module QA
<repositories>
<repository>
<id>#{project.name}</id>
<url>#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/maven</url>
<url>#{gitlab_address_with_port}/api/v4/groups/#{project.group.id}/-/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
......@@ -82,6 +83,43 @@ module QA
}
end
let(:pom_xml_another_project) do
{
file_path: 'pom.xml',
content: <<~XML
<project>
<groupId>#{group_id}</groupId>
<artifactId>#{another_artifact_id}</artifactId>
<version>1.0</version>
<modelVersion>4.0.0</modelVersion>
<repositories>
<repository>
<id>#{another_project.name}</id>
<url>#{gitlab_address_with_port}/api/v4/groups/#{another_project.group.id}/-/packages/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>#{another_project.name}</id>
<url>#{gitlab_address_with_port}/api/v4/projects/#{another_project.id}/packages/maven</url>
</repository>
<snapshotRepository>
<id>#{another_project.name}</id>
<url>#{gitlab_address_with_port}/api/v4/projects/#{another_project.id}/packages/maven</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>#{group_id}</groupId>
<artifactId>#{artifact_id}</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</project>
XML
}
end
let(:settings_xml) do
{
file_path: 'settings.xml',
......@@ -106,7 +144,7 @@ module QA
}
end
let(:gitlab_ci_yaml) do
let(:gitlab_ci_deploy_yml) do
{
file_path: '.gitlab-ci.yml',
content:
......@@ -124,58 +162,90 @@ module QA
}
end
let(:gitlab_ci_install_yml) do
{
file_path: '.gitlab-ci.yml',
content:
<<~YAML
install:
image: maven:3.6-jdk-11
script:
- "mvn install"
only:
- "#{project.default_branch}"
tags:
- "runner-for-#{another_project.group.name}"
YAML
}
end
after do
runner.remove_via_api!
project.remove_via_api!
another_project.remove_via_api!
end
it 'publishes a maven package and deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/943' do
# Use a maven docker container to deploy the package
with_fixtures([pom_xml, settings_xml]) do |dir|
Service::DockerRun::Maven.new(dir).publish!
it 'pushes and pulls a Maven package via CI and deletes it', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1115' do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files([
gitlab_ci_deploy_yml,
settings_xml,
pom_xml
])
end
project.visit!
Page::Project::Menu.perform(&:click_packages_link)
Page::Project::Packages::Index.perform do |index|
expect(index).to have_package(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")
Flow::Pipeline.visit_latest_pipeline
show.click_delete
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('deploy')
end
Page::Project::Packages::Index.perform do |index|
expect(index).to have_content("Package deleted successfully")
expect(index).not_to have_package(package_name)
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 800)
end
it 'publishes and downloads a maven package via CI', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1115' do
Resource::Repository::Commit.fabricate_via_api! do |commit|
commit.project = project
commit.project = another_project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files([
gitlab_ci_yaml,
settings_xml,
pom_xml
gitlab_ci_install_yml,
pom_xml_another_project
])
end
project.visit!
another_project.visit!
Flow::Pipeline.visit_latest_pipeline
Page::Project::Pipeline::Show.perform do |pipeline|
pipeline.click_job('deploy')
pipeline.click_job('install')
end
Page::Project::Job::Show.perform do |job|
expect(job).to be_successful(timeout: 800)
end
project.visit!
Page::Project::Menu.perform(&:click_packages_link)
Page::Project::Packages::Index.perform do |index|
expect(index).to have_package(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")
show.click_delete
end
Page::Project::Packages::Index.perform do |index|
expect(index).to have_content("Package deleted successfully")
expect(index).not_to have_package(package_name)
end
end
context 'when "allow duplicate" setting is disabled' do
......@@ -204,7 +274,7 @@ module QA
commit.project = another_project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files([
gitlab_ci_yaml,
gitlab_ci_deploy_yml,
settings_xml,
pom_xml
])
......@@ -249,7 +319,7 @@ module QA
commit.project = another_project
commit.commit_message = 'Add .gitlab-ci.yml'
commit.add_files([
gitlab_ci_yaml,
gitlab_ci_deploy_yml,
settings_xml,
pom_xml
])
......
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