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.rb34
1 files changed, 7 insertions, 27 deletions
diff --git a/qa/qa/support/retrier.rb b/qa/qa/support/retrier.rb
index aa568d633fc..aa36bf5922e 100644
--- a/qa/qa/support/retrier.rb
+++ b/qa/qa/support/retrier.rb
@@ -7,21 +7,15 @@ module QA
module_function
- def retry_on_exception(max_attempts: 3, reload_page: nil, sleep_interval: 0.5, log: true)
- if log
- msg = ["with retry_on_exception: max_attempts: #{max_attempts}"]
- msg << "reload_page: #{reload_page}" if reload_page
- msg << "sleep_interval: #{sleep_interval}"
- QA::Runtime::Logger.debug(msg.join('; '))
- end
-
+ def retry_on_exception(max_attempts: 3, reload_page: nil, sleep_interval: 0.5, log: true, message: nil)
result = nil
repeat_until(
max_attempts: max_attempts,
reload_page: reload_page,
sleep_interval: sleep_interval,
retry_on_exception: true,
- log: log
+ log: log,
+ message: message
) do
result = yield
@@ -29,7 +23,6 @@ module QA
# We set it to `true` so that it doesn't repeat if there's no exception
true
end
- QA::Runtime::Logger.debug("ended retry_on_exception") if log
result
end
@@ -41,25 +34,12 @@ module QA
sleep_interval: 0,
raise_on_failure: true,
retry_on_exception: false,
- log: true
+ log: true,
+ message: nil
)
# For backwards-compatibility
max_attempts = 3 if max_attempts.nil? && max_duration.nil?
- if log
- start_msg = ["with retry_until:"]
- start_msg << "max_attempts: #{max_attempts};" if max_attempts
- start_msg << "max_duration: #{max_duration};" if max_duration
- start_msg.push(*[
- "reload_page: #{reload_page};",
- "sleep_interval: #{sleep_interval};",
- "raise_on_failure: #{raise_on_failure};",
- "retry_on_exception: #{retry_on_exception}"
- ])
-
- QA::Runtime::Logger.debug(start_msg.join(' '))
- end
-
result = nil
repeat_until(
max_attempts: max_attempts,
@@ -68,11 +48,11 @@ module QA
sleep_interval: sleep_interval,
raise_on_failure: raise_on_failure,
retry_on_exception: retry_on_exception,
- log: log
+ log: log,
+ message: message
) do
result = yield
end
- QA::Runtime::Logger.debug("ended retry_until") if log
result
end