Skip to content

Commit 9ba0bdf

Browse files
committed
Dump cluster state if ensureGreen timed out in QA tests (#40133)
When the method ensureGreen in QA tests is timed out, it does not provide enough info for us to investigate why the testing index is not green yet. With this change, we will dump the cluster state if ensureGreen timed out. Relates #32027
1 parent d720a64 commit 9ba0bdf

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,20 @@ protected static void ensureGreen(String index) throws IOException {
808808
request.addParameter("wait_for_no_relocating_shards", "true");
809809
request.addParameter("timeout", "70s");
810810
request.addParameter("level", "shards");
811-
client().performRequest(request);
811+
try {
812+
client().performRequest(request);
813+
} catch (ResponseException e) {
814+
if (e.getResponse().getStatusLine().getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) {
815+
try {
816+
final Response clusterStateResponse = client().performRequest(new Request("GET", "/_cluster/state"));
817+
fail("timed out waiting for green state for index [" + index + "] " +
818+
"cluster state [" + EntityUtils.toString(clusterStateResponse.getEntity()) + "]");
819+
} catch (Exception inner) {
820+
e.addSuppressed(inner);
821+
}
822+
}
823+
throw e;
824+
}
812825
}
813826

814827
/**

0 commit comments

Comments
 (0)