From 291c06dcabe2b7ed5471eb8ce901ae1af9a0d588 Mon Sep 17 00:00:00 2001 From: Mark Lapierre <mlapierre@gitlab.com> Date: Tue, 11 Jun 2019 08:48:33 +1000 Subject: [PATCH] DRY exception handling Use `retry_on_exception` instead of duplicating code --- qa/qa/ee/strategy.rb | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/qa/qa/ee/strategy.rb b/qa/qa/ee/strategy.rb index 477e7fdd89e..296f163e72d 100644 --- a/qa/qa/ee/strategy.rb +++ b/qa/qa/ee/strategy.rb @@ -10,19 +10,10 @@ module QA end def perform_before_hooks - begin - retries ||= 0 - - # The login page could take some time to load the first time it is visited. - # We visit the login page and wait for it to properly load only once before the tests. + # The login page could take some time to load the first time it is visited. + # We visit the login page and wait for it to properly load only once before the tests. + QA::Support::Retrier.retry_on_exception do QA::Runtime::Browser.visit(:gitlab, QA::Page::Main::Login) - rescue QA::Page::Validatable::PageValidationError - if (retries += 1) < 3 - QA::Runtime::Logger.warn("The login page did not appear as expected. Retrying... (attempt ##{retries})") - retry - end - - raise end return unless ENV['EE_LICENSE'] -- 2.30.9