Skip to content

Commit e8e9226

Browse files
committed
Update Limit operator tests
1 parent 25ef602 commit e8e9226

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/LimitStatusTests.java renamed to x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/LimitOperatorStatusTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import static org.hamcrest.Matchers.equalTo;
1818

19-
public class LimitStatusTests extends AbstractWireSerializingTestCase<LimitOperator.Status> {
19+
public class LimitOperatorStatusTests extends AbstractWireSerializingTestCase<LimitOperator.Status> {
2020
public void testToXContent() {
2121
assertThat(Strings.toString(new LimitOperator.Status(10, 1, 1, 111, 222)), equalTo("""
2222
{"limit":10,"limit_remaining":1,"pages_processed":1,"rows_received":111,"rows_emitted":222}"""));

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/operator/LimitOperatorTests.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,13 @@
1818

1919
import java.util.ArrayList;
2020
import java.util.List;
21+
import java.util.Map;
2122
import java.util.concurrent.atomic.AtomicInteger;
2223
import java.util.stream.LongStream;
2324

2425
import static org.elasticsearch.compute.test.RandomBlock.randomElementType;
26+
import static org.elasticsearch.test.MapMatcher.assertMap;
27+
import static org.elasticsearch.test.MapMatcher.matchesMap;
2528
import static org.hamcrest.Matchers.equalTo;
2629
import static org.hamcrest.Matchers.sameInstance;
2730

@@ -192,4 +195,17 @@ Block randomBlock(BlockFactory blockFactory, int size) {
192195
}
193196
return RandomBlock.randomBlock(blockFactory, randomElementType(), size, false, 1, 1, 0, 0).block();
194197
}
198+
199+
@Override
200+
protected final void assertStatus(Map<String, Object> map, List<Page> input, List<Page> output) {
201+
var emittedRows = output.stream().mapToInt(Page::getPositionCount).sum();
202+
203+
var mapMatcher = matchesMap().entry("rows_received", emittedRows)
204+
.entry("pages_processed", output.size())
205+
.entry("rows_emitted", emittedRows)
206+
.entry("limit", 100)
207+
.entry("limit_remaining", 100 - emittedRows);
208+
209+
assertMap(map, mapMatcher);
210+
}
195211
}

0 commit comments

Comments
 (0)