Skip to content

Commit

Permalink
ESQL: Fix tests around releasing early (elastic#100534)
Browse files Browse the repository at this point in the history
The test for releasing an `Operation` without fetching it's result
requires a single input page because that's the only valid way to drive
all operators. To do that the test forces a single input document. Some
tests were not respecting that input request. This fixes those tests.

Closes elastic#100496
  • Loading branch information
nik9000 authored Oct 9, 2023
1 parent b92a2ac commit 2292406
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class MedianAbsoluteDeviationDoubleAggregatorFunctionTests extends Aggreg
protected SourceOperator simpleInput(BlockFactory blockFactory, int end) {
List<Double> values = Arrays.asList(1.2, 1.25, 2.0, 2.0, 4.3, 6.0, 9.0);
Randomness.shuffle(values);
return new SequenceDoubleBlockSourceOperator(blockFactory, values);
return new SequenceDoubleBlockSourceOperator(blockFactory, values.subList(0, Math.min(values.size(), end)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected SourceOperator simpleInput(BlockFactory blockFactory, int end) {
values.add(Tuple.tuple((long) i, v));
}
}
return new LongDoubleTupleBlockSourceOperator(blockFactory, values);
return new LongDoubleTupleBlockSourceOperator(blockFactory, values.subList(0, Math.min(values.size(), end)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class MedianAbsoluteDeviationIntAggregatorFunctionTests extends Aggregato
protected SourceOperator simpleInput(BlockFactory blockFactory, int end) {
List<Integer> values = Arrays.asList(12, 125, 20, 20, 43, 60, 90);
Randomness.shuffle(values);
return new SequenceIntBlockSourceOperator(blockFactory, values);
return new SequenceIntBlockSourceOperator(blockFactory, values.subList(0, Math.min(values.size(), end)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected SourceOperator simpleInput(BlockFactory blockFactory, int end) {
values.add(Tuple.tuple((long) i, v));
}
}
return new LongIntBlockSourceOperator(blockFactory, values);
return new LongIntBlockSourceOperator(blockFactory, values.subList(0, Math.min(values.size(), end)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class MedianAbsoluteDeviationLongAggregatorFunctionTests extends Aggregat
protected SourceOperator simpleInput(BlockFactory blockFactory, int end) {
List<Long> values = Arrays.asList(12L, 125L, 20L, 20L, 43L, 60L, 90L);
Randomness.shuffle(values);
return new SequenceLongBlockSourceOperator(blockFactory, values);
return new SequenceLongBlockSourceOperator(blockFactory, values.subList(0, Math.min(values.size(), end)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ protected SourceOperator simpleInput(BlockFactory blockFactory, int end) {
values.add(Tuple.tuple((long) i, v));
}
}
return new TupleBlockSourceOperator(blockFactory, values);
return new TupleBlockSourceOperator(blockFactory, values.subList(0, Math.min(values.size(), end)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ protected final void assertSimple(DriverContext context, int size) {
}
}

// Tests that finish then close without calling getOutput to retrieve a potential last page, releases all memory
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/100496")
/**
* Tests that finish then close without calling {@link Operator#getOutput} to
* retrieve a potential last page, releases all memory.
*/
public void testSimpleFinishClose() {
DriverContext driverContext = driverContext();
List<Page> input = CannedSourceOperator.collectPages(simpleInput(driverContext.blockFactory(), 1));
Expand Down

0 comments on commit 2292406

Please sign in to comment.