Skip to content

Commit 12cf663

Browse files
committed
Fix InternalTTestTests
`testReduceRandom` was bumping up against the serialization that I added in #54776. This makes it use random values that reduce in ways that don't cause the randomized serialization to fail.
1 parent f9cb309 commit 12cf663

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

x-pack/plugin/analytics/src/test/java/org/elasticsearch/xpack/analytics/ttest/InternalTTestTests.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,13 @@ private TTestState randomState() {
5151
}
5252

5353
private TTestStats randomStats() {
54-
return new TTestStats(randomNonNegativeLong(), randomDouble(), randomDouble());
54+
/*
55+
* Use a count significantly less than Long.MAX_VALUE so the reduce
56+
* phase doesn't wrap to a negative number. If it *did* then we'd
57+
* try to serialize a negative number with writeVLong which throws
58+
* an assertion in tests.
59+
*/
60+
return new TTestStats(randomLongBetween(0, Integer.MAX_VALUE), randomDouble(), randomDouble());
5561
}
5662

5763
@Override

0 commit comments

Comments
 (0)