Commit 43a1ed9c authored by Tanya Pazitny's avatar Tanya Pazitny

Merge branch 'ml-add-e2e-test-repo-storage-change-status' into 'master'

Add new E2E test of the status of moving a repo

Closes gitlab-org/quality/team-tasks#446 and gitlab-org/quality/testcases#721

See merge request gitlab-org/gitlab!32819
parents c22f7b06 b84c4597
......@@ -43,6 +43,7 @@ module QA
module API
autoload :Client, 'qa/runtime/api/client'
autoload :RepositoryStorageMoves, 'qa/runtime/api/repository_storage_moves'
autoload :Request, 'qa/runtime/api/request'
end
......
......@@ -91,6 +91,10 @@ module QA
super
end
def has_file?(file_path)
repository_tree.any? { |file| file[:path] == file_path }
end
def api_get_path
"/projects/#{CGI.escape(path_with_namespace)}"
end
......@@ -115,6 +119,10 @@ module QA
"#{api_get_path}/repository/branches"
end
def api_repository_tree_path
"#{api_get_path}/repository/tree"
end
def api_pipelines_path
"#{api_get_path}/pipelines"
end
......@@ -155,11 +163,9 @@ module QA
raise ResourceUpdateFailedError, "Could not change repository storage to #{new_storage}. Request returned (#{response.code}): `#{response}`."
end
wait_until do
reload!
api_response[:repository_storage] == new_storage
end
wait_until(sleep_interval: 1) { Runtime::API::RepositoryStorageMoves.has_status?(self, 'finished') }
rescue Support::Repeater::RepeaterConditionExceededError
raise Runtime::API::RepositoryStorageMoves::RepositoryStorageMovesError, 'Timed out while waiting for the repository storage move to finish'
end
def import_status
......@@ -187,8 +193,11 @@ module QA
end
def repository_branches
response = get Runtime::API::Request.new(api_client, api_repository_branches_path).url
parse_body(response)
parse_body(get(Runtime::API::Request.new(api_client, api_repository_branches_path).url))
end
def repository_tree
parse_body(get(Runtime::API::Request.new(api_client, api_repository_tree_path).url))
end
def pipelines
......
# frozen_string_literal: true
module QA
module Runtime
module API
module RepositoryStorageMoves
extend self
extend Support::Api
RepositoryStorageMovesError = Class.new(RuntimeError)
def has_status?(project, status)
all.any? do |move|
move[:project][:path_with_namespace] == project.path_with_namespace &&
move[:state] == status &&
move[:destination_storage_name] == Env.additional_repository_storage
end
end
def all
Logger.debug('Getting repository storage moves')
parse_body(get(Request.new(api_client, '/project_repository_storage_moves').url))
end
private
def api_client
@api_client ||= Client.as_admin
end
end
end
end
end
# frozen_string_literal: true
module QA
context 'Create' do
describe 'Gitaly repository storage', :orchestrated, :repository_storage, :requires_admin do
let(:project) do
Resource::Project.fabricate_via_api! do |project|
project.name = 'repo-storage-status'
project.initialize_with_readme = true
end
end
it 'confirms a `finished` status after moving project repository storage' do
expect(project).to have_file('README.md')
project.change_repository_storage(QA::Runtime::Env.additional_repository_storage)
expect(Runtime::API::RepositoryStorageMoves).to have_status(project, 'finished')
Resource::Repository::ProjectPush.fabricate! do |push|
push.project = project
push.file_name = 'new_file'
push.file_content = '# This is a new file'
push.commit_message = 'Add new file'
push.new_branch = false
end
expect(project).to have_file('README.md')
expect(project).to have_file('new_file')
end
end
end
end
......@@ -7,8 +7,9 @@ module QA
module Repeater
DEFAULT_MAX_WAIT_TIME = 60
RetriesExceededError = Class.new(RuntimeError)
WaitExceededError = Class.new(RuntimeError)
RepeaterConditionExceededError = Class.new(RuntimeError)
RetriesExceededError = Class.new(RepeaterConditionExceededError)
WaitExceededError = Class.new(RepeaterConditionExceededError)
def repeat_until(max_attempts: nil, max_duration: nil, reload_page: nil, sleep_interval: 0, raise_on_failure: true, retry_on_exception: false, log: true)
attempts = 0
......
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