Skip to content

Commit 402b9a6

Browse files
committed
Move REST test
1 parent 7ea40d8 commit 402b9a6

File tree

2 files changed

+31
-115
lines changed

2 files changed

+31
-115
lines changed

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

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.apache.http.HttpHost;
1313
import org.elasticsearch.Version;
1414
import org.elasticsearch.client.Request;
15+
import org.elasticsearch.client.Response;
1516
import org.elasticsearch.client.RestClient;
1617
import org.elasticsearch.common.Strings;
1718
import org.elasticsearch.common.settings.Settings;
@@ -37,9 +38,11 @@
3738

3839
import static org.elasticsearch.test.MapMatcher.assertMap;
3940
import static org.elasticsearch.test.MapMatcher.matchesMap;
41+
import static org.elasticsearch.xpack.esql.ccq.Clusters.REMOTE_CLUSTER_NAME;
4042
import static org.hamcrest.Matchers.any;
4143
import static org.hamcrest.Matchers.equalTo;
4244
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
45+
import static org.hamcrest.Matchers.hasKey;
4346

4447
@ThreadLeakFilters(filters = TestClustersThreadFilter.class)
4548
public class MultiClustersIT extends ESRestTestCase {
@@ -395,6 +398,34 @@ public void testIndexPattern() throws Exception {
395398
}
396399
}
397400

401+
@SuppressWarnings("unchecked")
402+
public void testStats() throws IOException {
403+
assumeTrue("Older versions do not have ESQL stats", Clusters.localClusterVersion().onOrAfter(Version.V_8_18_0));
404+
run("FROM test-local-index,*:test-remote-index | STATS total = SUM(data) BY color | SORT color", includeCCSMetadata());
405+
Request stats = new Request("GET", "_cluster/stats");
406+
Response statsResponse = client().performRequest(stats);
407+
Map<String, Object> result = entityAsMap(statsResponse.getEntity());
408+
assertThat(result, hasKey("ccs"));
409+
Map<String, Object> ccs = (Map<String, Object>) result.get("ccs");
410+
assertThat(ccs, hasKey("_esql"));
411+
Map<String, Object> esql = (Map<String, Object>) ccs.get("_esql");
412+
assertThat(esql, hasKey("total"));
413+
assertThat(esql, hasKey("success"));
414+
assertThat(esql, hasKey("took"));
415+
assertThat(esql, hasKey("remotes_per_search_max"));
416+
assertThat(esql, hasKey("remotes_per_search_avg"));
417+
assertThat(esql, hasKey("failure_reasons"));
418+
assertThat(esql, hasKey("features"));
419+
assertThat(esql, hasKey("clusters"));
420+
Map<String, Object> clusters = (Map<String, Object>) esql.get("clusters");
421+
assertThat(clusters, hasKey(REMOTE_CLUSTER_NAME));
422+
assertThat(clusters, hasKey("(local)"));
423+
Map<String, Object> clusterData = (Map<String, Object>) clusters.get(REMOTE_CLUSTER_NAME);
424+
assertThat(clusterData, hasKey("total"));
425+
assertThat(clusterData, hasKey("skipped"));
426+
assertThat(clusterData, hasKey("took"));
427+
}
428+
398429
private RestClient remoteClusterClient() throws IOException {
399430
var clusterHosts = parseClusterHosts(remoteCluster.getHttpAddresses());
400431
return buildClient(restClientSettings(), clusterHosts.toArray(new HttpHost[0]));

x-pack/plugin/src/yamlRestTest/resources/rest-api-spec/test/esql/200_ccs_stats.yml

Lines changed: 0 additions & 115 deletions
This file was deleted.

0 commit comments

Comments
 (0)