Commit e16f224e authored by Sanad Liaquat's avatar Sanad Liaquat

Retry sign out if unsuccessful

Also extract retry_until into qa/qa/support/retrier.rb
parent bf172b11
......@@ -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)
......
# frozen_string_literal: true
require 'logger'
require 'forwardable'
module QA
module Runtime
......
......@@ -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|
......
......@@ -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
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment