Skip to content

Commit

Permalink
Fix occasionally failing tests (increase tolerance of timing checks)
Browse files Browse the repository at this point in the history
  • Loading branch information
adams85 committed Mar 25, 2024
1 parent 00af5e5 commit 398325c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/ConfigCat.Client.Tests/ConfigCatClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ public async Task Initialization_AutoPoll_WithMaxInitWaitTime_GetValueShouldWait

sw.Stop();

Assert.IsTrue(sw.Elapsed >= delay - TimeSpan.FromMilliseconds(10), $"Elapsed time: {sw.Elapsed}");
Assert.IsTrue(sw.Elapsed >= delay - TimeSpan.FromMilliseconds(50), $"Elapsed time: {sw.Elapsed}"); // 50ms for tolerance
Assert.IsTrue(sw.Elapsed <= delay + TimeSpan.FromMilliseconds(250), $"Elapsed time: {sw.Elapsed}"); // 250ms for tolerance
Assert.IsTrue(actualValue);
}
Expand Down Expand Up @@ -252,7 +252,7 @@ public async Task Initialization_AutoPoll_WithMaxInitWaitTime_GetValueShouldWait

sw.Stop();

Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(10), $"Elapsed time: {sw.Elapsed}");
Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(50), $"Elapsed time: {sw.Elapsed}"); // 50ms for tolerance
Assert.IsTrue(sw.Elapsed <= maxInitWaitTime + TimeSpan.FromMilliseconds(250), $"Elapsed time: {sw.Elapsed}"); // 250ms for tolerance

Assert.IsFalse(actualValue);
Expand Down Expand Up @@ -312,7 +312,7 @@ public async Task WaitForReadyAsync_AutoPoll_ShouldWaitForMaxInitWaitTime()

sw.Stop();

Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(10), $"Elapsed time: {sw.Elapsed}");
Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(50), $"Elapsed time: {sw.Elapsed}"); // 50ms for tolerance
Assert.IsTrue(sw.Elapsed <= maxInitWaitTime + TimeSpan.FromMilliseconds(250), $"Elapsed time: {sw.Elapsed}"); // 250ms for tolerance

Assert.AreEqual(ClientCacheState.NoFlagData, cacheState);
Expand Down Expand Up @@ -360,7 +360,7 @@ public async Task WaitForReadyAsync_AutoPoll_ShouldWaitForMaxInitWaitTimeAndRetu

sw.Stop();

Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(10), $"Elapsed time: {sw.Elapsed}");
Assert.IsTrue(sw.Elapsed >= maxInitWaitTime - TimeSpan.FromMilliseconds(50), $"Elapsed time: {sw.Elapsed}"); // 50ms for tolerance
Assert.IsTrue(sw.Elapsed <= maxInitWaitTime + TimeSpan.FromMilliseconds(250), $"Elapsed time: {sw.Elapsed}"); // 250ms for tolerance

Assert.AreEqual(ClientCacheState.HasCachedFlagDataOnly, cacheState);
Expand Down

0 comments on commit 398325c

Please sign in to comment.