maheshrijal commented on code in PR #20724:
URL: https://github.com/apache/druid/pull/20724#discussion_r4370967503
##########
server/src/test/java/org/apache/druid/server/coordinator/balancer/ReservoirSegmentSamplerTest.java:
##########
@@ -279,15 +279,32 @@ public void
testSegmentsFromMorePopulousServerAreMoreLikelyToBePicked()
// Number of segments picked from server0 are ~40% of total and
// number of segments picked from other servers are each ~20% of total
- double error = totalSegmentsPicked * 0.02;
- Assertions.assertEquals(totalSegmentsPicked * 0.40,
numSegmentsPickedFromServer[0], error);
+ Assertions.assertEquals(
+ totalSegmentsPicked * 0.40,
+ numSegmentsPickedFromServer[0],
+ allowedError(totalSegmentsPicked, 0.40)
+ );
for (int serverId = 1; serverId < servers.size(); ++serverId) {
- Assertions.assertEquals(totalSegmentsPicked * 0.20,
numSegmentsPickedFromServer[serverId], error);
+ Assertions.assertEquals(
+ totalSegmentsPicked * 0.20,
+ numSegmentsPickedFromServer[serverId],
+ allowedError(totalSegmentsPicked, 0.20)
+ );
}
}
}
+ /**
+ * Returns 4 standard deviations of a binomial count with {@code numPicked}
trials
+ * and probability {@code p}. A fixed percentage of {@code numPicked} is too
tight
+ * for small samples and makes the test flaky.
+ */
+ private static double allowedError(int numPicked, double p)
Review Comment:
Applied the same `allowedError(totalSegmentsPicked, 0.25)` tolerance to the
equal-server assertions in 15289d4. At the 5% sample size the margin goes from
±50 to ±86.6.
With 4 standard deviations, the two tests together can still fail about once
in 1,700 runs. Would you prefer 6 to make that negligible? Happy to change it.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]