diff options
Diffstat (limited to 'qa/qa/support/retrier.rb')
-rw-r--r-- | qa/qa/support/retrier.rb | 19 |
1 files changed, 19 insertions, 0 deletions
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 |