Closed maaex closed 11 months ago
There currently seems to be no timeout on wait strategies leading to the possibility of a test getting stuck in an endless wait.
You can pass a cancellation token to the container's start method like this:
I began working on improving the wait strategy API and adding more convenient features some time ago, but I haven't had the time to finalize and review it (refactor-wait-strategy-api). This issue is related to https://github.com/testcontainers/testcontainers-dotnet/issues/827. I would prefer to continue the discussion in this issue to maintain clarity and avoid losing track.
You can pass a cancellation token to the container's start method like this:
Thanks, I didn't realize this existed. That will be enough to solve the issue in my case.
Problem
There currently seems to be no timeout on wait strategies leading to the possibility of a test getting stuck in an endless wait.
Solution
The
WaitStrategy.WaitUntilAsync
method already has aTimeout
argument. Currently the call to it is hardcoded toTimeout.InfiniteTimeSpan
. I propose making it configurable for the user, possibly by adding a Timeout property to theIWaitUntil
interface.Benefit
This would give the user a fail-safe by allowing configurable timeouts WaitStrategies
Alternatives
One alternative could be to change the current WaitStrategy from Infinite to some long number, though I think its hard to find a good number here due to the numerous use cases.
Another alternative could be to rely on the testing frameworks' timeouts.
Would you like to help contributing this enhancement?
Yes