Skip to content

Commit

Permalink
Make timing and statistics tests less flaky (DataDog#559)
Browse files Browse the repository at this point in the history
  • Loading branch information
colin-higgins authored Nov 18, 2019
1 parent 3b842cc commit 36695f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/Datadog.Trace.Tests/ApiTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public async Task SendTracesAsync_500_ErrorIsCaught()
sw.Stop();

Assert.Equal(5, handler.RequestsCount);
Assert.InRange(sw.ElapsedMilliseconds, 1500, 10000); // should be ~ 1600ms
Assert.InRange(sw.ElapsedMilliseconds, 1000, 12000); // should be ~ 1600ms

// TODO:bertrand check that it's properly logged
}
Expand Down
8 changes: 4 additions & 4 deletions test/Datadog.Trace.Tests/Sampling/RateLimiterTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ private static void Run_Limit_Test(int? intervalLimit, int numberPerBurst, int n
var totalMilliseconds = result.TimeElapsed.TotalMilliseconds;

var expectedLimit = totalMilliseconds * actualIntervalLimit / 1_000;

var upperLimit = expectedLimit + (actualIntervalLimit * 0.8);
var lowerLimit = expectedLimit - (actualIntervalLimit * 0.8);
var acceptableDifference = (actualIntervalLimit * 0.80);
var upperLimit = expectedLimit + acceptableDifference;
var lowerLimit = expectedLimit - acceptableDifference;

Assert.True(
result.TotalAllowed >= lowerLimit && result.TotalAllowed <= upperLimit,
Expand All @@ -88,7 +88,7 @@ private static void Run_Limit_Test(int? intervalLimit, int numberPerBurst, int n
var totalExpectedAllowed = 2 * actualIntervalLimit;
var expectedRate = totalExpectedAllowed / (float)totalExpectedSent;

var maxPercentVariance = 0.20f;
var maxPercentVariance = 0.35f;
var lowestRate = expectedRate - maxPercentVariance;
var highestRate = expectedRate + maxPercentVariance;

Expand Down

0 comments on commit 36695f1

Please sign in to comment.