Fix nested agg test

I accidentally allowed the test framework to double-wrap a reader that
we rely on being only singly wrapped. Lame.

closes #56529
This commit is contained in:
Nik Everett 2020-05-11 15:30:08 -04:00
parent 91c5ace569
commit c85a363b60
1 changed files with 8 additions and 2 deletions

View File

@ -555,8 +555,14 @@ public abstract class AggregatorTestCase extends ESTestCase {
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);