Skip to content

Commit

Permalink
Fix nested agg test
Browse files Browse the repository at this point in the history
I accidentally allowed the test framework to double-wrap a reader that
we rely on being only singly wrapped. Lame.

closes elastic#56529
  • Loading branch information
nik9000 committed May 11, 2020
1 parent 91c5ace commit c85a363
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -555,8 +555,14 @@ protected <T extends AggregationBuilder, V extends InternalAggregation> 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);
Expand Down

0 comments on commit c85a363

Please sign in to comment.