summaryrefslogtreecommitdiff
path: root/qa/qa/resource
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/resource')
-rw-r--r--qa/qa/resource/bulk_import_group.rb16
-rw-r--r--qa/qa/resource/project.rb40
-rw-r--r--qa/qa/resource/runner.rb41
3 files changed, 70 insertions, 27 deletions
diff --git a/qa/qa/resource/bulk_import_group.rb b/qa/qa/resource/bulk_import_group.rb
index a22529152e1..31db8ae4cc6 100644
--- a/qa/qa/resource/bulk_import_group.rb
+++ b/qa/qa/resource/bulk_import_group.rb
@@ -7,10 +7,14 @@ module QA
:destination_group,
:import_id
- attribute :access_token do
+ attribute :import_access_token do
api_client.personal_access_token
end
+ attribute :gitlab_address do
+ QA::Runtime::Scenario.gitlab_address
+ end
+
# In most cases we will want to set path the same as source group
# but it can be set to a custom name as well when imported via API
attribute :destination_group_path do
@@ -19,18 +23,16 @@ module QA
# Can't define path as attribue since @path is set in base class initializer
alias_method :path, :destination_group_path
- delegate :gitlab_address, to: 'QA::Runtime::Scenario'
-
- def fabricate_via_browser_ui!
+ def fabricate!
Page::Main::Menu.perform(&:go_to_create_group)
Page::Group::New.perform do |group|
group.switch_to_import_tab
- group.connect_gitlab_instance(gitlab_address, api_client.personal_access_token)
+ group.connect_gitlab_instance(gitlab_address, import_access_token)
end
Page::Group::BulkImport.perform do |import_page|
- import_page.import_group(path, sandbox.path)
+ import_page.import_group(destination_group_path, sandbox.full_path)
end
reload!
@@ -49,7 +51,7 @@ module QA
{
configuration: {
url: gitlab_address,
- access_token: access_token
+ access_token: import_access_token
},
entities: [
{
diff --git a/qa/qa/resource/project.rb b/qa/qa/resource/project.rb
index 740a8920cf2..dba3eb2e219 100644
--- a/qa/qa/resource/project.rb
+++ b/qa/qa/resource/project.rb
@@ -90,7 +90,12 @@ module QA
Page::Project::New.perform(&:click_blank_project_link)
Page::Project::New.perform do |new_page|
- new_page.choose_test_namespace unless @personal_namespace
+ if @personal_namespace
+ new_page.choose_namespace(@personal_namespace)
+ else
+ new_page.choose_test_namespace
+ end
+
new_page.choose_name(@name)
new_page.add_description(@description)
new_page.set_visibility(@visibility)
@@ -105,7 +110,16 @@ module QA
def fabricate_via_api!
resource_web_url(api_get)
rescue ResourceNotFoundError
- super
+ response = super
+
+ # If a project is being imported, wait until it completes before we let the test continue.
+ # Otherwise we see Git repository errors
+ # See https://gitlab.com/gitlab-org/gitlab/-/issues/356101
+ Support::Retrier.retry_until(max_duration: 60, sleep_interval: 5) do
+ %w[none finished].include?(reload!.api_resource[:import_status])
+ end
+
+ response
end
def api_get_path
@@ -295,13 +309,6 @@ module QA
merge_requests.find { |mr| mr[:title] == title }
end
- def runners(tag_list: nil)
- url = tag_list ? "#{api_runners_path}?tag_list=#{tag_list.compact.join(',')}" : api_runners_path
- response = get(request_url(url, per_page: '100'))
-
- parse_body(response)
- end
-
def registry_repositories
response = get(request_url(api_registry_repositories_path))
parse_body(response)
@@ -336,16 +343,17 @@ module QA
parse_body(response)
end
- def pipelines
- response = get(request_url(api_pipelines_path))
- parse_body(response)
- end
-
def pipeline_schedules
response = get(request_url(api_pipeline_schedules_path))
parse_body(response)
end
+ def pipelines(auto_paginate: false, attempts: 0)
+ return parse_body(api_get_from(api_pipelines_path)) unless auto_paginate
+
+ auto_paginated_response(request_url(api_pipelines_path, per_page: '100'), attempts: attempts)
+ end
+
def issues(auto_paginate: false, attempts: 0)
return parse_body(api_get_from(api_issues_path)) unless auto_paginate
@@ -380,9 +388,7 @@ module QA
api_resource[:import_status] == "finished"
end
- unless mirror_succeeded
- raise "Mirroring failed with error: #{api_resource[:import_error]}"
- end
+ raise "Mirroring failed with error: #{api_resource[:import_error]}" unless mirror_succeeded
end
def remove_via_api!
diff --git a/qa/qa/resource/runner.rb b/qa/qa/resource/runner.rb
index 9c5c9992442..c014563671d 100644
--- a/qa/qa/resource/runner.rb
+++ b/qa/qa/resource/runner.rb
@@ -31,7 +31,7 @@ module QA
end
def fabricate_via_api!
- Service::DockerRun::GitlabRunner.new(name).tap do |runner|
+ @docker_container = Service::DockerRun::GitlabRunner.new(name).tap do |runner|
runner.pull
runner.token = @token ||= project.runners_token
runner.address = Runtime::Scenario.gitlab_address
@@ -46,12 +46,22 @@ module QA
end
def remove_via_api!
- runners = project.runners(tag_list: @tags)
+ runners = list_of_runners(tag_list: @tags)
- return if runners.blank?
+ # If we have no runners, print the logs from the runner docker container in case they show why it isn't running.
+ if runners.blank?
+ dump_logs
+
+ return
+ end
this_runner = runners.find { |runner| runner[:description] == name }
+
+ # As above, but now we should have a specific runner. If not, print the logs from the runner docker container
+ # to see if we can find out why the runner isn't running.
unless this_runner
+ dump_logs
+
raise "Project #{project.path_with_namespace} does not have a runner with a description matching #{name} #{"or tags #{@tags}" if @tags&.any?}. Runners available: #{runners}"
end
@@ -62,6 +72,20 @@ module QA
Service::DockerRun::GitlabRunner.new(name).remove!
end
+ def list_of_runners(tag_list: nil)
+ url = tag_list ? "#{api_post_path}?tag_list=#{tag_list.compact.join(',')}" : api_post_path
+ response = get(request_url(url, per_page: '100'))
+
+ # Capturing 500 error code responses to log this issue better. We can consider cleaning it up once https://gitlab.com/gitlab-org/gitlab/-/issues/331753 is addressed.
+ raise "Response returned a #{response.code} error code. #{response.body}" if response.code == Support::API::HTTP_STATUS_SERVER_ERROR
+
+ parse_body(response)
+ end
+
+ def reload!
+ super if method(:running?).super_method.call
+ end
+
def api_delete_path
"/runners/#{id}"
end
@@ -70,10 +94,21 @@ module QA
end
def api_post_path
+ "/runners"
end
def api_post_body
end
+
+ private
+
+ def dump_logs
+ if @docker_container.running?
+ @docker_container.logs { |line| QA::Runtime::Logger.debug(line) }
+ else
+ QA::Runtime::Logger.debug("No runner container found named #{name}")
+ end
+ end
end
end
end