Closed saurla closed 5 months ago
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 52.21%. Comparing base (
60689c9
) to head (79046fe
).
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
thanks @saurla for the improvement, please check if there is a using missing for the CancellationToken to fix the build.
Sure, my bad. I had some Thread.Sleep in my code for testing purposes so I thought the using was just for that. I have now committed the missing using.
Made tests more robust by using GetConsumingEnumerable which blocks indefinitely.
Proposed changes
These changes aim to make the NodeStateCollectionConcurrencyTests to not randomly fail in the CI build.
Related Issues
Types of changes
Checklist
Further comments
I'm not 100% sure that this fixes the flaky CI builds since I was not able to reproduce the issue without modifying the test code. My assumption is that the test fails because I was calling TryTake on the BlockingCollection with timeout of 1 second. Maybe in some cases in the CI system there is some slowness that causes the other Task which is adding items to the collection to take more than 1 second. In this case the TryTake returns false and while loop is exited and then the items from the BlockingCollection are never removed.
I was able to reproduce the issue by adding a 1 second Thread.Sleep at the begin of the Task that adds items to the collection. I fixed this issue by using GetConsumingEnumerable instead of TryTake. The GetConsumingEnumerable block indefinitely so there is no danger of some slowness to fail the build. Since I'm using indefinite blocking I added timeout to each of the tests so that they don't take too long in case something goes wrong in the test.