-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Internal Code
-
Fully Compatible
-
ALL
-
v5.0
-
Service Arch 2021-06-14, Service Arch 2021-06-28
-
124
These two tests that AsyncTryUntilWithDelay loops can be canceled by a CancellationToken should be split into four tests that use barriers to specify exactly when cancelSource.cancel() is called with respect to the execution of the loop.
E.g. AsyncTryUntilWithBackoffCanBeCanceled should be changed to AsyncTryUntilWithBackoffCanBeCanceledAfterLoopIsDoneExecuting and AsyncTryUntilWithBackoffCanBeCanceledWhileLoopIsExecuting. Example code for the former:
TEST_F(AsyncTryUntilTest, AsyncTryUntilWithBackoffCanBeCanceledAfterLoopIsDoneExecuting) { CancellationSource cancelSource; unittest::Barrier barrier{2}; auto resultFut = AsyncTry([] {}) .until([&](Status) { barrier.countDownAndWait(); return false; }) .withBackoffBetweenIterations(TestBackoff{Seconds(10000000)}) .on(executor(), cancelSource.token()); barrier.countDownAndWait(); cancelSource.cancel(); ASSERT_EQ(resultFut.getNoThrow(), kCanceledStatus); }
This will help tease out more possible bugs in the implementation.