Merge pull request #14270 from Ayanda-D/await-condition-ignoring-exceptions
Trigger a 4.2.x alpha release build / trigger_alpha_build (push) Waiting to run
Details
Test (make) / Build and Xref (1.18, 26) (push) Waiting to run
Details
Test (make) / Build and Xref (1.18, 27) (push) Waiting to run
Details
Test (make) / Build and Xref (1.18, 28) (push) Waiting to run
Details
Test (make) / Test (1.18, 28, khepri) (push) Waiting to run
Details
Test (make) / Test (1.18, 28, mnesia) (push) Waiting to run
Details
Test (make) / Test mixed clusters (1.18, 28, khepri) (push) Waiting to run
Details
Test (make) / Test mixed clusters (1.18, 28, mnesia) (push) Waiting to run
Details
Test (make) / Type check (1.18, 28) (push) Waiting to run
Details
Trigger a 4.2.x alpha release build / trigger_alpha_build (push) Waiting to run
Details
Test (make) / Build and Xref (1.18, 26) (push) Waiting to run
Details
Test (make) / Build and Xref (1.18, 27) (push) Waiting to run
Details
Test (make) / Build and Xref (1.18, 28) (push) Waiting to run
Details
Test (make) / Test (1.18, 28, khepri) (push) Waiting to run
Details
Test (make) / Test (1.18, 28, mnesia) (push) Waiting to run
Details
Test (make) / Test mixed clusters (1.18, 28, khepri) (push) Waiting to run
Details
Test (make) / Test mixed clusters (1.18, 28, mnesia) (push) Waiting to run
Details
Test (make) / Type check (1.18, 28) (push) Waiting to run
Details
Introduce rabbit_ct_helpers:await_condition_* helpers which ignore exceptions
This commit is contained in:
commit
8c8a2e92d2
|
@ -55,6 +55,10 @@
|
|||
await_condition/2,
|
||||
await_condition_with_retries/2,
|
||||
|
||||
await_condition_ignoring_exceptions/1,
|
||||
await_condition_ignoring_exceptions/2,
|
||||
await_condition_with_retries_ignoring_exceptions/2,
|
||||
|
||||
eventually/1, eventually/3,
|
||||
consistently/1, consistently/3,
|
||||
|
||||
|
@ -1138,6 +1142,28 @@ await_condition_with_retries(ConditionFun, RetriesLeft) ->
|
|||
ok
|
||||
end.
|
||||
|
||||
await_condition_ignoring_exceptions(ConditionFun) ->
|
||||
await_condition_ignoring_exceptions(ConditionFun, 10_000).
|
||||
|
||||
await_condition_ignoring_exceptions(ConditionFun, Timeout) ->
|
||||
Retries = ceil(Timeout / 50),
|
||||
await_condition_with_retries_ignoring_exceptions(ConditionFun, Retries).
|
||||
|
||||
await_condition_with_retries_ignoring_exceptions(_ConditionFun, 0) ->
|
||||
ct:fail("Condition did not materialize in the expected period of time");
|
||||
await_condition_with_retries_ignoring_exceptions(ConditionFun, RetriesLeft) ->
|
||||
try ConditionFun() of
|
||||
false ->
|
||||
timer:sleep(50),
|
||||
await_condition_with_retries_ignoring_exceptions(ConditionFun, RetriesLeft - 1);
|
||||
true ->
|
||||
ok
|
||||
catch
|
||||
_:_ ->
|
||||
timer:sleep(50),
|
||||
await_condition_with_retries_ignoring_exceptions(ConditionFun, RetriesLeft - 1)
|
||||
end.
|
||||
|
||||
%% Pass in any EUnit test object. Example:
|
||||
%% eventually(?_assertEqual(1, Actual))
|
||||
eventually({Line, Assertion} = TestObj)
|
||||
|
|
Loading…
Reference in New Issue