Skip to content
3 changes: 0 additions & 3 deletions muted-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -435,9 +435,6 @@ tests:
- class: org.elasticsearch.xpack.remotecluster.RemoteClusterSecurityFcActionAuthorizationIT
method: testIndicesPrivilegesAreEnforcedForCcrRestoreSessionActions
issue: https://github.com/elastic/elasticsearch/issues/127782
- class: org.elasticsearch.compute.aggregation.FilteredGroupingAggregatorFunctionTests
method: testSimpleCircuitBreaking
issue: https://github.com/elastic/elasticsearch/issues/127833
- class: org.elasticsearch.packaging.test.DockerTests
method: test025SyncPluginsUsingProxy
issue: https://github.com/elastic/elasticsearch/issues/127138
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import org.elasticsearch.compute.operator.SourceOperator;
import org.elasticsearch.compute.test.BlockTestUtils;
import org.elasticsearch.compute.test.CannedSourceOperator;
import org.elasticsearch.compute.test.OperatorTestCase;
import org.elasticsearch.compute.test.TestBlockFactory;
import org.elasticsearch.core.Nullable;
import org.elasticsearch.core.Releasables;
Expand All @@ -46,6 +47,7 @@
import org.hamcrest.Matcher;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
Expand Down Expand Up @@ -108,13 +110,41 @@ private Operator.OperatorFactory simpleWithMode(
if (randomBoolean()) {
supplier = chunkGroups(emitChunkSize, supplier);
}
return new RandomizingHashAggregationOperatorFactory(
List.of(new BlockHash.GroupSpec(0, ElementType.LONG)),
mode,
List.of(supplier.groupingAggregatorFactory(mode, channels(mode))),
randomPageSize(),
null
);

if (shouldRandomizeBlocks()) {
return new RandomizingHashAggregationOperatorFactory(
List.of(new BlockHash.GroupSpec(0, ElementType.LONG)),
mode,
List.of(supplier.groupingAggregatorFactory(mode, channels(mode))),
randomPageSize(),
null
);
} else {
return new HashAggregationOperator.HashAggregationOperatorFactory(
List.of(new BlockHash.GroupSpec(0, ElementType.LONG)),
mode,
List.of(supplier.groupingAggregatorFactory(mode, channels(mode))),
randomPageSize(),
null
);
}
}

/**
* Checks whether the class is being run by {@link org.elasticsearch.compute.test.OperatorTestCase#testSimpleCircuitBreaking} or not.
* <p>
* If it is, then we can't randomize blocks, as it expects a deterministic memory usage.
* </p>
* <p>
* Explicitly linking {@link org.elasticsearch.compute.test.OperatorTestCase#testSimpleCircuitBreaking} as
* this method looks for it based on its name, so any modification there should be updated here!
* </p>
*/
private boolean shouldRandomizeBlocks() {
return Arrays.stream(Thread.currentThread().getStackTrace())
.noneMatch(
e -> e.getClassName().equals(OperatorTestCase.class.getName()) && e.getMethodName().equals("testSimpleCircuitBreaking")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wish we had C#'s nameof() to make this more robust. But I think adding that link in the javadoc is the only simple option we have (?)

);
}

@Override
Expand Down