diff --git a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java index 8c69e64215161..8f485509778f7 100644 --- a/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java +++ b/server/src/test/java/org/elasticsearch/search/aggregations/bucket/nested/NestedAggregatorTests.java @@ -817,7 +817,6 @@ public void testNestedWithPipeline() throws IOException { * that stopped wrapping itself in {@link AggregatorFactory#asMultiBucketAggregator} * so this tests that nested works properly inside of it. */ - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/56529") public void testNestedUnderLongTerms() throws IOException { int numProducts = scaledRandomIntBetween(1, 100); int numResellers = scaledRandomIntBetween(1, 100); diff --git a/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java b/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java index 19c93310bfba1..8ca7278b6e7b6 100644 --- a/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java +++ b/test/framework/src/main/java/org/elasticsearch/search/aggregations/AggregatorTestCase.java @@ -551,8 +551,14 @@ protected void tes buildIndex.accept(indexWriter); indexWriter.close(); - try (IndexReader indexReader = wrapDirectoryReader(DirectoryReader.open(directory))) { - IndexSearcher indexSearcher = newSearcher(indexReader, true, true); + try (DirectoryReader unwrapped = DirectoryReader.open(directory); + IndexReader indexReader = wrapDirectoryReader(unwrapped)) { + /* + * Only allow the randomized testing to wrap the reader if + * the test didn't explicitly wrap the reader. + */ + boolean maybeWrap = unwrapped == indexReader; + IndexSearcher indexSearcher = newSearcher(indexReader, maybeWrap, true); V agg = searchAndReduce(indexSearcher, query, aggregationBuilder, fieldTypes); verify.accept(agg);