Skip to content

Commit bccd6f2

Browse files
authored
ESQL: Fix block randomization on circuit breaking tests (#127909)
Fixes #127833
1 parent 126bc7a commit bccd6f2

34 files changed

+84
-49
lines changed

muted-tests.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -426,9 +426,6 @@ tests:
426426
- class: org.elasticsearch.backwards.MixedClusterClientYamlTestSuiteIT
427427
method: test {p0=search/350_point_in_time/point-in-time with index filter}
428428
issue: https://github.com/elastic/elasticsearch/issues/127741
429-
- class: org.elasticsearch.compute.aggregation.FilteredGroupingAggregatorFunctionTests
430-
method: testSimpleCircuitBreaking
431-
issue: https://github.com/elastic/elasticsearch/issues/127833
432429
- class: org.elasticsearch.packaging.test.DockerTests
433430
method: test025SyncPluginsUsingProxy
434431
issue: https://github.com/elastic/elasticsearch/issues/127138

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/AggregatorFunctionTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ protected final int aggregatorIntermediateBlockCount() {
6161
protected abstract void assertSimpleOutput(List<Block> input, Block result);
6262

6363
@Override
64-
protected Operator.OperatorFactory simpleWithMode(AggregatorMode mode) {
64+
protected Operator.OperatorFactory simpleWithMode(SimpleOptions options, AggregatorMode mode) {
6565
return simpleWithMode(mode, Function.identity());
6666
}
6767

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -90,15 +90,16 @@ protected DataType acceptedDataType() {
9090
};
9191

9292
@Override
93-
protected final Operator.OperatorFactory simpleWithMode(AggregatorMode mode) {
94-
return simpleWithMode(mode, Function.identity());
93+
protected final Operator.OperatorFactory simpleWithMode(SimpleOptions options, AggregatorMode mode) {
94+
return simpleWithMode(options, mode, Function.identity());
9595
}
9696

9797
protected List<Integer> channels(AggregatorMode mode) {
9898
return mode.isInputPartial() ? range(1, 1 + aggregatorIntermediateBlockCount()).boxed().toList() : List.of(1);
9999
}
100100

101101
private Operator.OperatorFactory simpleWithMode(
102+
SimpleOptions options,
102103
AggregatorMode mode,
103104
Function<AggregatorFunctionSupplier, AggregatorFunctionSupplier> wrap
104105
) {
@@ -108,13 +109,24 @@ private Operator.OperatorFactory simpleWithMode(
108109
if (randomBoolean()) {
109110
supplier = chunkGroups(emitChunkSize, supplier);
110111
}
111-
return new RandomizingHashAggregationOperatorFactory(
112-
List.of(new BlockHash.GroupSpec(0, ElementType.LONG)),
113-
mode,
114-
List.of(supplier.groupingAggregatorFactory(mode, channels(mode))),
115-
randomPageSize(),
116-
null
117-
);
112+
113+
if (options.requiresDeterministicFactory()) {
114+
return new HashAggregationOperator.HashAggregationOperatorFactory(
115+
List.of(new BlockHash.GroupSpec(0, ElementType.LONG)),
116+
mode,
117+
List.of(supplier.groupingAggregatorFactory(mode, channels(mode))),
118+
randomPageSize(),
119+
null
120+
);
121+
} else {
122+
return new RandomizingHashAggregationOperatorFactory(
123+
List.of(new BlockHash.GroupSpec(0, ElementType.LONG)),
124+
mode,
125+
List.of(supplier.groupingAggregatorFactory(mode, channels(mode))),
126+
randomPageSize(),
127+
null
128+
);
129+
}
118130
}
119131

120132
@Override
@@ -389,6 +401,7 @@ public final void testEmptyInput() {
389401

390402
public final void testAllFiltered() {
391403
Operator.OperatorFactory factory = simpleWithMode(
404+
SimpleOptions.DEFAULT,
392405
AggregatorMode.SINGLE,
393406
agg -> new FilteredAggregatorFunctionSupplier(agg, ConstantBooleanExpressionEvaluator.factory(false))
394407
);
@@ -401,6 +414,7 @@ public final void testAllFiltered() {
401414

402415
public final void testNoneFiltered() {
403416
Operator.OperatorFactory factory = simpleWithMode(
417+
SimpleOptions.DEFAULT,
404418
AggregatorMode.SINGLE,
405419
agg -> new FilteredAggregatorFunctionSupplier(agg, ConstantBooleanExpressionEvaluator.factory(true))
406420
);
@@ -414,6 +428,7 @@ public final void testNoneFiltered() {
414428

415429
public void testSomeFiltered() {
416430
Operator.OperatorFactory factory = simpleWithMode(
431+
SimpleOptions.DEFAULT,
417432
AggregatorMode.SINGLE,
418433
agg -> new FilteredAggregatorFunctionSupplier(agg, AddGarbageRowsSourceOperator.filterFactory())
419434
);

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/lucene/LuceneCountOperatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public void closeIndex() throws IOException {
5151
}
5252

5353
@Override
54-
protected LuceneCountOperator.Factory simple() {
54+
protected LuceneCountOperator.Factory simple(SimpleOptions options) {
5555
return simple(randomFrom(DataPartitioning.values()), between(1, 10_000), 100);
5656
}
5757

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/lucene/LuceneMaxOperatorTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void closeIndex() throws IOException {
7373
}
7474

7575
@Override
76-
protected LuceneMaxFactory simple() {
76+
protected LuceneMaxFactory simple(SimpleOptions options) {
7777
return simple(getNumberTypeTest(), randomFrom(DataPartitioning.values()), between(1, 10_000), 100);
7878
}
7979

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/lucene/LuceneMinOperatorTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public void closeIndex() throws IOException {
7373
}
7474

7575
@Override
76-
protected LuceneMinFactory simple() {
76+
protected LuceneMinFactory simple(SimpleOptions options) {
7777
return simple(getNumberTypeTest(), randomFrom(DataPartitioning.values()), between(1, 10_000), 100);
7878
}
7979

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/lucene/LuceneSourceOperatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ public void closeIndex() throws IOException {
7272
}
7373

7474
@Override
75-
protected LuceneSourceOperator.Factory simple() {
75+
protected LuceneSourceOperator.Factory simple(SimpleOptions options) {
7676
return simple(randomFrom(DataPartitioning.values()), between(1, 10_000), 100, scoring);
7777
}
7878

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/lucene/LuceneTopNSourceOperatorScoringTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ private void closeIndex() throws IOException {
5858
}
5959

6060
@Override
61-
protected LuceneTopNSourceOperator.Factory simple() {
61+
protected LuceneTopNSourceOperator.Factory simple(SimpleOptions options) {
6262
return simple(DataPartitioning.SHARD, 10_000, 100);
6363
}
6464

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/lucene/LuceneTopNSourceOperatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ private void closeIndex() throws IOException {
6363
}
6464

6565
@Override
66-
protected LuceneTopNSourceOperator.Factory simple() {
66+
protected LuceneTopNSourceOperator.Factory simple(SimpleOptions options) {
6767
return simple(DataPartitioning.SHARD, 10_000, 100);
6868
}
6969

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/lucene/TimeSeriesSourceOperatorTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ public void testMatchNone() throws Exception {
328328
}
329329

330330
@Override
331-
protected Operator.OperatorFactory simple() {
331+
protected Operator.OperatorFactory simple(SimpleOptions options) {
332332
return createTimeSeriesSourceOperator(directory, r -> this.reader = r, randomBoolean(), List.of(), 1, 1, false, writer -> {
333333
long timestamp = DateFieldMapper.DEFAULT_DATE_TIME_FORMATTER.parseMillis("2024-01-01T00:00:00Z");
334334
writeTS(writer, timestamp, new Object[] { "hostname", "host-01" }, new Object[] { "voltage", 2 });

0 commit comments

Comments
 (0)