summaryrefslogtreecommitdiff
path: root/qa/qa/support/retrier.rb
diff options
context:
space:
mode:
Diffstat (limited to 'qa/qa/support/retrier.rb')
-rw-r--r--qa/qa/support/retrier.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/qa/qa/support/retrier.rb b/qa/qa/support/retrier.rb
index 8be4e9f5365..720f1d17037 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_page: nil, sleep_interval: 0)
+ QA::Runtime::Logger.debug("with retry_until: max_attempts #{max_attempts}; sleep_interval #{sleep_interval}; reload_page:#{reload_page}")
+ attempts = 0
+
+ while attempts < max_attempts
+ QA::Runtime::Logger.debug("Attempt number #{attempts + 1}")
+ result = yield
+ return result if result
+
+ sleep sleep_interval
+
+ reload_page.refresh if reload_page
+
+ attempts += 1
+ end
+
+ false
+ end
end
end
end