diff options
Diffstat (limited to 'qa/qa/specs/features/browser_ui/5_package')
11 files changed, 417 insertions, 98 deletions
diff --git a/qa/qa/specs/features/browser_ui/5_package/composer_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/composer_registry_spec.rb index 2489545782a..61c71b062ae 100644 --- a/qa/qa/specs/features/browser_ui/5_package/composer_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/composer_registry_spec.rb @@ -3,7 +3,7 @@ require 'securerandom' module QA - RSpec.describe 'Package', :orchestrated, :packages do + RSpec.describe 'Package', :orchestrated, :packages, :object_storage do describe 'Composer Repository' do include Runtime::Fixtures @@ -14,7 +14,7 @@ module QA end let(:package) do - Resource::Package.new.tap do |package| + Resource::Package.init do |package| package.name = "my_package-#{SecureRandom.hex(4)}" package.project = project end diff --git a/qa/qa/specs/features/browser_ui/5_package/conan_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/conan_repository_spec.rb index a1e2eb1046c..668a1524b1c 100644 --- a/qa/qa/specs/features/browser_ui/5_package/conan_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/conan_repository_spec.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :packages do + RSpec.describe 'Package', :orchestrated, :packages, :object_storage, quarantine: { + only: { job: 'object_storage' }, + issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/335981', + type: :bug + } do describe 'Conan Repository' do include Runtime::Fixtures @@ -12,7 +16,7 @@ module QA end let(:package) do - Resource::Package.new.tap do |package| + Resource::Package.init do |package| package.name = 'conantest' package.project = project end diff --git a/qa/qa/specs/features/browser_ui/5_package/container_registry_omnibus_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry_omnibus_spec.rb new file mode 100644 index 00000000000..4b7669810ec --- /dev/null +++ b/qa/qa/specs/features/browser_ui/5_package/container_registry_omnibus_spec.rb @@ -0,0 +1,88 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Package', :registry, :orchestrated do + describe 'Self-managed Container Registry' do + let(:project) do + Resource::Project.fabricate_via_api! do |project| + project.name = 'project-with-registry' + project.template_name = 'express' + end + end + + let!(:runner) do + Resource::Runner.fabricate! do |runner| + runner.name = "qa-runner-#{Time.now.to_i}" + runner.tags = ["runner-for-#{project.name}"] + runner.executor = :docker + runner.project = project + end + end + + before do + Flow::Login.sign_in + project.visit! + end + + after do + runner.remove_via_api! + end + + it "pushes image and deletes tag", testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1743' do + 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 + build: + image: docker:19.03.12 + stage: build + services: + - name: docker:19.03.12-dind + command: + - /bin/sh + - -c + - | + apk add --no-cache openssl + true | openssl s_client -showcerts -connect gitlab.test:5050 > /usr/local/share/ca-certificates/gitlab.test.crt + update-ca-certificates + dockerd-entrypoint.sh || exit + variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD gitlab.test:5050 + - docker build -t $IMAGE_TAG . + - docker push $IMAGE_TAG + tags: + - "runner-for-#{project.name}" + YAML + }]) + end + + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('build') + end + + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) + end + + Page::Project::Menu.perform(&:go_to_container_registry) + + Page::Project::Registry::Show.perform do |registry| + expect(registry).to have_registry_repository(project.path_with_namespace) + + registry.click_on_image(project.path_with_namespace) + expect(registry).to have_tag('master') + + registry.click_delete + expect(registry).not_to have_tag('master') + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/5_package/generic_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/generic_repository_spec.rb index bbf8ea8c05e..ef5965b29e5 100644 --- a/qa/qa/specs/features/browser_ui/5_package/generic_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/generic_repository_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :packages do + RSpec.describe 'Package', :orchestrated, :packages, :object_storage do describe 'Generic Repository' do let(:project) do Resource::Project.fabricate_via_api! do |project| @@ -10,7 +10,7 @@ module QA end let(:package) do - Resource::Package.new.tap do |package| + Resource::Package.init do |package| package.name = "my_package" package.project = project end diff --git a/qa/qa/specs/features/browser_ui/5_package/maven_gradle_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/maven_gradle_repository_spec.rb index 4d4f981f021..32a0670e342 100644 --- a/qa/qa/specs/features/browser_ui/5_package/maven_gradle_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/maven_gradle_repository_spec.rb @@ -1,41 +1,47 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :packages do + RSpec.describe 'Package', :orchestrated, :packages, :object_storage do describe 'Maven Repository with Gradle' do + using RSpec::Parameterized::TableSyntax include Runtime::Fixtures let(:group_id) { 'com.gitlab.qa' } let(:artifact_id) { 'maven_gradle' } let(:package_name) { "#{group_id}/#{artifact_id}".tr('.', '/') } - let(:auth_token) do - unless Page::Main::Menu.perform(&:signed_in?) - Flow::Login.sign_in - end + let(:package_version) { '1.3.7' } - Resource::PersonalAccessToken.fabricate!.token - end + let(:personal_access_token) { Runtime::Env.personal_access_token } - let(:project) do + let(:package_project) do Resource::Project.fabricate_via_api! do |project| project.name = 'maven-with-gradle-project' project.initialize_with_readme = true + project.visibility = :private + end + end + + let(:client_project) do + Resource::Project.fabricate_via_api! do |client_project| + client_project.name = 'gradle_client' + client_project.initialize_with_readme = true + client_project.group = package_project.group end end let(:package) do - Resource::Package.new.tap do |package| + Resource::Package.init do |package| package.name = package_name - package.project = project + package.project = package_project end end - let!(:runner) do + let(:runner) do Resource::Runner.fabricate! do |runner| runner.name = "qa-runner-#{Time.now.to_i}" - runner.tags = ["runner-for-#{project.name}"] + runner.tags = ["runner-for-#{package_project.group.name}"] runner.executor = :docker - runner.project = project + runner.token = package_project.group.runners_token end end @@ -44,87 +50,200 @@ module QA "#{uri.scheme}://#{uri.host}:#{uri.port}" end + let(:project_deploy_token) do + Resource::DeployToken.fabricate_via_browser_ui! do |deploy_token| + deploy_token.name = 'maven-with-gradle-deploy-token' + deploy_token.project = package_project + end + end + + let(:package_gitlab_ci_file) do + { + file_path: '.gitlab-ci.yml', + content: + <<~YAML + deploy: + image: gradle:6.5-jdk11 + script: + - 'gradle publish' + only: + - "#{package_project.default_branch}" + tags: + - "runner-for-#{package_project.group.name}" + YAML + } + end + + let(:package_build_gradle_file) do + { + file_path: 'build.gradle', + content: + <<~EOF + plugins { + id 'java' + id 'maven-publish' + } + + publishing { + publications { + library(MavenPublication) { + groupId '#{group_id}' + artifactId '#{artifact_id}' + version '#{package_version}' + from components.java + } + } + repositories { + maven { + url "#{gitlab_address_with_port}/api/v4/projects/#{package_project.id}/packages/maven" + credentials(HttpHeaderCredentials) { + name = "Private-Token" + value = "#{personal_access_token}" + } + authentication { + header(HttpHeaderAuthentication) + } + } + } + } + EOF + } + end + + let(:client_gitlab_ci_file) do + { + file_path: '.gitlab-ci.yml', + content: + <<~YAML + build: + image: gradle:6.5-jdk11 + script: + - 'gradle build' + only: + - "#{client_project.default_branch}" + tags: + - "runner-for-#{client_project.group.name}" + YAML + } + end + + before do + Flow::Login.sign_in_unless_signed_in + runner + end + after do runner.remove_via_api! package.remove_via_api! + package_project.remove_via_api! + client_project.remove_via_api! end - it 'publishes a maven package via gradle', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1074' do - 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 - deploy: - image: gradle:6.5-jdk11 - script: - - 'gradle publish' - only: - - "#{project.default_branch}" - tags: - - "runner-for-#{project.name}" - YAML - }, - { - file_path: 'build.gradle', - content: - <<~EOF - plugins { - id 'java' - id 'maven-publish' - } - - publishing { - publications { - library(MavenPublication) { - groupId '#{group_id}' - artifactId '#{artifact_id}' - from components.java - } - } - repositories { - maven { - url "#{gitlab_address_with_port}/api/v4/projects/#{project.id}/packages/maven" - credentials(HttpHeaderCredentials) { - name = "Private-Token" - value = "#{auth_token}" - } - authentication { - header(HttpHeaderAuthentication) - } - } - } - } - EOF - }]) - end - - project.visit! - Flow::Pipeline.visit_latest_pipeline + where(:authentication_token_type, :maven_header_name) do + :personal_access_token | 'Private-Token' + :ci_job_token | 'Job-Token' + :project_deploy_token | 'Deploy-Token' + end - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.click_job('deploy') + with_them do + let(:token) do + case authentication_token_type + when :personal_access_token + "\"#{personal_access_token}\"" + when :ci_job_token + 'System.getenv("CI_JOB_TOKEN")' + when :project_deploy_token + "\"#{project_deploy_token.password}\"" + end end - Page::Project::Job::Show.perform do |job| - expect(job).to be_successful(timeout: 800) + let(:client_build_gradle_file) do + { + file_path: 'build.gradle', + content: + <<~EOF + plugins { + id 'java' + id 'application' + } + + repositories { + jcenter() + maven { + url "#{gitlab_address_with_port}/api/v4/projects/#{package_project.id}/packages/maven" + name "GitLab" + credentials(HttpHeaderCredentials) { + name = '#{maven_header_name}' + value = #{token} + } + authentication { + header(HttpHeaderAuthentication) + } + } + } + + dependencies { + implementation group: '#{group_id}', name: '#{artifact_id}', version: '#{package_version}' + testImplementation 'junit:junit:4.12' + } + + application { + mainClassName = 'gradle_maven_app.App' + } + EOF + } end - Page::Project::Menu.perform(&:click_packages_link) + it "pushes and pulls a maven package via gradle using #{params[:authentication_token_type]}", testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1074' do + # pushing + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = package_project + commit.commit_message = 'Add .gitlab-ci.yml' + commit.add_files([package_gitlab_ci_file, package_build_gradle_file]) + end - Page::Project::Packages::Index.perform do |index| - expect(index).to have_package(package_name) + package_project.visit! - index.click_package(package_name) - end + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('deploy') + end + + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) + end + + 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, package_version) + end + + # pulling + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = client_project + commit.commit_message = 'Add .gitlab-ci.yml' + commit.add_files([client_gitlab_ci_file, client_build_gradle_file]) + end + + client_project.visit! + + Flow::Pipeline.visit_latest_pipeline - Page::Project::Packages::Show.perform(&:click_delete) + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('build') + end - Page::Project::Packages::Index.perform do |index| - expect(index).to have_content("Package deleted successfully") - expect(index).not_to have_package(package_name) + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 800) + end end end end diff --git a/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb index 9c00f1f6d17..fb92616ffc5 100644 --- a/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/maven_repository_spec.rb @@ -3,7 +3,7 @@ require 'securerandom' module QA - RSpec.describe 'Package', :orchestrated, :packages, :reliable do + RSpec.describe 'Package', :orchestrated, :packages, :reliable, :object_storage do describe 'Maven Repository' do include Runtime::Fixtures @@ -33,7 +33,7 @@ module QA end let(:package) do - Resource::Package.new.tap do |package| + Resource::Package.init do |package| package.name = package_name package.project = project end diff --git a/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb index c4bfaacca11..2322d18a9ba 100644 --- a/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/npm_registry_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :packages, :reliable do + RSpec.describe 'Package', :orchestrated, :packages, :reliable, :object_storage do describe 'npm registry' do include Runtime::Fixtures @@ -50,7 +50,7 @@ module QA stages: - deploy - + deploy: stage: deploy script: @@ -72,7 +72,7 @@ module QA stages: - install - + install: stage: install script: @@ -120,7 +120,7 @@ module QA end let(:package) do - Resource::Package.new.tap do |package| + Resource::Package.init do |package| package.name = "@#{registry_scope}/#{project.name}" package.project = project end diff --git a/qa/qa/specs/features/browser_ui/5_package/nuget_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/nuget_repository_spec.rb index daf41f1c6ab..1f62b285798 100644 --- a/qa/qa/specs/features/browser_ui/5_package/nuget_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/nuget_repository_spec.rb @@ -3,7 +3,7 @@ require 'securerandom' module QA - RSpec.describe 'Package', :orchestrated, :packages do + RSpec.describe 'Package', :orchestrated, :packages, :object_storage do describe 'NuGet Repository' do include Runtime::Fixtures let(:project) do @@ -14,7 +14,7 @@ module QA end let(:package) do - Resource::Package.new.tap do |package| + Resource::Package.init do |package| package.name = "dotnetcore-#{SecureRandom.hex(8)}" package.project = project end diff --git a/qa/qa/specs/features/browser_ui/5_package/online_garbage_collection_spec.rb b/qa/qa/specs/features/browser_ui/5_package/online_garbage_collection_spec.rb new file mode 100644 index 00000000000..65fc12545b7 --- /dev/null +++ b/qa/qa/specs/features/browser_ui/5_package/online_garbage_collection_spec.rb @@ -0,0 +1,108 @@ +# frozen_string_literal: true + +module QA + RSpec.describe 'Package' do + describe 'Container Registry Online Garbage Collection', :registry_gc, only: { subdomain: %i[pre] } do + let(:group) { Resource::Group.fabricate_via_api! } + + let(:imported_project) do + Resource::ProjectImportedFromURL.fabricate_via_browser_ui! do |project| + project.name = 'container-registry' + project.group = group + project.gitlab_repository_path = 'https://gitlab.com/gitlab-org/container-registry.git' + end + end + + let!(:gitlab_ci_yaml) do + <<~YAML + variables: + GOPATH: $CI_PROJECT_DIR/.go + BUILD_CACHE: $CI_PROJECT_DIR/.online-gc-tester + STAGE_ONE_VALIDATION_DELAY: "6m" + STAGE_TWO_VALIDATION_DELAY: "12m" + STAGE_THREE_VALIDATION_DELAY: "6m" + STAGE_FOUR_VALIDATION_DELAY: "12m" + STAGE_FIVE_VALIDATION_DELAY: "12m" + + stages: + - generate + - build + - test + + .base: &base + image: docker:19 + services: + - docker:19-dind + variables: + DOCKER_HOST: tcp://docker:2376 + DOCKER_TLS_CERTDIR: "/certs" + DOCKER_TLS_VERIFY: 1 + DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" + before_script: + - until docker info; do sleep 1; done + - mkdir -p $GOPATH + - mkdir -p $BUILD_CACHE + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + + test: + stage: generate + extends: .base + script: + - apk add go make git + - make binaries + - ./bin/online-gc-tester generate --base-dir=$BUILD_CACHE + - ./bin/online-gc-tester build --base-dir=$BUILD_CACHE + - ./bin/online-gc-tester push --base-dir=$BUILD_CACHE + - ./bin/online-gc-tester pull --base-dir=$BUILD_CACHE + - ./bin/online-gc-tester test --base-dir=$BUILD_CACHE --stage=1 --delay=$STAGE_ONE_VALIDATION_DELAY + - ./bin/online-gc-tester test --base-dir=$BUILD_CACHE --stage=2 --delay=$STAGE_TWO_VALIDATION_DELAY + - ./bin/online-gc-tester test --base-dir=$BUILD_CACHE --stage=3 --delay=$STAGE_THREE_VALIDATION_DELAY + - ./bin/online-gc-tester test --base-dir=$BUILD_CACHE --stage=4 --delay=$STAGE_FOUR_VALIDATION_DELAY + - ./bin/online-gc-tester test --base-dir=$BUILD_CACHE --stage=5 --delay=$STAGE_FIVE_VALIDATION_DELAY + timeout: 1h 30m + YAML + end + + before do + Flow::Login.sign_in + + imported_project + + Page::Project::Menu.perform(&:go_to_repository_settings) + + Page::Project::Settings::Repository.perform do |setting| + setting.expand_default_branch + end + + Page::Project::Settings::DefaultBranch.perform do |setting| + setting.set_default_branch('online-gc-test-builder-poc') + setting.click_save_changes_button + end + + Resource::Repository::Commit.fabricate_via_api! do |commit| + commit.project = imported_project + commit.branch = 'online-gc-test-builder-poc' + commit.commit_message = 'Update .gitlab-ci.yml' + commit.update_files([{ + file_path: '.gitlab-ci.yml', + content: gitlab_ci_yaml + }]) + end + end + + it 'runs the online garbage collector tool', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1854' do + imported_project.visit! + + Flow::Pipeline.visit_latest_pipeline + + Page::Project::Pipeline::Show.perform do |pipeline| + pipeline.click_job('test') + end + + Page::Project::Job::Show.perform do |job| + expect(job).to be_successful(timeout: 3900) + end + end + end + end +end diff --git a/qa/qa/specs/features/browser_ui/5_package/pypi_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/pypi_repository_spec.rb index fb29af43da6..a9034174cab 100644 --- a/qa/qa/specs/features/browser_ui/5_package/pypi_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/pypi_repository_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :packages do + RSpec.describe 'Package', :orchestrated, :packages, :object_storage do describe 'PyPI Repository' do include Runtime::Fixtures let(:project) do @@ -11,7 +11,7 @@ module QA end let(:package) do - Resource::Package.new.tap do |package| + Resource::Package.init do |package| package.name = 'mypypipackage' package.project = project end diff --git a/qa/qa/specs/features/browser_ui/5_package/rubygems_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/rubygems_registry_spec.rb index 5d15885cd67..530a3243766 100644 --- a/qa/qa/specs/features/browser_ui/5_package/rubygems_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/rubygems_registry_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :orchestrated, :requires_admin, :packages do + RSpec.describe 'Package', :orchestrated, :requires_admin, :packages, :object_storage do describe 'RubyGems Repository' do include Runtime::Fixtures @@ -12,7 +12,7 @@ module QA end let(:package) do - Resource::Package.new.tap do |package| + Resource::Package.init do |package| package.name = 'mygem' package.project = project end |