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
This commit is contained in:
parent
3a0fc526bb
commit
489f38918d
|
@ -180,9 +180,9 @@ public abstract class AggregatorTestCase extends ESTestCase {
|
||||||
if (aggs.isEmpty()) {
|
if (aggs.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
if (aggs.size() > 2 && randomBoolean()) {
|
if (randomBoolean()) {
|
||||||
// sometimes do an incremental reduce
|
// sometimes do an incremental reduce
|
||||||
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(2, aggs.size()-1), aggs);
|
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(1, aggs.size()), aggs);
|
||||||
A internalAgg = (A) aggs.get(0).doReduce(internalAggregations,
|
A internalAgg = (A) aggs.get(0).doReduce(internalAggregations,
|
||||||
new InternalAggregation.ReduceContext(root.context().bigArrays(), null, false));
|
new InternalAggregation.ReduceContext(root.context().bigArrays(), null, false));
|
||||||
aggs.removeAll(internalAggregations);
|
aggs.removeAll(internalAggregations);
|
||||||
|
|
|
@ -57,8 +57,9 @@ public abstract class InternalAggregationTestCase<T extends InternalAggregation>
|
||||||
inputs.add(t);
|
inputs.add(t);
|
||||||
toReduce.add(t);
|
toReduce.add(t);
|
||||||
}
|
}
|
||||||
if (randomBoolean() && toReduceSize >= 2) {
|
if (randomBoolean()) {
|
||||||
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(2, toReduceSize - 2), toReduce);
|
// we leave at least one in the list
|
||||||
|
List<InternalAggregation> internalAggregations = randomSubsetOf(randomIntBetween(1, toReduceSize), toReduce);
|
||||||
InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(null, null, true);
|
InternalAggregation.ReduceContext context = new InternalAggregation.ReduceContext(null, null, true);
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
T reduced = (T) inputs.get(0).reduce(internalAggregations, context);
|
T reduced = (T) inputs.get(0).reduce(internalAggregations, context);
|
||||||
|
|
|
@ -30,7 +30,7 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class InternalExtendedStatsTests extends InternalAggregationTestCase<InternalExtendedStats> {
|
public class InternalExtendedStatsTests extends InternalAggregationTestCase<InternalExtendedStats> {
|
||||||
private double sigma;
|
private double sigma;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
|
|
Loading…
Reference in New Issue