Commit bab8c49d authored by Ramya Authappan's avatar Ramya Authappan

Merge branch 'ml-update-pull-mirroring-test' into 'master'

Update and quarantine pull mirroring test

See merge request gitlab-org/gitlab!80573
parents 83130de0 789cfadd
......@@ -87,20 +87,21 @@ module QA
end
def update(url)
row_index = find_repository_row_index url
row_index = find_repository_row_index(url)
within_element_by_index(:mirrored_repository_row, row_index) do
# When a repository is first mirrored, the update process might
# already be started, so the button is already "clicked"
click_element :update_now_button unless has_element? :updating_button
end
end
# Wait a few seconds for the sync to occur and then refresh the page
# so that 'last update' shows 'just now' or a period in seconds
sleep 5
def verify_update(url)
refresh
wait_until(max_duration: 180, sleep_interval: 1) do
row_index = find_repository_row_index(url)
wait_until(sleep_interval: 1) do
within_element_by_index(:mirrored_repository_row, row_index) do
last_update = find_element(:mirror_last_update_at_cell, wait: 0)
last_update.has_text?('just now') || last_update.has_text?('seconds')
......
......@@ -165,6 +165,14 @@ module QA
def transform_api_resource(api_resource)
api_resource
end
# Get api request url
#
# @param [String] path
# @return [String]
def request_url(path, **opts)
Runtime::API::Request.new(api_client, path, **opts).url
end
end
end
end
......@@ -5,6 +5,8 @@ module QA
class DeployKey < Base
attr_accessor :title, :key
attribute :id
attribute :md5_fingerprint do
Page::Project::Settings::Repository.perform do |setting|
setting.expand_deploy_keys do |key|
......@@ -34,6 +36,46 @@ module QA
end
end
end
def fabricate_via_api!
resource_web_url(api_get)
rescue ResourceNotFoundError
super
end
def resource_web_url(resource)
super
rescue ResourceURLMissingError
# this particular resource does not expose a web_url property
end
def api_get_path
"/projects/#{project.id}/deploy_keys/#{find_id}"
end
def api_post_path
"/projects/#{project.id}/deploy_keys"
end
def api_post_body
{
key: key,
title: title
}
end
private
def find_id
id
rescue NoValueError
found_key = auto_paginated_response(request_url("/projects/#{project.id}/deploy_keys", per_page: '100'))
.find { |keys| keys[:key].strip == @key.strip }
return found_key.fetch(:id) if found_key
raise ResourceNotFoundError
end
end
end
end
......@@ -407,14 +407,6 @@ module QA
Git::Location.new(api_resource[:http_url_to_repo])
api_resource
end
# Get api request url
#
# @param [String] path
# @return [String]
def request_url(path, **opts)
Runtime::API::Request.new(api_client, path, **opts).url
end
end
end
end
......
......@@ -10,7 +10,7 @@ module QA
deploy_key_title = 'deploy key title'
deploy_key_value = key.public_key
deploy_key = Resource::DeployKey.fabricate! do |resource|
deploy_key = Resource::DeployKey.fabricate_via_browser_ui! do |resource|
resource.title = deploy_key_title
resource.key = deploy_key_value
end
......
......@@ -25,7 +25,13 @@ module QA
target_project.visit!
end
it 'configures and syncs a (pull) mirrored repository', testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347736' do
it 'configures and syncs a (pull) mirrored repository',
testcase: 'https://gitlab.com/gitlab-org/gitlab/-/quality/test_cases/347736',
quarantine: {
only: { subdomain: :staging },
type: :test_environment,
issue: 'https://gitlab.com/gitlab-org/gitlab/-/issues/352706'
} do
# Configure the target project to pull from the source project
# And get the public key to be used as a deploy key
Page::Project::Menu.perform(&:go_to_repository_settings)
......@@ -41,7 +47,7 @@ module QA
end
# Add the public key to the source project as a deploy key
Resource::DeployKey.fabricate! do |deploy_key|
Resource::DeployKey.fabricate_via_api! do |deploy_key|
deploy_key.project = source.project
deploy_key.title = "pull mirror key #{Time.now.to_f}"
deploy_key.key = public_key
......@@ -52,7 +58,19 @@ module QA
Page::Project::Menu.perform(&:go_to_repository_settings)
Page::Project::Settings::Repository.perform do |settings|
settings.expand_mirroring_repositories do |mirror_settings|
mirror_settings.update source_project_uri # rubocop:disable Rails/SaveBang
mirror_settings.update(source_project_uri) # rubocop:disable Rails/SaveBang
# Use the API to wait until the update was successful (pull mirroring is treated as an import)
mirror_succeeded = mirror_settings.wait_until(reload: false, max_duration: 180, sleep_interval: 1, raise_on_failure: false) do
target_project.reload!
target_project.api_resource[:import_status] == "finished"
end
unless mirror_succeeded
raise "Mirroring failed with error: #{target_project.api_resource[:import_error]}"
end
mirror_settings.verify_update(source_project_uri)
end
end
......
......@@ -79,7 +79,7 @@ module QA
else
default
end
rescue QA::Resource::Base::NoValueError
rescue QA::Resource::Base::NoValueError, QA::Resource::Errors::ResourceNotFoundError
default
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