diff --git a/qa/qa/flow/pipeline.rb b/qa/qa/flow/pipeline.rb index 4114407d52c7e45dc6be069038e6cdbdb03ccea7..bd7e556ea9167c6e062b29b563e6cfc3533ad0e8 100644 --- a/qa/qa/flow/pipeline.rb +++ b/qa/qa/flow/pipeline.rb @@ -60,7 +60,7 @@ def wait_for_latest_pipeline_to_have_status(project:, status: nil, wait: 240) end end - def wait_for_latest_pipeline_to_start(project:, wait: 60) + def wait_for_latest_pipeline_to_start(project:, wait: 240) Runtime::Logger.info("Waiting for #{project.name}'s latest pipeline to start...") wait_for_latest_pipeline_to_have_status(project: project, status: 'running', wait: wait) end diff --git a/qa/qa/resource/base.rb b/qa/qa/resource/base.rb index fcb901e41f394c47d2caa64084cdc5c0a5cad38f..373ba93b9dc16d8eb8278b885df7a560e7cc0378 100644 --- a/qa/qa/resource/base.rb +++ b/qa/qa/resource/base.rb @@ -229,6 +229,15 @@ def wait_until(max_duration: 60, sleep_interval: 0.1, message: nil, &block) ) end + def retry_until(max_duration: 60, sleep_interval: 0.1, retry_on_exception: true, &block) + Support::Retrier.retry_until( + max_duration: max_duration, + sleep_interval: sleep_interval, + retry_on_exception: retry_on_exception, + &block + ) + end + # Object comparison # # @param [QA::Resource::Base] other diff --git a/qa/qa/resource/project.rb b/qa/qa/resource/project.rb index 287a241684c09581d5208d53156ca87eb063e382..9c8cb2651b9c1c46dc028d71b89dfef38ae483b2 100644 --- a/qa/qa/resource/project.rb +++ b/qa/qa/resource/project.rb @@ -412,7 +412,21 @@ def pipelines(auto_paginate: false, attempts: 0, **kwargs) end def latest_pipeline - parse_body(api_get_from(api_latest_pipeline_path)) + # Observing in https://gitlab.com/gitlab-org/gitlab/-/issues/481642#note_2081214771 + # Sometimes in either canary or staging-canary, + # GET latest pipeline immediately after 1st pipeline was created seems to cause 500 or 502 + # Adding a retry block with `retry_on_exception: true` to reduce flakiness + # + retry_until do + response = get(request_url(api_latest_pipeline_path)) + response.code == HTTP_STATUS_OK + rescue ResourceQueryError + raise( + "Could not GET project's latest pipeline. Request returned (#{response.code}): `#{response}`." + ) + end + + parse_body(get(request_url(api_latest_pipeline_path))) end def visit_latest_pipeline diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb index e08323c654f3ca1b760c54ed2ea84b9d2290e5a3..e1c3fac46fca0b7d045134016d2444fb3e4f5b06 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/composer_registry_spec.rb @@ -29,8 +29,8 @@ module QA { action: 'create', file_path: 'composer.json', content: composer_json } ]) + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) end after do diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb index 03782cad7e0cf6a103c9716f7457fd6e22a375c1..0b077ca6892e266e7cbf3388e8201d064c682cec 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/conan_repository_spec.rb @@ -44,8 +44,8 @@ module QA { action: 'create', file_path: '.gitlab-ci.yml', content: conan_yaml } ]) + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) project.visit_job('test_package') Page::Project::Job::Show.perform do |job| diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb index a669b51240dbceb04bb5b17836f718bf1ef6eeaa..ce7e50713ea01650dd32127e31dc8e2db529c536 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/generic_repository_spec.rb @@ -32,8 +32,8 @@ module QA ]) Flow::Login.sign_in + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) end after do diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/helm_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/helm_registry_spec.rb index e109c5cb3690c71c49a2a465595e85e28667033b..3edf45ff36dee0cb94d21913b6503a273f11489d 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/helm_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/helm_registry_spec.rb @@ -55,8 +55,9 @@ module QA { action: 'create', file_path: 'Chart.yaml', content: helm_chart_yaml } ]) + Flow::Login.sign_in + package_project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: package_project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: package_project) package_project.visit_job('deploy') Page::Project::Job::Show.perform do |job| @@ -81,8 +82,8 @@ module QA { action: 'create', file_path: '.gitlab-ci.yml', content: helm_install_yaml } ]) + client_project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: client_project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: client_project) client_project.visit_job('pull') Page::Project::Job::Show.perform do |job| diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb index fae2f03085a7a5581989c20634fd8c60f250fcc7..cf5d5eedcf022bd30af13356f97179ebc560968e 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_group_level_spec.rb @@ -74,8 +74,8 @@ module QA { action: 'create', file_path: 'settings.xml', content: settings_xml } ]) + package_project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: package_project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: package_project) package_project.visit_job('deploy') Page::Project::Job::Show.perform do |job| @@ -105,8 +105,8 @@ module QA { action: 'create', file_path: 'settings.xml', content: settings_xml } ]) + client_project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: client_project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: client_project) client_project.visit_job('install') Page::Project::Job::Show.perform do |job| diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb index 8cc0d1102b107ce2ff1e60dc2b486a23e6f5129e..da1b40cf2a49ef78ea30bcccacee388c86a1b859 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven/maven_project_level_spec.rb @@ -92,8 +92,8 @@ module QA { action: 'create', file_path: 'settings.xml', content: settings_xml } ]) + package_project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: package_project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: package_project) package_project.visit_job('deploy-and-install') Page::Project::Job::Show.perform do |job| diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven_gradle_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven_gradle_repository_spec.rb index fa9859144d1d4a9fe174291a12779ca898719c3d..7f2dd7b35dc6ab7bbd9189ffaa0c4b2494b9b6eb 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/maven_gradle_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/maven_gradle_repository_spec.rb @@ -81,8 +81,8 @@ module QA { action: 'create', file_path: 'build.gradle', content: build_gradle } ]) + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) project.visit_job('publish') Page::Project::Job::Show.perform do |job| diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_group_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_group_level_spec.rb index 674b5ebaca86b22c0edfc8d20439dbabe366a8be..d589a0a7245fad0504390f6a49d7f921d8414931 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_group_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_group_level_spec.rb @@ -86,8 +86,8 @@ module QA } ]) + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) project.visit_job('deploy') Page::Project::Job::Show.perform do |job| @@ -105,8 +105,8 @@ module QA } ]) + another_project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: another_project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: another_project) another_project.visit_job('install') Page::Project::Job::Show.perform do |job| diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_instance_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_instance_level_spec.rb index 44805c86c4497fc05ff82d77525c7400949f5b54..f0ef8eeaef843a7775916214ef9b56cd6bb2fc6a 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_instance_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_instance_level_spec.rb @@ -86,8 +86,8 @@ module QA } ]) + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) project.visit_job('deploy') Page::Project::Job::Show.perform do |job| @@ -101,8 +101,8 @@ module QA { action: 'create', file_path: '.gitlab-ci.yml', content: npm_install_yaml } ]) + another_project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: another_project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: another_project) another_project.visit_job('install') Page::Project::Job::Show.perform do |job| diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_project_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_project_level_spec.rb index 63b16469833f7a00643b61ad443cb4ecf709603f..f3332f7b06a74b0ebc7e88d0d7f4226b927280dc 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_project_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/npm/npm_project_level_spec.rb @@ -73,8 +73,8 @@ module QA { action: 'create', file_path: 'package.json', content: package_json } ]) + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) project.visit_job('deploy') Page::Project::Job::Show.perform do |job| diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb index 564076fa1b2572ba0828f66ad9f4231e43559e0d..f4da9b0e438b9bc9d8cd9e05efe5a4f3e72f3a8c 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_group_level_spec.rb @@ -105,8 +105,8 @@ module QA { action: 'update', file_path: '.gitlab-ci.yml', content: nuget_upload_yaml } ]) + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project, size: 2) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) project.visit_job('deploy') Page::Project::Job::Show.perform do |job| @@ -132,8 +132,8 @@ module QA { action: 'update', file_path: '.gitlab-ci.yml', content: nuget_install_yaml } ]) + another_project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: another_project, size: 2) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: another_project) another_project.visit_job('install') Page::Project::Job::Show.perform do |job| diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_project_level_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_project_level_spec.rb index be8a45b587f0729d408cea0d990d6aec27450230..fe7a175a0493730ddce39a3c757249ab16984cb2 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_project_level_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/nuget/nuget_project_level_spec.rb @@ -133,8 +133,8 @@ module QA } ]) + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project, size: 2) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) project.visit_job('deploy') Page::Project::Job::Show.perform do |job| diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/pypi_repository_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/pypi_repository_spec.rb index d14a1223565c5760205972bb41a52e68c51956cd..2ef2c8d30465cacf7702eb8dc5ca01b327e9d6a0 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/pypi_repository_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/pypi_repository_spec.rb @@ -46,8 +46,8 @@ module QA } ]) + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) end after do diff --git a/qa/qa/specs/features/browser_ui/5_package/package_registry/rubygems_registry_spec.rb b/qa/qa/specs/features/browser_ui/5_package/package_registry/rubygems_registry_spec.rb index 90909c5da35962fae5a1325363a4df4075a05922..d08451077e29a2484d93a20ebb810fca0d7cd0f9 100644 --- a/qa/qa/specs/features/browser_ui/5_package/package_registry/rubygems_registry_spec.rb +++ b/qa/qa/specs/features/browser_ui/5_package/package_registry/rubygems_registry_spec.rb @@ -64,8 +64,8 @@ def self.hi } ]) + project.visit! Flow::Pipeline.wait_for_pipeline_creation_via_api(project: project) - Flow::Pipeline.wait_for_latest_pipeline_to_start(project: project) project.visit_job('test_package') Page::Project::Job::Show.perform do |job|