diff options
author | Sanad Liaquat <sliaquat@gitlab.com> | 2019-07-08 15:48:33 +0500 |
---|---|---|
committer | Sanad Liaquat <sliaquat@gitlab.com> | 2019-07-09 10:26:32 +0500 |
commit | e16f224ee9628e91425c6fa9bb19bfaeb5aa1af0 (patch) | |
tree | d54451193b32e7a03f7187dae06e60a74a56dd20 | |
parent | bf172b115c206cb6ed6c2b271fad600f1548b43c (diff) | |
download | gitlab-ce-e16f224ee9628e91425c6fa9bb19bfaeb5aa1af0.tar.gz |
Retry sign out if unsuccessful
Also extract retry_until into qa/qa/support/retrier.rb
-rw-r--r-- | qa/qa/page/base.rb | 15 | ||||
-rw-r--r-- | qa/qa/runtime/logger.rb | 1 | ||||
-rw-r--r-- | qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb | 6 | ||||
-rw-r--r-- | qa/qa/support/retrier.rb | 19 |
4 files changed, 27 insertions, 14 deletions
diff --git a/qa/qa/page/base.rb b/qa/qa/page/base.rb index d0fe2987b0a..130e5e33ab4 100644 --- a/qa/qa/page/base.rb +++ b/qa/qa/page/base.rb @@ -25,19 +25,10 @@ module QA end end - def retry_until(max_attempts: 3, reload: false) - attempts = 0 - - while attempts < max_attempts - result = yield - return result if result - - refresh if reload - - attempts += 1 + def retry_until(max_attempts: 3, reload: false, sleep_interval: 0) + QA::Support::Retrier.retry_until(max_attempts: max_attempts, reload: reload, sleep_interval: sleep_interval) do + yield end - - false end def retry_on_exception(max_attempts: 3, reload: false, sleep_interval: 0.5) diff --git a/qa/qa/runtime/logger.rb b/qa/qa/runtime/logger.rb index bd5c4fe5bf5..7f73f1bd01b 100644 --- a/qa/qa/runtime/logger.rb +++ b/qa/qa/runtime/logger.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require 'logger' +require 'forwardable' module QA module Runtime diff --git a/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb b/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb index cf225a639b6..a6bc6d2077c 100644 --- a/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb +++ b/qa/qa/specs/features/browser_ui/1_manage/login/log_in_spec.rb @@ -11,8 +11,10 @@ module QA expect(menu).to have_personal_area end - Page::Main::Menu.perform do |menu| - menu.sign_out + Support::Retrier.retry_until(reload: false, sleep_interval: 1.0) do + Page::Main::Menu.perform(&:sign_out) + + Page::Main::Login.perform(&:has_sign_in_tab?) end Page::Main::Login.perform do |form| diff --git a/qa/qa/support/retrier.rb b/qa/qa/support/retrier.rb index 8be4e9f5365..230cec8f8d2 100644 --- a/qa/qa/support/retrier.rb +++ b/qa/qa/support/retrier.rb @@ -23,6 +23,25 @@ module QA raise end end + + def retry_until(max_attempts: 3, reload: false, sleep_interval: 0) + QA::Runtime::Logger.debug("with retry_until: max_attempts #{max_attempts}; sleep_interval #{sleep_interval}; reload:#{reload}") + attempts = 0 + + while attempts < max_attempts + QA::Runtime::Logger.debug("Attempt number #{attempts + 1}") + result = yield + return result if result + + sleep sleep_interval + + refresh if reload + + attempts += 1 + end + + false + end end end end |