Skip to content

Commit 646fcb8

Browse files
committed
Fix timeout in testDowngradeRemoteClusterToBasic (#52322)
- ESCCRRestTestCase#ensureYellow does not work well with assertBusy - Increases timeout to 60s Closes #52036
1 parent f243ff3 commit 646fcb8

File tree

3 files changed

+18
-12
lines changed

3 files changed

+18
-12
lines changed

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -966,14 +966,18 @@ protected static void ensureHealth(Consumer<Request> requestConsumer) throws IOE
966966
}
967967

968968
protected static void ensureHealth(String index, Consumer<Request> requestConsumer) throws IOException {
969+
ensureHealth(client(), index, requestConsumer);
970+
}
971+
972+
protected static void ensureHealth(RestClient client, String index, Consumer<Request> requestConsumer) throws IOException {
969973
Request request = new Request("GET", "/_cluster/health" + (index.trim().isEmpty() ? "" : "/" + index));
970974
requestConsumer.accept(request);
971975
try {
972-
client().performRequest(request);
976+
client.performRequest(request);
973977
} catch (ResponseException e) {
974978
if (e.getResponse().getStatusLine().getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) {
975979
try {
976-
final Response clusterStateResponse = client().performRequest(new Request("GET", "/_cluster/state?pretty"));
980+
final Response clusterStateResponse = client.performRequest(new Request("GET", "/_cluster/state?pretty"));
977981
fail("timed out waiting for green state for index [" + index + "] " +
978982
"cluster state [" + EntityUtils.toString(clusterStateResponse.getEntity()) + "]");
979983
} 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
@@ -21,6 +21,7 @@
2121
import java.io.IOException;
2222
import java.nio.file.Path;
2323
import java.util.Map;
24+
import java.util.concurrent.TimeUnit;
2425
import java.util.stream.Stream;
2526

2627
import static org.elasticsearch.common.xcontent.ObjectPath.eval;
@@ -50,7 +51,7 @@ public void testDowngradeRemoteClusterToBasic() throws Exception {
5051
assertBusy(() -> {
5152
ensureYellow(index1);
5253
verifyDocuments(index1, 5, "filtered_field:true");
53-
});
54+
}, 60, TimeUnit.SECONDS);
5455

5556
String index2 = "logs-20190102";
5657
try (RestClient leaderClient = buildLeaderClient()) {
@@ -90,7 +91,7 @@ public void testDowngradeRemoteClusterToBasic() throws Exception {
9091
}
9192
});
9293
}
93-
});
94+
}, 60, TimeUnit.SECONDS);
9495

9596
// Manually following index2 also does not work after the downgrade:
9697
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: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,14 +215,15 @@ 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_active_shards", "1");
221+
request.addParameter("wait_for_no_relocating_shards", "true");
222+
// follower index can be yellow even when its primary shards are still initializing as we bootstrap them using snapshot/restore.
223+
request.addParameter("wait_for_no_initializing_shards", "true");
224+
request.addParameter("timeout", "5s");
225+
request.addParameter("level", "shards");
226+
});
226227
}
227228

228229
protected int countCcrNodeTasks() throws IOException {

0 commit comments

Comments
 (0)