diff --git a/qa/qa/specs/features/api/5_package/container_registry/saas/container_registry_spec.rb b/qa/qa/specs/features/api/5_package/container_registry/saas/container_registry_spec.rb index 6f9d7ffd53b0168999ddcf265e8a077dc49f589e..9c60b19deff274adcc967ff11ee0f74168077b19 100644 --- a/qa/qa/specs/features/api/5_package/container_registry/saas/container_registry_spec.rb +++ b/qa/qa/specs/features/api/5_package/container_registry/saas/container_registry_spec.rb @@ -3,16 +3,14 @@ module QA RSpec.describe 'Package', only: { subdomain: %i[staging staging-canary pre] }, product_group: :container_registry do - include Support::API include Support::Helpers::MaskToken include Support::Data::Image describe 'SaaS Container Registry API' do - let(:api_client) { Runtime::API::Client.new(:gitlab) } let(:executor) { "qa-runner-#{Faker::Alphanumeric.alphanumeric(number: 8)}" } let(:project) do - create(:project, name: 'project-with-registry-api', template_name: 'express', api_client: api_client) + create(:project, name: 'project-with-registry-api', template_name: 'express') end let!(:runner) do @@ -27,41 +25,41 @@ module QA let(:gitlab_ci_yaml) do <<~YAML - stages: - - build - - test + stages: + - build + - test - build: - image: docker:24.0.1 - stage: build - services: - - docker:24.0.1-dind - variables: - IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG - 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 - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build -t $IMAGE_TAG . - - docker push $IMAGE_TAG - - docker pull $IMAGE_TAG + build: + image: docker:24.0.1 + stage: build + services: + - docker:24.0.1-dind + variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + 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 + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build -t $IMAGE_TAG . + - docker push $IMAGE_TAG + - docker pull $IMAGE_TAG - test: - image: #{ci_test_image} - stage: test - script: - - 'id=$(curl --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories" | tac | jq ".[0].id")' - - echo $id - - 'tag_count=$(curl --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories/$id/tags" | jq ". | length")' - - if [ $tag_count -ne 1 ]; then exit 1; fi; - - 'status_code=$(curl --request DELETE --head --output /dev/null --write-out "%{http_code}\n" --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories/$id/tags/master")' - - if [ $status_code -ne 200 ]; then exit 1; fi; - - 'status_code=$(curl --head --output /dev/null --write-out "%{http_code}\n" --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories/$id/tags/master")' - - if [ $status_code -ne 404 ]; then exit 1; fi; + test: + image: #{ci_test_image} + stage: test + script: + - 'id=$(curl --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories" | tac | jq ".[0].id")' + - echo $id + - 'tag_count=$(curl --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories/$id/tags" | jq ". | length")' + - if [ $tag_count -ne 1 ]; then exit 1; fi; + - 'status_code=$(curl --request DELETE --head --output /dev/null --write-out "%{http_code}\n" --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories/$id/tags/master")' + - if [ $status_code -ne 200 ]; then exit 1; fi; + - 'status_code=$(curl --head --output /dev/null --write-out "%{http_code}\n" --header "PRIVATE-TOKEN: #{masked_token}" "https://${CI_SERVER_HOST}/api/v4/projects/#{project.id}/registry/repositories/$id/tags/master")' + - if [ $status_code -ne 404 ]; then exit 1; fi; YAML end @@ -71,37 +69,12 @@ module QA it 'pushes, pulls image to the registry and deletes tag', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/348001' do - Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2, message: "Commit push") do - create(:commit, api_client: api_client, commit_message: 'Add .gitlab-ci.yml', project: project, actions: [ - { action: 'create', file_path: '.gitlab-ci.yml', content: gitlab_ci_yaml } - ]) - end + create(:commit, commit_message: 'Add .gitlab-ci.yml', project: project, actions: [ + { action: 'create', file_path: '.gitlab-ci.yml', content: gitlab_ci_yaml } + ]) - Support::Retrier.retry_until( - max_duration: 30, - sleep_interval: 1, - message: "Waiting for pipeline to start" - ) do - pipeline_is_triggered? - end - Support::Retrier.retry_until( - max_duration: 300, - sleep_interval: 5, - message: "Waiting for pipeline to succeed" - ) do - latest_pipeline_succeed? - end - end - - private - - def pipeline_is_triggered? - !project.pipelines.empty? - end - - def latest_pipeline_succeed? - latest_pipeline = project.pipelines.first - latest_pipeline[:status] == 'success' + Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) + expect { project.latest_pipeline[:status] }.to eventually_eq('success').within(max_duration: 300) end end end diff --git a/qa/qa/specs/features/browser_ui/5_package/container_registry/saas/container_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry/saas/container_registry_spec.rb index d97f343ca7c142ef359fa34b0ee19e601c339666..d2f0340d1a2024a42866ec8f7dc7e4665126b8eb 100644 --- a/qa/qa/specs/features/browser_ui/5_package/container_registry/saas/container_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/container_registry/saas/container_registry_spec.rb @@ -5,79 +5,70 @@ module QA describe 'SaaS Container Registry', only: { subdomain: %i[staging staging-canary pre] }, product_group: :container_registry do let(:project) { create(:project, name: 'project-with-registry', template_name: 'express') } - let!(:gitlab_ci_yaml) do + let(:gitlab_ci_yaml) do <<~YAML - stages: - - test - - build + stages: + - test + - build - test: - image: registry.gitlab.com/gitlab-ci-utils/curl-jq:latest - stage: test - script: - - 'status_code=$(curl --header "Authorization: Bearer $CI_JOB_TOKEN" "https://${CI_SERVER_HOST}/gitlab/v1")' - - | - if [ "$status_code" -eq 404 ]; then - echo "The registry implements this API specification, but it is unavailable because the metadata database is disabled." - exit 1 - fi - build: - image: docker:24.0.1 - stage: build - services: - - docker:24.0.1-dind - variables: - IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG - DOCKER_HOST: tcp://docker:2376 - DOCKER_TLS_CERTDIR: "/certs" - DOCKER_TLS_VERIFY: 1 - DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" - before_script: - - | - echo "Waiting for docker to start..." - for i in $(seq 1 30); do - docker info && break - sleep 1s - done - script: - - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY - - docker build -t $IMAGE_TAG . - - docker push $IMAGE_TAG + test: + image: registry.gitlab.com/gitlab-ci-utils/curl-jq:latest + stage: test + script: + - 'status_code=$(curl --header "Authorization: Bearer $CI_JOB_TOKEN" "https://${CI_SERVER_HOST}/gitlab/v1")' + - | + if [ "$status_code" -eq 404 ]; then + echo "The registry implements this API specification, but it is unavailable because the metadata database is disabled." + exit 1 + fi + build: + image: docker:24.0.1 + stage: build + services: + - docker:24.0.1-dind + variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + DOCKER_HOST: tcp://docker:2376 + DOCKER_TLS_CERTDIR: "/certs" + DOCKER_TLS_VERIFY: 1 + DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client" + before_script: + - | + echo "Waiting for docker to start..." + for i in $(seq 1 30); do + docker info && break + sleep 1s + done + script: + - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY + - docker build -t $IMAGE_TAG . + - docker push $IMAGE_TAG YAML end - it 'pushes project image to the container registry and deletes tag', - testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/412806' do + before do + create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [ + { action: 'create', file_path: '.gitlab-ci.yml', content: gitlab_ci_yaml } + ]) + Flow::Login.sign_in project.visit! + end - Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do - create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [ - { action: 'create', file_path: '.gitlab-ci.yml', content: gitlab_ci_yaml } - ]) - end - - Flow::Pipeline.visit_latest_pipeline - - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.click_job('test') - end + it 'pushes project image to the container registry and deletes tag', + testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/412806' do + Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) + project.visit_job('test') Page::Project::Job::Show.perform do |job| expect(job).to be_successful(timeout: 200) - - job.go_to_pipeline - end - - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.click_job('build') end + project.visit_job('build') Page::Project::Job::Show.perform do |job| expect(job).to be_successful(timeout: 500) end Page::Project::Menu.perform(&:go_to_container_registry) - Page::Project::Registry::Show.perform do |registry| expect(registry).to have_registry_repository(project.name) diff --git a/qa/qa/specs/features/browser_ui/5_package/container_registry/self_managed/container_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/container_registry/self_managed/container_registry_spec.rb index d369ea7db3d3c78639a0a29a9a029b6bca7a83a6..04b125fc728382239a4f3e20762f691fd7158e9f 100644 --- a/qa/qa/specs/features/browser_ui/5_package/container_registry/self_managed/container_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/container_registry/self_managed/container_registry_spec.rb @@ -79,43 +79,36 @@ module QA end it "pushes image and deletes tag", :blocking, :registry, testcase: params[:testcase] do - Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do - create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [ - { - action: 'create', - file_path: '.gitlab-ci.yml', - content: <<~YAML - build: - image: "docker:24.0.1" - stage: build - services: - - name: "docker:24.0.1-dind" - command: ["--insecure-registry=gitlab.test:5050"] - variables: - IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG - script: - - docker login -u #{auth_user} -p #{auth_token} 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 + create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [ + { + action: 'create', + file_path: '.gitlab-ci.yml', + content: <<~YAML + build: + image: "docker:24.0.1" + stage: build + services: + - name: "docker:24.0.1-dind" + command: ["--insecure-registry=gitlab.test:5050"] + variables: + IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG + script: + - docker login -u #{auth_user} -p #{auth_token} gitlab.test:5050 + - docker build -t $IMAGE_TAG . + - docker push $IMAGE_TAG + tags: + - "runner-for-#{project.name}" + YAML + } + ]) + Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) + project.visit_job('build') 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.name) @@ -132,12 +125,11 @@ module QA :registry_tls, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347591' ) do - Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do - create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [ - { - action: 'create', - file_path: '.gitlab-ci.yml', - content: <<~YAML + create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [ + { + action: 'create', + file_path: '.gitlab-ci.yml', + content: <<~YAML build: image: "docker:24.0.1" stage: build @@ -159,27 +151,18 @@ module QA - 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 + YAML + } + ]) + Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) + project.visit_job('build') Page::Project::Job::Show.perform do |job| expect(job).to be_successful(timeout: 200) end - Support::Retrier.retry_until(max_duration: 500, sleep_interval: 10) do - project.pipelines.last[:status] == 'success' - end - + Flow::Pipeline.wait_for_latest_pipeline_to_have_status(project: project, status: 'success') Page::Project::Menu.perform(&:go_to_container_registry) - Page::Project::Registry::Show.perform do |registry| expect(registry).to have_registry_repository(project.name) diff --git a/qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb b/qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb index 6f29fbf2aeebcc74308f12b047e636e09543ff1e..084ca2e6904c3cd89aad4db6e1cf15d0207d2c1f 100644 --- a/qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/dependency_proxy/dependency_proxy_spec.rb @@ -30,14 +30,7 @@ module QA before do Flow::Login.sign_in - project.group.visit! - - Page::Group::Menu.perform(&:go_to_package_settings) - - Page::Group::Settings::PackageRegistries.perform do |index| - expect(index).to have_dependency_proxy_enabled - end end after do @@ -95,12 +88,16 @@ module QA end it "pulls an image using the dependency proxy", :blocking, testcase: params[:testcase] do - Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do - create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [ - { - action: 'create', - file_path: '.gitlab-ci.yml', - content: <<~YAML + Page::Group::Menu.perform(&:go_to_package_settings) + Page::Group::Settings::PackageRegistries.perform do |index| + expect(index).to have_dependency_proxy_enabled + end + + create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [ + { + action: 'create', + file_path: '.gitlab-ci.yml', + content: <<~YAML dependency-proxy-pull-test: image: "#{docker_client_version}" services: @@ -117,26 +114,19 @@ module QA - 'curl --head --header "Authorization: Bearer $TOKEN" "https://registry-1.docker.io/v2/ratelimitpreview/test/manifests/latest" 2>&1' tags: - "runner-for-#{project.name}" - YAML - } - ]) - end + YAML + } + ]) project.visit! - Flow::Pipeline.visit_latest_pipeline - - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.click_job('dependency-proxy-pull-test') - end - + Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) + project.visit_job('dependency-proxy-pull-test') Page::Project::Job::Show.perform do |job| expect(job).to be_successful(timeout: 800) end project.group.visit! - Page::Group::Menu.perform(&:go_to_dependency_proxy) - Page::Group::DependencyProxy.perform do |index| expect(index).to have_blob_count(/Contains [1-9]\d* blobs of images/) end diff --git a/qa/qa/specs/features/browser_ui/5_package/infrastructure_registry/terraform_module_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/infrastructure_registry/terraform_module_registry_spec.rb index ec0ceb02cc53e6f3d2b35803a6d5134d72e4eae5..b7123d5af20aa2c70fbc6bde59d155dc7cce7455 100644 --- a/qa/qa/specs/features/browser_ui/5_package/infrastructure_registry/terraform_module_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/infrastructure_registry/terraform_module_registry_spec.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true module QA - RSpec.describe 'Package', :requires_admin, product_group: :package_registry do + RSpec.describe 'Package', product_group: :package_registry do describe 'Terraform Module Registry', quarantine: { only: { job: 'airgapped' }, @@ -17,7 +17,7 @@ module QA project.name = 'terraform-module-test' project.group = group project.gitlab_repository_path = 'https://gitlab.com/mattkasa/terraform-module-test.git' - end + end.reload! end let(:runner) do @@ -34,7 +34,6 @@ module QA QA::Support::Helpers::ImportSource.enable('git') Flow::Login.sign_in - imported_project runner end @@ -45,24 +44,18 @@ module QA it 'publishes a module', :blocking, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/371583' do - Support::Retrier.retry_on_exception(max_attempts: 3, sleep_interval: 2) do - terraform_module_yaml = ERB.new( - read_fixture('package_managers/terraform', 'module_upload.yaml.erb') - ).result(binding) + terraform_module_yaml = ERB.new( + read_fixture('package_managers/terraform', 'module_upload.yaml.erb') + ).result(binding) - create(:commit, project: imported_project, commit_message: 'Add gitlab-ci.yaml file', actions: [ - { action: 'update', file_path: '.gitlab-ci.yml', content: terraform_module_yaml } - ]) - end + create(:commit, project: imported_project, commit_message: 'Add gitlab-ci.yaml file', actions: [ + { action: 'update', file_path: '.gitlab-ci.yml', content: terraform_module_yaml } + ]) create(:tag, project: imported_project, ref: imported_project.default_branch, name: '1.0.0') - Flow::Pipeline.visit_latest_pipeline - - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.click_job('upload') - end - + Flow::Pipeline.wait_for_pipeline_creation_via_api(project: imported_project) + imported_project.visit_job('upload') Page::Project::Job::Show.perform do |job| expect(job).to be_successful(timeout: 180) end diff --git a/qa/qa/specs/features/ee/browser_ui/5_package/dependency_proxy_sso_spec.rb b/qa/qa/specs/features/ee/browser_ui/5_package/dependency_proxy_sso_spec.rb index cb3f67d24b2a86c95727f6f5d98d8fb5c1b9257b..0260236ea1d928ab62972aea5baa06717a0e64d9 100644 --- a/qa/qa/specs/features/ee/browser_ui/5_package/dependency_proxy_sso_spec.rb +++ b/qa/qa/specs/features/ee/browser_ui/5_package/dependency_proxy_sso_spec.rb @@ -3,8 +3,6 @@ module QA RSpec.describe 'Package', :skip_live_env, :orchestrated, :group_saml, requires_admin: 'for various user admin functions' do describe 'Dependency Proxy Group SSO', product_group: :container_registry do - include Support::API - let!(:group) do Resource::Sandbox.fabricate! do |sandbox_group| sandbox_group.path = "saml_sso_group_with_dependency_proxy_#{SecureRandom.hex(8)}" @@ -54,15 +52,11 @@ module QA after do Flow::Saml.remove_saml_idp_service(saml_idp_service) - remove_user - group.remove_via_api! runner.remove_via_api! end it "pulls an image using the dependency proxy on a group enforced SSO", :blocking, testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347612' do - project.group.visit! - create(:commit, project: project, commit_message: 'Add .gitlab-ci.yml', actions: [ { action: 'create', @@ -89,22 +83,15 @@ module QA ]) project.visit! - Flow::Pipeline.visit_latest_pipeline - - Page::Project::Pipeline::Show.perform do |pipeline| - pipeline.click_job('dependency-proxy-pull-test') - end - + Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) + project.visit_job('dependency-proxy-pull-test') Page::Project::Job::Show.perform do |job| expect(job).to be_successful(timeout: 800) end Flow::Login.sign_in - project.group.visit! - Page::Group::Menu.perform(&:go_to_dependency_proxy) - Page::Group::DependencyProxy.perform do |index| expect(index).to have_blob_count(/Contains [1-9]\d* blobs of images/) end