Skip to content

Commit 75cef17

Browse files
committed
Tets
1 parent aebd712 commit 75cef17

File tree

3 files changed

+22
-6
lines changed

3 files changed

+22
-6
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2667,6 +2667,8 @@ public static Request newXContentRequest(HttpMethod method, String endpoint, ToX
26672667

26682668
protected static MapMatcher getResultMatcher(boolean includeMetadata, boolean includePartial) {
26692669
MapMatcher mapMatcher = matchesMap();
2670+
mapMatcher = mapMatcher.entry("documents_found", greaterThanOrEqualTo(0));
2671+
mapMatcher = mapMatcher.entry("values_loaded", greaterThanOrEqualTo(0));
26702672
if (includeMetadata) {
26712673
mapMatcher = mapMatcher.entry("took", greaterThanOrEqualTo(0));
26722674
}
@@ -2688,7 +2690,13 @@ protected static MapMatcher getResultMatcher(Map<String, Object> result) {
26882690
* Match result columns and values, with default matchers for metadata.
26892691
*/
26902692
protected static void assertResultMap(Map<String, Object> result, Matcher<?> columnMatcher, Matcher<?> valuesMatcher) {
2691-
assertMap(result, getResultMatcher(result).entry("columns", columnMatcher).entry("values", valuesMatcher));
2693+
assertMap(
2694+
result,
2695+
getResultMatcher(result).entry("columns", columnMatcher)
2696+
.entry("values", valuesMatcher)
2697+
.entry("documents_found", greaterThanOrEqualTo(0))
2698+
.entry("values_loaded", greaterThanOrEqualTo(0))
2699+
);
26922700
}
26932701

26942702
protected static void assertResultMap(Map<String, Object> result, Object columnMatcher, Object valuesMatcher) {

x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/RestEsqlIT.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,9 @@ private MapMatcher commonProfile() {
659659
.entry("cpu_nanos", greaterThan(0L))
660660
.entry("took_nanos", greaterThan(0L))
661661
.entry("operators", instanceOf(List.class))
662-
.entry("sleeps", matchesMap().extraOk());
662+
.entry("sleeps", matchesMap().extraOk())
663+
.entry("documents_found", greaterThanOrEqualTo(0))
664+
.entry("values_loaded", greaterThanOrEqualTo(0));
663665
}
664666

665667
/**
@@ -688,7 +690,8 @@ private String checkOperatorProfile(Map<String, Object> o) {
688690
.entry("rows_emitted", greaterThan(0))
689691
.entry("process_nanos", greaterThan(0))
690692
.entry("processed_queries", List.of("*:*"));
691-
case "ValuesSourceReaderOperator" -> basicProfile().entry("readers_built", matchesMap().extraOk());
693+
case "ValuesSourceReaderOperator" -> basicProfile().entry("values_loaded", greaterThanOrEqualTo(0))
694+
.entry("readers_built", matchesMap().extraOk());
692695
case "AggregationOperator" -> matchesMap().entry("pages_processed", greaterThan(0))
693696
.entry("rows_received", greaterThan(0))
694697
.entry("rows_emitted", greaterThan(0))

x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import static java.util.Map.entry;
6060
import static org.elasticsearch.common.logging.LoggerMessageFormat.format;
6161
import static org.elasticsearch.test.ListMatcher.matchesList;
62+
import static org.elasticsearch.test.MapMatcher.assertMap;
6263
import static org.elasticsearch.test.MapMatcher.matchesMap;
6364
import static org.elasticsearch.xpack.esql.EsqlTestUtils.as;
6465
import static org.elasticsearch.xpack.esql.qa.rest.RestEsqlTestCase.Mode.ASYNC;
@@ -266,12 +267,16 @@ public static RequestObjectBuilder jsonBuilder() throws IOException {
266267

267268
public void testGetAnswer() throws IOException {
268269
Map<String, Object> answer = runEsql(requestObjectBuilder().query("row a = 1, b = 2"));
269-
assertEquals(4, answer.size());
270+
assertEquals(6, answer.size());
270271
assertThat(((Integer) answer.get("took")).intValue(), greaterThanOrEqualTo(0));
271272
Map<String, String> colA = Map.of("name", "a", "type", "integer");
272273
Map<String, String> colB = Map.of("name", "b", "type", "integer");
273-
assertEquals(List.of(colA, colB), answer.get("columns"));
274-
assertEquals(List.of(List.of(1, 2)), answer.get("values"));
274+
assertMap(answer, matchesMap().entry("took", greaterThanOrEqualTo(0))
275+
.entry("is_partial", any(Boolean.class))
276+
.entry("documents_found", 0)
277+
.entry("values_loaded", 0)
278+
.entry("columns", List.of(colA, colB))
279+
.entry("values", List.of(List.of(1, 2))));
275280
}
276281

277282
public void testUseUnknownIndex() throws IOException {

0 commit comments

Comments
 (0)