diff --git a/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlSpecIT.java b/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlSpecIT.java index a21c416ba8741..dacc34167955a 100644 --- a/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlSpecIT.java +++ b/x-pack/plugin/esql/qa/server/single-node/src/javaRestTest/java/org/elasticsearch/xpack/esql/qa/single_node/EsqlSpecIT.java @@ -53,6 +53,7 @@ protected boolean supportsSourceFieldMapping() { @Before public void configureChunks() throws IOException { + assumeTrue("test clusters were broken", testClustersOk); boolean smallChunks = randomBoolean(); Request request = new Request("PUT", "/_cluster/settings"); XContentBuilder builder = JsonXContent.contentBuilder().startObject().startObject("persistent"); diff --git a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java index 33ff75519348c..fed250051d84d 100644 --- a/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java +++ b/x-pack/plugin/esql/qa/server/src/main/java/org/elasticsearch/xpack/esql/qa/rest/EsqlSpecTestCase.java @@ -122,9 +122,11 @@ protected EsqlSpecTestCase( } private static boolean dataLoaded = false; + protected static boolean testClustersOk = true; @Before public void setup() throws IOException { + assumeTrue("test clusters were broken", testClustersOk); boolean supportsLookup = supportsIndexModeLookup(); boolean supportsSourceMapping = supportsSourceFieldMapping(); boolean supportsInferenceTestService = supportsInferenceTestService(); @@ -140,6 +142,9 @@ public void setup() throws IOException { @AfterClass public static void wipeTestData() throws IOException { + if (testClustersOk == false) { + return; + } try { dataLoaded = false; adminClient().performRequest(new Request("DELETE", "/*")); @@ -162,11 +167,25 @@ public final void test() throws Throwable { shouldSkipTest(testName); doTest(); } catch (Exception e) { + ensureTestClustersAreOk(e); throw reworkException(e); } } + protected void ensureTestClustersAreOk(Exception failure) { + try { + ensureHealth(client(), "", (request) -> { + request.addParameter("wait_for_status", "yellow"); + request.addParameter("level", "shards"); + }); + } catch (Exception inner) { + testClustersOk = false; + failure.addSuppressed(inner); + } + } + protected void shouldSkipTest(String testName) throws IOException { + assumeTrue("test clusters were broken", testClustersOk); if (requiresInferenceEndpoint()) { assumeTrue("Inference test service needs to be supported", supportsInferenceTestService()); } @@ -374,7 +393,9 @@ protected boolean preserveClusterUponCompletion() { @After public void assertRequestBreakerEmptyAfterTests() throws Exception { - assertRequestBreakerEmpty(); + if (testClustersOk) { + assertRequestBreakerEmpty(); + } } public static void assertRequestBreakerEmpty() throws Exception {