Skip to content

Commit 1342f86

Browse files
authored
Fix timeout in testDowngradeRemoteClusterToBasic (#52284)
- ESCCRRestTestCase#ensureYellow does not work well with assertBusy - Increases timeout to 60s Closes #52036
1 parent 0898df4 commit 1342f86

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-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
@@ -950,14 +950,18 @@ protected static void ensureHealth(Consumer<Request> requestConsumer) throws IOE
950950
}
951951

952952
protected static void ensureHealth(String index, Consumer<Request> requestConsumer) throws IOException {
953+
ensureHealth(client(), index, requestConsumer);
954+
}
955+
956+
protected static void ensureHealth(RestClient client, String index, Consumer<Request> requestConsumer) throws IOException {
953957
Request request = new Request("GET", "/_cluster/health" + (index.isBlank() ? "" : "/" + index));
954958
requestConsumer.accept(request);
955959
try {
956-
client().performRequest(request);
960+
client.performRequest(request);
957961
} catch (ResponseException e) {
958962
if (e.getResponse().getStatusLine().getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) {
959963
try {
960-
final Response clusterStateResponse = client().performRequest(new Request("GET", "/_cluster/state?pretty"));
964+
final Response clusterStateResponse = client.performRequest(new Request("GET", "/_cluster/state?pretty"));
961965
fail("timed out waiting for green state for index [" + index + "] " +
962966
"cluster state [" + EntityUtils.toString(clusterStateResponse.getEntity()) + "]");
963967
} 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)