Commit 46074cc3 authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'clean-registry-images-from-test' into 'master'

Delete the registry repository via API

See merge request gitlab-org/gitlab!55175
parents b9662918 0b214971
......@@ -95,6 +95,7 @@ module QA
autoload :Visibility, 'qa/resource/visibility'
autoload :ProjectSnippet, 'qa/resource/project_snippet'
autoload :Design, 'qa/resource/design'
autoload :RegistryRepository, 'qa/resource/registry_repository'
module KubernetesCluster
autoload :Base, 'qa/resource/kubernetes_cluster/base'
......
......@@ -13,7 +13,7 @@ module QA
element :tag_delete_button
end
def has_image_repository?(name)
def has_registry_repository?(name)
find('a[data-testid="details-link"]', text: name)
end
......
......@@ -151,6 +151,10 @@ module QA
"#{api_get_path}/runners"
end
def api_registry_repositories_path
"#{api_get_path}/registry/repositories"
end
def api_commits_path
"#{api_get_path}/repository/commits"
end
......@@ -256,6 +260,12 @@ module QA
parse_body(response)
end
def registry_repositories
response = get Runtime::API::Request.new(api_client, "#{api_registry_repositories_path}").url
parse_body(response)
end
def repository_branches
parse_body(get(Runtime::API::Request.new(api_client, api_repository_branches_path).url))
end
......
# frozen_string_literal: true
require 'securerandom'
module QA
module Resource
class RegistryRepository < Base
attr_accessor :name,
:repository_id
attribute :project do
Project.fabricate_via_api! do |resource|
resource.name = 'project-with-registry'
resource.description = 'Project with Registry'
end
end
def initialize
@name = project.path_with_namespace
@repository_id = nil
end
def fabricate!
end
def fabricate_via_api!
resource_web_url(api_get)
rescue ResourceNotFoundError
super
end
def remove_via_api!
registry_repositories = project.registry_repositories
if registry_repositories && !registry_repositories.empty?
this_registry_repository = registry_repositories.find { |registry_repository| registry_repository[:path] == name }
@repository_id = this_registry_repository[:id]
QA::Runtime::Logger.debug("Deleting registry '#{name}'")
super
end
end
def api_delete_path
"/projects/#{project.id}/registry/repositories/#{@repository_id}"
end
def api_get_path
"/projects/#{project.id}/registry/repositories"
end
end
end
end
......@@ -10,6 +10,13 @@ module QA
end
end
let(:registry_repository) do
Resource::RegistryRepository.fabricate! do |repository|
repository.name = "#{project.path_with_namespace}"
repository.project = project
end
end
let!(:gitlab_ci_yaml) do
<<~YAML
build:
......@@ -26,6 +33,10 @@ module QA
YAML
end
after do
registry_repository&.remove_via_api!
end
it 'pushes project image to the container registry and deletes tag', testcase: 'https://gitlab.com/gitlab-org/quality/testcases/-/issues/1699' do
Flow::Login.sign_in
project.visit!
......@@ -52,9 +63,9 @@ module QA
Page::Project::Menu.perform(&:go_to_container_registry)
Page::Project::Registry::Show.perform do |registry|
expect(registry).to have_image_repository(project.path_with_namespace)
expect(registry).to have_registry_repository(registry_repository.name)
registry.click_on_image(project.path_with_namespace)
registry.click_on_image(registry_repository.name)
expect(registry).to have_tag('master')
registry.click_delete
......
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