Skip to content

Commit 4ffbc92

Browse files
committed
Changed QueueHandler_WithThreads_Enqueue test to sleep a thread for 2 seconds instead of 1. This reduces the risk of thread reusage which could cause the distinct threads count to fail.
1 parent 053b2f0 commit 4ffbc92

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tests/CommunityToolkit.Datasync.Client.Test/Threading/QueueHandler_Tests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public async Task QueueHandler_WithThreads_Enqueue(int nThreads)
2323
{
2424
accId.Enqueue(el);
2525
accTh.Enqueue(Environment.CurrentManagedThreadId);
26-
Thread.Sleep(1000);
26+
Thread.Sleep(2000);
2727
return Task.CompletedTask;
2828
});
2929
DateTimeOffset startTime = DateTimeOffset.Now;
@@ -49,7 +49,7 @@ public async Task QueueHandler_WithThreads_Enqueue(int nThreads)
4949
accTh.AsEnumerable().Distinct().Should().HaveCount(nThreads);
5050
// This just makes sure that the amount of time is "of the right order of magnitude" since CI systems
5151
// are notoriously bad at correct timings. We just don't want it to be 10x the expected time.
52-
(endTime - startTime).TotalSeconds.Should().BeLessThanOrEqualTo((nElements / nThreads) + 5);
52+
(endTime - startTime).TotalSeconds.Should().BeLessThanOrEqualTo(2 * (nElements / nThreads) + 5);
5353
}
5454

5555
[Theory(Timeout = 30000)]

0 commit comments

Comments
 (0)