From dc09915327f66f4d8987495aee188c86aa067793 Mon Sep 17 00:00:00 2001 From: hawk huang Date: Fri, 24 Jul 2026 16:56:49 +0100 Subject: [PATCH] [ESQL] Skip CCQ tests when remote skipped due to connect_transport_exception When a remote cluster is unavailable during query execution, EsqlCCSUtils returns a 200 OK with is_partial=true and the remote cluster marked status=skipped with a connect_transport_exception failure. CCQ csv-spec tests for lookup indices are particularly vulnerable because they query remote-only (no local fallback), so any transient remote outage produces an empty result set that fails the row-count assertion. Instead of failing in assertNotPartial, detect this specific pattern and skip the test via JUnit Assume, treating it as an infrastructure flake rather than a product failure. --- .../xpack/esql/qa/rest/RestEsqlTestCase.java | 53 ++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java index 7fd8c05295a4f..aff964d281807 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/RestEsqlTestCase.java @@ -37,6 +37,7 @@ import org.elasticsearch.xpack.esql.action.EsqlCapabilities; import org.junit.After; import org.junit.Assert; +import org.junit.Assume; import org.junit.Before; import org.junit.Rule; @@ -2240,8 +2241,58 @@ protected static Response performRequest(Request request) throws IOException { static void assertNotPartial(Map answer) { var clusters = answer.get("_clusters"); + var isPartial = answer.get("is_partial"); + if (Boolean.TRUE.equals(isPartial) && isSkippedDueToConnectTransportException(clusters)) { + // Remote cluster(s) unavailable during execution — not a product bug; skip rather than fail. + Assume.assumeTrue("Remote cluster(s) skipped due to connect_transport_exception; treating as infrastructure flake", false); + } var reason = "unexpected partial results" + (clusters != null ? ": _clusters=" + clusters : ""); - assertThat(reason, answer.get("is_partial"), anyOf(nullValue(), is(false))); + assertThat(reason, isPartial, anyOf(nullValue(), is(false))); + } + + /** + * Returns true when every cluster entry in the {@code _clusters.details} map has {@code status=skipped} + * and at least one failure whose {@code reason.reason} contains {@code connect_transport_exception}. + * This pattern indicates a transient remote-cluster connectivity failure rather than a product bug. + */ + @SuppressWarnings("unchecked") + private static boolean isSkippedDueToConnectTransportException(Object clusters) { + if (!(clusters instanceof Map clustersMap)) { + return false; + } + var details = clustersMap.get("details"); + if (!(details instanceof Map detailsMap) || detailsMap.isEmpty()) { + return false; + } + for (var clusterDetail : detailsMap.values()) { + if (!(clusterDetail instanceof Map clusterMap)) { + return false; + } + if ("skipped".equals(clusterMap.get("status")) == false) { + return false; + } + var failures = clusterMap.get("failures"); + if (!(failures instanceof List failureList) || failureList.isEmpty()) { + return false; + } + boolean foundConnectError = false; + for (var failure : failureList) { + if (failure instanceof Map failureMap) { + var reason = failureMap.get("reason"); + if (reason instanceof Map reasonMap) { + var reasonStr = reasonMap.get("reason"); + if (reasonStr instanceof String s && s.contains("connect_transport_exception")) { + foundConnectError = true; + break; + } + } + } + } + if (foundConnectError == false) { + return false; + } + } + return true; } private static void assertWarnings(Response response, AssertWarnings assertWarnings, Object context) {