From 1c6b9de0bd7ed5605188a63b8ef3c756c0afe2f3 Mon Sep 17 00:00:00 2001 From: Andrejs Cunskis <acunskis@gitlab.com> Date: Thu, 14 Dec 2023 17:45:05 +0000 Subject: [PATCH] E2E: Increase attempts and sleep interval for paginated requests --- .../import/import_large_github_repo_spec.rb | 10 +++++----- .../gitlab_migration_large_project_spec.rb | 20 +++++++++---------- qa/qa/support/api.rb | 2 +- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/qa/qa/specs/features/api/1_manage/import/import_large_github_repo_spec.rb b/qa/qa/specs/features/api/1_manage/import/import_large_github_repo_spec.rb index e5c617738f0c..1b79c65efc33 100644 --- a/qa/qa/specs/features/api/1_manage/import/import_large_github_repo_spec.rb +++ b/qa/qa/specs/features/api/1_manage/import/import_large_github_repo_spec.rb @@ -45,7 +45,7 @@ module QA let(:logger) { Runtime::Logger.logger } let(:gitlab_address) { QA::Runtime::Scenario.gitlab_address.chomp("/") } let(:dummy_url) { "https://example.com" } # this is used to replace all dynamic urls in descriptions and comments - let(:api_request_params) { { auto_paginate: true, attempts: 2 } } + let(:api_request_params) { { auto_paginate: true, attempts: 3 } } let(:created_by_pattern) { /\*Created by: \S+\*\n\n/ } let(:suggestion_pattern) { /suggestion:-\d+\+\d+/ } @@ -536,7 +536,7 @@ def verify_comments_and_events(type, actual, expected) def gl_branches @gl_branches ||= begin logger.debug("= Fetching branches =") - imported_project.repository_branches(auto_paginate: true).map { |b| b[:name] } + imported_project.repository_branches(auto_paginate: true, attempts: 3).map { |b| b[:name] } end end @@ -546,7 +546,7 @@ def gl_branches def gl_commits @gl_commits ||= begin logger.debug("= Fetching commits =") - imported_project.commits(auto_paginate: true, attempts: 2).map { |c| c[:id] } + imported_project.commits(auto_paginate: true, attempts: 3).map { |c| c[:id] } end end @@ -556,7 +556,7 @@ def gl_commits def gl_labels @gl_labels ||= begin logger.debug("= Fetching labels =") - imported_project.labels(auto_paginate: true).map { |label| label.slice(:name, :color) } + imported_project.labels(auto_paginate: true, attempts: 3).map { |label| label.slice(:name, :color) } end end @@ -566,7 +566,7 @@ def gl_labels def gl_milestones @gl_milestones ||= begin logger.debug("= Fetching milestones =") - imported_project.milestones(auto_paginate: true).map { |ms| ms.slice(:title, :description) } + imported_project.milestones(auto_paginate: true, attempts: 3).map { |ms| ms.slice(:title, :description) } end end diff --git a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_large_project_spec.rb b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_large_project_spec.rb index 8761f0958b12..6426872e76dd 100644 --- a/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_large_project_spec.rb +++ b/qa/qa/specs/features/api/1_manage/migration/gitlab_migration_large_project_spec.rb @@ -85,16 +85,16 @@ module QA # Imported objects # - let(:imported_project) { imported_group.projects(auto_paginate: true).find { |project| project.name == gitlab_source_project }.reload! } - let(:branches) { imported_project.repository_branches(auto_paginate: true).map { |b| b[:name] } } - let(:commits) { imported_project.commits(auto_paginate: true).map { |c| c[:id] } } - let(:labels) { imported_project.labels(auto_paginate: true).map { |l| l.except(:id, :description_html) } } - let(:milestones) { imported_project.milestones(auto_paginate: true).map { |ms| ms.except(:id, :web_url, :project_id) } } + let(:imported_project) { imported_group.projects(auto_paginate: true, attempts: 3).find { |project| project.name == gitlab_source_project }.reload! } + let(:branches) { imported_project.repository_branches(auto_paginate: true, attempts: 3).map { |b| b[:name] } } + let(:commits) { imported_project.commits(auto_paginate: true, attempts: 3).map { |c| c[:id] } } + let(:labels) { imported_project.labels(auto_paginate: true, attempts: 3).map { |l| l.except(:id, :description_html) } } + let(:milestones) { imported_project.milestones(auto_paginate: true, attempts: 3).map { |ms| ms.except(:id, :web_url, :project_id) } } let(:mrs) { fetch_mrs(imported_project, api_client) } let(:issues) { fetch_issues(imported_project, api_client) } let(:pipelines) do imported_project - .pipelines(auto_paginate: true) + .pipelines(auto_paginate: true, attempts: 3) .sort_by { |pipeline| pipeline[:created_at] } .map { |pipeline| pipeline.except(:id, :web_url, :project_id) } end @@ -353,7 +353,7 @@ def verify_comments(type, actual, expected) # @param [Boolean] transform_urls # @return [Hash] def fetch_mrs(project, client, transform_urls: false) - imported_mrs = project.merge_requests(auto_paginate: true, attempts: 2) + imported_mrs = project.merge_requests(auto_paginate: true, attempts: 3) Parallel.map(imported_mrs, in_threads: api_parallel_threads) do |mr| resource = build(:merge_request, project: project, iid: mr[:iid], api_client: client) @@ -364,7 +364,7 @@ def fetch_mrs(project, client, transform_urls: false) body: sanitize_description(mr[:description], transform_urls) || '', state: mr[:state], comments: resource - .comments(auto_paginate: true, attempts: 2) + .comments(auto_paginate: true, attempts: 3) .map { |c| sanitize_comment(c[:body], transform_urls) } }] end.to_h @@ -377,7 +377,7 @@ def fetch_mrs(project, client, transform_urls: false) # @param [Boolean] transform_urls # @return [Hash] def fetch_issues(project, client, transform_urls: false) - imported_issues = project.issues(auto_paginate: true, attempts: 2) + imported_issues = project.issues(auto_paginate: true, attempts: 3) Parallel.map(imported_issues, in_threads: api_parallel_threads) do |issue| resource = build(:issue, project: project, iid: issue[:iid], api_client: client) @@ -388,7 +388,7 @@ def fetch_issues(project, client, transform_urls: false) state: issue[:state], body: sanitize_description(issue[:description], transform_urls) || '', comments: resource - .comments(auto_paginate: true, attempts: 2) + .comments(auto_paginate: true, attempts: 3) .map { |c| sanitize_comment(c[:body], transform_urls) } }] end.to_h diff --git a/qa/qa/support/api.rb b/qa/qa/support/api.rb index 2ffd4e5d7afc..6431511e6c40 100644 --- a/qa/qa/support/api.rb +++ b/qa/qa/support/api.rb @@ -159,7 +159,7 @@ def with_paginated_response_body(url, attempts: 0) loop do response = if attempts > 0 - Retrier.retry_on_exception(max_attempts: attempts, log: false) do + Retrier.retry_on_exception(max_attempts: attempts, log: false, sleep_interval: 1) do get(url).tap { |resp| not_ok_error.call(resp) if resp.code != HTTP_STATUS_OK } end else -- GitLab