Skip to content

Commit 1627586

Browse files
committed
Fix incremental reduce randomization in base tests cases
We can and should randomly reduce down to a single result before we passing the aggs to the final reduce. This commit changes the logic to do that and ensures we don't trip the assertions the previous imple tripped. Relates to #23253
1 parent ed4a47d commit 1627586

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

core/src/test/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,9 @@ protected <A extends InternalAggregation, C extends Aggregator> A searchAndReduc
180180
if (aggs.isEmpty()) {
181181
return null;
182182
} else {
183-
if (aggs.size() > 2 && randomBoolean()) {
183+
if (randomBoolean()) {
184184
// sometimes do an incremental reduce
185-
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(2, aggs.size()-1), aggs);
185+
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(1, aggs.size()), aggs);
186186
A internalAgg = (A) aggs.get(0).doReduce(internalAggregations,
187187
new InternalAggregation.ReduceContext(root.context().bigArrays(), null, false));
188188
aggs.removeAll(internalAggregations);

0 commit comments

Comments
 (0)