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

-3
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

+1-1
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

+24-9
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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 });

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ private IndexReader reader(String indexKey) {
216216
}
217217

218218
@Override
219-
protected Operator.OperatorFactory simple() {
219+
protected Operator.OperatorFactory simple(SimpleOptions options) {
220220
return factory(initShardContexts(), mapperService("index1").fieldType("long"), ElementType.LONG);
221221
}
222222

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ public void closeIndex() throws IOException {
127127
}
128128

129129
@Override
130-
protected Operator.OperatorFactory simple() {
130+
protected Operator.OperatorFactory simple(SimpleOptions options) {
131131
if (reader == null) {
132132
// Init a reader if one hasn't been built, so things don't blow up
133133
try {

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/AggregationOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ protected SourceOperator simpleInput(BlockFactory blockFactory, int size) {
3535
}
3636

3737
@Override
38-
protected Operator.OperatorFactory simpleWithMode(AggregatorMode mode) {
38+
protected Operator.OperatorFactory simpleWithMode(SimpleOptions options, AggregatorMode mode) {
3939
List<Integer> sumChannels, maxChannels;
4040
if (mode.isInputPartial()) {
4141
int sumInterChannelCount = SumLongAggregatorFunction.intermediateStateDesc().size();

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/ChangePointOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ protected void assertSimpleOutput(List<Page> input, List<Page> results) {
7070
}
7171

7272
@Override
73-
protected Operator.OperatorFactory simple() {
73+
protected Operator.OperatorFactory simple(SimpleOptions options) {
7474
return new ChangePointOperator.Factory(0, null, 0, 0);
7575
}
7676

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/ColumnExtractOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public String toString() {
4848
}
4949

5050
@Override
51-
protected Operator.OperatorFactory simple() {
51+
protected Operator.OperatorFactory simple(SimpleOptions options) {
5252
Supplier<ColumnExtractOperator.Evaluator> expEval = () -> new FirstWord(0);
5353
return new ColumnExtractOperator.Factory(
5454
new ElementType[] { ElementType.BYTES_REF },

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/ColumnLoadOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ protected void assertSimpleOutput(List<Page> input, List<Page> results) {
6464
}
6565

6666
@Override
67-
protected Operator.OperatorFactory simple() {
67+
protected Operator.OperatorFactory simple(SimpleOptions options) {
6868
return new ColumnLoadOperator.Factory(
6969
new ColumnLoadOperator.Values(
7070
"values",

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/EvalOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ public void close() {}
6868
}
6969

7070
@Override
71-
protected Operator.OperatorFactory simple() {
71+
protected Operator.OperatorFactory simple(SimpleOptions options) {
7272
return new EvalOperator.EvalOperatorFactory(new EvalOperator.ExpressionEvaluator.Factory() {
7373
@Override
7474
public EvalOperator.ExpressionEvaluator get(DriverContext context) {

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/FilterOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public void close() {}
5454
}
5555

5656
@Override
57-
protected Operator.OperatorFactory simple() {
57+
protected Operator.OperatorFactory simple(SimpleOptions options) {
5858
return new FilterOperator.FilterOperatorFactory(new EvalOperator.ExpressionEvaluator.Factory() {
5959

6060
@Override

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/ForkingOperatorTestCase.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,18 @@ public abstract class ForkingOperatorTestCase extends OperatorTestCase {
5454

5555
private static final String ESQL_TEST_EXECUTOR = "esql_test_executor";
5656

57-
protected abstract Operator.OperatorFactory simpleWithMode(AggregatorMode mode);
57+
protected abstract Operator.OperatorFactory simpleWithMode(SimpleOptions options, AggregatorMode mode);
58+
59+
/**
60+
* Calls {@link #simpleWithMode(SimpleOptions, AggregatorMode)} with the default options.
61+
*/
62+
protected final Operator.OperatorFactory simpleWithMode(AggregatorMode mode) {
63+
return simpleWithMode(SimpleOptions.DEFAULT, mode);
64+
}
5865

5966
@Override
60-
protected final Operator.OperatorFactory simple() {
61-
return simpleWithMode(AggregatorMode.SINGLE);
67+
protected final Operator.OperatorFactory simple(SimpleOptions options) {
68+
return simpleWithMode(options, AggregatorMode.SINGLE);
6269
}
6370

6471
public final void testInitialFinal() {

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/HashAggregationOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ protected SourceOperator simpleInput(BlockFactory blockFactory, int size) {
4141
}
4242

4343
@Override
44-
protected Operator.OperatorFactory simpleWithMode(AggregatorMode mode) {
44+
protected Operator.OperatorFactory simpleWithMode(SimpleOptions options, AggregatorMode mode) {
4545
List<Integer> sumChannels, maxChannels;
4646
if (mode.isInputPartial()) {
4747
int sumChannelCount = SumLongAggregatorFunction.intermediateStateDesc().size();

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/IteratorAppendPageTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ protected void assertSimpleOutput(List<Page> input, List<Page> results) {
103103
}
104104

105105
@Override
106-
protected Operator.OperatorFactory simple() {
106+
protected Operator.OperatorFactory simple(SimpleOptions options) {
107107
return new IteratorAppendPage.Factory();
108108
}
109109

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/IteratorRemovePageTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ protected void assertSimpleOutput(List<Page> input, List<Page> results) {
105105
}
106106

107107
@Override
108-
protected Operator.OperatorFactory simple() {
108+
protected Operator.OperatorFactory simple(SimpleOptions options) {
109109
return new IteratorRemovePage.Factory();
110110
}
111111

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/LimitOperatorTests.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
public class LimitOperatorTests extends OperatorTestCase {
2929
@Override
30-
protected LimitOperator.Factory simple() {
30+
protected LimitOperator.Factory simple(SimpleOptions options) {
3131
return new LimitOperator.Factory(100);
3232
}
3333

@@ -55,7 +55,7 @@ protected void assertSimpleOutput(List<Page> input, List<Page> results) {
5555

5656
public void testStatus() {
5757
BlockFactory blockFactory = driverContext().blockFactory();
58-
LimitOperator op = simple().get(driverContext());
58+
LimitOperator op = simple(SimpleOptions.DEFAULT).get(driverContext());
5959

6060
LimitOperator.Status status = op.status();
6161
assertThat(status.limit(), equalTo(100));
@@ -77,7 +77,7 @@ public void testStatus() {
7777

7878
public void testNeedInput() {
7979
BlockFactory blockFactory = driverContext().blockFactory();
80-
try (LimitOperator op = simple().get(driverContext())) {
80+
try (LimitOperator op = simple(SimpleOptions.DEFAULT).get(driverContext())) {
8181
assertTrue(op.needsInput());
8282
Page p = new Page(blockFactory.newConstantNullBlock(10));
8383
op.addInput(p);

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/MvExpandOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ protected Page createPage(int positionOffset, int length) {
4949
}
5050

5151
@Override
52-
protected Operator.OperatorFactory simple() {
52+
protected Operator.OperatorFactory simple(SimpleOptions options) {
5353
return new MvExpandOperator.Factory(0, randomIntBetween(1, 1000));
5454
}
5555

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/OutputOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
public class OutputOperatorTests extends AnyOperatorTestCase {
1919
@Override
20-
protected Operator.OperatorFactory simple() {
20+
protected Operator.OperatorFactory simple(SimpleOptions options) {
2121
return new OutputOperator.OutputOperatorFactory(List.of("a"), p -> p, p -> {});
2222
}
2323

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/ProjectOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ protected SourceOperator simpleInput(BlockFactory blockFactory, int end) {
6666
}
6767

6868
@Override
69-
protected Operator.OperatorFactory simple() {
69+
protected Operator.OperatorFactory simple(SimpleOptions options) {
7070
return new ProjectOperator.ProjectOperatorFactory(Arrays.asList(1));
7171
}
7272

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/RowInTableLookupOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ private void assertSimpleOutput(List<Page> input, List<Page> results, int keyCha
7979
}
8080

8181
@Override
82-
protected Operator.OperatorFactory simple() {
82+
protected Operator.OperatorFactory simple(SimpleOptions options) {
8383
return new RowInTableLookupOperator.Factory(
8484
new RowInTableLookupOperator.Key[] {
8585
new RowInTableLookupOperator.Key(

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/SampleOperatorTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ protected void assertSimpleOutput(List<Page> input, List<Page> results) {
4040
}
4141

4242
@Override
43-
protected SampleOperator.Factory simple() {
43+
protected SampleOperator.Factory simple(SimpleOptions options) {
4444
return new SampleOperator.Factory(0.5, randomInt());
4545
}
4646

@@ -59,7 +59,7 @@ public void testAccuracy() {
5959
int totalPositionCount = 0;
6060

6161
for (int iter = 0; iter < 10000; iter++) {
62-
SampleOperator operator = simple().get(driverContext());
62+
SampleOperator operator = simple(SimpleOptions.DEFAULT).get(driverContext());
6363
operator.addInput(new Page(blockFactory.newConstantNullBlock(20000)));
6464
Page output = operator.getOutput();
6565
// 10000 expected rows, stddev=sqrt(10000)=100, so this is 10 stddevs.

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/StringExtractOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public Map<String, String> apply(String s) {
4141
}
4242

4343
@Override
44-
protected Operator.OperatorFactory simple() {
44+
protected Operator.OperatorFactory simple(SimpleOptions options) {
4545
Supplier<Function<String, Map<String, String>>> expEval = () -> new FirstWord("test");
4646
return new StringExtractOperator.StringExtractOperatorFactory(
4747
new String[] { "test" },

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/topn/TopNOperatorTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ public class TopNOperatorTests extends OperatorTestCase {
130130
);
131131

132132
@Override
133-
protected TopNOperator.TopNOperatorFactory simple() {
133+
protected TopNOperator.TopNOperatorFactory simple(SimpleOptions options) {
134134
return new TopNOperator.TopNOperatorFactory(
135135
4,
136136
List.of(LONG),

0 commit comments

Comments
 (0)