Skip to content

Commit fbbe29c

Browse files
committed
Update
1 parent 79f7c39 commit fbbe29c

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

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

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2672,10 +2672,13 @@ protected static MapMatcher getProfileMatcher() {
26722672
.entry("drivers", instanceOf(List.class));
26732673
}
26742674

2675-
protected static MapMatcher getResultMatcher(boolean includeMetadata, boolean includePartial) {
2675+
protected static MapMatcher getResultMatcher(boolean includeMetadata, boolean includePartial, boolean includeDocumentsFound) {
26762676
MapMatcher mapMatcher = matchesMap();
2677-
mapMatcher = mapMatcher.entry("documents_found", greaterThanOrEqualTo(0));
2678-
mapMatcher = mapMatcher.entry("values_loaded", greaterThanOrEqualTo(0));
2677+
if (includeDocumentsFound) {
2678+
// Older versions may not return documents_found and values_loaded.
2679+
mapMatcher = mapMatcher.entry("documents_found", greaterThanOrEqualTo(0));
2680+
mapMatcher = mapMatcher.entry("values_loaded", greaterThanOrEqualTo(0));
2681+
}
26792682
if (includeMetadata) {
26802683
mapMatcher = mapMatcher.entry("took", greaterThanOrEqualTo(0));
26812684
}
@@ -2690,7 +2693,7 @@ protected static MapMatcher getResultMatcher(boolean includeMetadata, boolean in
26902693
* Create empty result matcher from result, taking into account all metadata items.
26912694
*/
26922695
protected static MapMatcher getResultMatcher(Map<String, Object> result) {
2693-
return getResultMatcher(result.containsKey("took"), result.containsKey("is_partial"));
2696+
return getResultMatcher(result.containsKey("took"), result.containsKey("is_partial"), result.containsKey("documents_found"));
26942697
}
26952698

26962699
/**

x-pack/plugin/esql/qa/server/multi-clusters/src/javaRestTest/java/org/elasticsearch/xpack/esql/ccq/MultiClustersIT.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,11 @@ private Map<String, Object> runEsql(RestEsqlTestCase.RequestObjectBuilder reques
159159
}
160160

161161
private <C, V> void assertResultMap(boolean includeCCSMetadata, Map<String, Object> result, C columns, V values, boolean remoteOnly) {
162-
MapMatcher mapMatcher = getResultMatcher(ccsMetadataAvailable(), result.containsKey("is_partial"));
162+
MapMatcher mapMatcher = getResultMatcher(
163+
ccsMetadataAvailable(),
164+
result.containsKey("is_partial"),
165+
result.containsKey("documents_found")
166+
);
163167
if (includeCCSMetadata) {
164168
mapMatcher = mapMatcher.entry("_clusters", any(Map.class));
165169
}

0 commit comments

Comments
 (0)