Skip to content

Commit 30c98d6

Browse files
committed
Fix timeout in testDowngradeRemoteClusterToBasic (elastic#52284)
- ESCCRRestTestCase#ensureYellow does not work well with assertBusy - Increases timeout to 60s Closes elastic#52036
1 parent cdd8f38 commit 30c98d6

File tree

3 files changed

+16
-13
lines changed

3 files changed

+16
-13
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -969,14 +969,18 @@ protected static void ensureHealth(Consumer<Request> requestConsumer) throws IOE
969969
}
970970

971971
protected static void ensureHealth(String index, Consumer<Request> requestConsumer) throws IOException {
972-
Request request = new Request("GET", "/_cluster/health" + (index.trim().isEmpty() ? "" : "/" + index));
972+
ensureHealth(client(), index, requestConsumer);
973+
}
974+
975+
protected static void ensureHealth(RestClient client, String index, Consumer<Request> requestConsumer) throws IOException {
976+
Request request = new Request("GET", "/_cluster/health" + (index.isBlank() ? "" : "/" + index));
973977
requestConsumer.accept(request);
974978
try {
975-
client().performRequest(request);
979+
client.performRequest(request);
976980
} catch (ResponseException e) {
977981
if (e.getResponse().getStatusLine().getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) {
978982
try {
979-
final Response clusterStateResponse = client().performRequest(new Request("GET", "/_cluster/state?pretty"));
983+
final Response clusterStateResponse = client.performRequest(new Request("GET", "/_cluster/state?pretty"));
980984
fail("timed out waiting for green state for index [" + index + "] " +
981985
"cluster state [" + EntityUtils.toString(clusterStateResponse.getEntity()) + "]");
982986
} catch (Exception inner) {

x-pack/plugin/ccr/qa/downgrade-to-basic-license/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import java.io.IOException;
2020
import java.nio.file.Path;
2121
import java.util.Map;
22+
import java.util.concurrent.TimeUnit;
2223
import java.util.stream.Stream;
2324

2425
import static org.elasticsearch.common.xcontent.ObjectPath.eval;
@@ -48,7 +49,7 @@ public void testDowngradeRemoteClusterToBasic() throws Exception {
4849
assertBusy(() -> {
4950
ensureYellow(index1);
5051
verifyDocuments(index1, 5, "filtered_field:true");
51-
});
52+
}, 60, TimeUnit.SECONDS);
5253

5354
String index2 = "logs-20190102";
5455
try (RestClient leaderClient = buildLeaderClient()) {
@@ -88,7 +89,7 @@ public void testDowngradeRemoteClusterToBasic() throws Exception {
8889
}
8990
});
9091
}
91-
});
92+
}, 60, TimeUnit.SECONDS);
9293

9394
// Manually following index2 also does not work after the downgrade:
9495
Exception e = expectThrows(ResponseException.class, () -> followIndex("leader_cluster", index2));

x-pack/plugin/ccr/qa/src/main/java/org/elasticsearch/xpack/ccr/ESCCRRestTestCase.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,12 @@ protected static void ensureYellow(final String index) throws IOException {
215215
}
216216

217217
protected static void ensureYellow(final String index, final RestClient client) throws IOException {
218-
final Request request = new Request("GET", "/_cluster/health/" + index);
219-
request.addParameter("wait_for_status", "yellow");
220-
request.addParameter("wait_for_active_shards", "1");
221-
request.addParameter("wait_for_no_relocating_shards", "true");
222-
request.addParameter("wait_for_no_initializing_shards", "true");
223-
request.addParameter("timeout", "5s");
224-
request.addParameter("level", "shards");
225-
client.performRequest(request);
218+
ensureHealth(client, index, request -> {
219+
request.addParameter("wait_for_status", "yellow");
220+
request.addParameter("wait_for_no_relocating_shards", "true");
221+
request.addParameter("timeout", "5s");
222+
request.addParameter("level", "shards");
223+
});
226224
}
227225

228226
protected int countCcrNodeTasks() throws IOException {

0 commit comments

Comments
 (0)