Skip to content

Commit 307cd0d

Browse files
authored
Skip spec tests when test cluster broken (#135862) (#135986)
If the test clusters are broken, we should stop running spec tests; otherwise we will see a lot of failures, making triage and investigating more difficult.
1 parent d9f84ec commit 307cd0d

File tree

2 files changed

+23
-1
lines changed
  • x-pack/plugin/esql/qa/server

2 files changed

+23
-1
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ protected boolean supportsSourceFieldMapping() {
5353

5454
@Before
5555
public void configureChunks() throws IOException {
56+
assumeTrue("test clusters were broken", testClustersOk);
5657
boolean smallChunks = randomBoolean();
5758
Request request = new Request("PUT", "/_cluster/settings");
5859
XContentBuilder builder = JsonXContent.contentBuilder().startObject().startObject("persistent");

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

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,11 @@ protected EsqlSpecTestCase(
122122
}
123123

124124
private static boolean dataLoaded = false;
125+
protected static boolean testClustersOk = true;
125126

126127
@Before
127128
public void setup() throws IOException {
129+
assumeTrue("test clusters were broken", testClustersOk);
128130
boolean supportsLookup = supportsIndexModeLookup();
129131
boolean supportsSourceMapping = supportsSourceFieldMapping();
130132
boolean supportsInferenceTestService = supportsInferenceTestService();
@@ -140,6 +142,9 @@ public void setup() throws IOException {
140142

141143
@AfterClass
142144
public static void wipeTestData() throws IOException {
145+
if (testClustersOk == false) {
146+
return;
147+
}
143148
try {
144149
dataLoaded = false;
145150
adminClient().performRequest(new Request("DELETE", "/*"));
@@ -162,11 +167,25 @@ public final void test() throws Throwable {
162167
shouldSkipTest(testName);
163168
doTest();
164169
} catch (Exception e) {
170+
ensureTestClustersAreOk(e);
165171
throw reworkException(e);
166172
}
167173
}
168174

175+
protected void ensureTestClustersAreOk(Exception failure) {
176+
try {
177+
ensureHealth(client(), "", (request) -> {
178+
request.addParameter("wait_for_status", "yellow");
179+
request.addParameter("level", "shards");
180+
});
181+
} catch (Exception inner) {
182+
testClustersOk = false;
183+
failure.addSuppressed(inner);
184+
}
185+
}
186+
169187
protected void shouldSkipTest(String testName) throws IOException {
188+
assumeTrue("test clusters were broken", testClustersOk);
170189
if (requiresInferenceEndpoint()) {
171190
assumeTrue("Inference test service needs to be supported", supportsInferenceTestService());
172191
}
@@ -374,7 +393,9 @@ protected boolean preserveClusterUponCompletion() {
374393

375394
@After
376395
public void assertRequestBreakerEmptyAfterTests() throws Exception {
377-
assertRequestBreakerEmpty();
396+
if (testClustersOk) {
397+
assertRequestBreakerEmpty();
398+
}
378399
}
379400

380401
public static void assertRequestBreakerEmpty() throws Exception {

0 commit comments

Comments
 (0)