Skip to content

Commit

Permalink
Fix timeout in testDowngradeRemoteClusterToBasic (#52322)
Browse files Browse the repository at this point in the history
- ESCCRRestTestCase#ensureYellow does not work well with assertBusy
- Increases timeout to 60s

Closes #52036
  • Loading branch information
dnhatn committed Feb 17, 2020
1 parent f243ff3 commit 646fcb8
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -966,14 +966,18 @@ protected static void ensureHealth(Consumer<Request> requestConsumer) throws IOE
}

protected static void ensureHealth(String index, Consumer<Request> requestConsumer) throws IOException {
ensureHealth(client(), index, requestConsumer);
}

protected static void ensureHealth(RestClient client, String index, Consumer<Request> requestConsumer) throws IOException {
Request request = new Request("GET", "/_cluster/health" + (index.trim().isEmpty() ? "" : "/" + index));
requestConsumer.accept(request);
try {
client().performRequest(request);
client.performRequest(request);
} catch (ResponseException e) {
if (e.getResponse().getStatusLine().getStatusCode() == HttpStatus.SC_REQUEST_TIMEOUT) {
try {
final Response clusterStateResponse = client().performRequest(new Request("GET", "/_cluster/state?pretty"));
final Response clusterStateResponse = client.performRequest(new Request("GET", "/_cluster/state?pretty"));
fail("timed out waiting for green state for index [" + index + "] " +
"cluster state [" + EntityUtils.toString(clusterStateResponse.getEntity()) + "]");
} catch (Exception inner) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.IOException;
import java.nio.file.Path;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import java.util.stream.Stream;

import static org.elasticsearch.common.xcontent.ObjectPath.eval;
Expand Down Expand Up @@ -50,7 +51,7 @@ public void testDowngradeRemoteClusterToBasic() throws Exception {
assertBusy(() -> {
ensureYellow(index1);
verifyDocuments(index1, 5, "filtered_field:true");
});
}, 60, TimeUnit.SECONDS);

String index2 = "logs-20190102";
try (RestClient leaderClient = buildLeaderClient()) {
Expand Down Expand Up @@ -90,7 +91,7 @@ public void testDowngradeRemoteClusterToBasic() throws Exception {
}
});
}
});
}, 60, TimeUnit.SECONDS);

// Manually following index2 also does not work after the downgrade:
Exception e = expectThrows(ResponseException.class, () -> followIndex("leader_cluster", index2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,15 @@ protected static void ensureYellow(final String index) throws IOException {
}

protected static void ensureYellow(final String index, final RestClient client) throws IOException {
final Request request = new Request("GET", "/_cluster/health/" + index);
request.addParameter("wait_for_status", "yellow");
request.addParameter("wait_for_active_shards", "1");
request.addParameter("wait_for_no_relocating_shards", "true");
request.addParameter("wait_for_no_initializing_shards", "true");
request.addParameter("timeout", "5s");
request.addParameter("level", "shards");
client.performRequest(request);
ensureHealth(client, index, request -> {
request.addParameter("wait_for_status", "yellow");
request.addParameter("wait_for_active_shards", "1");
request.addParameter("wait_for_no_relocating_shards", "true");
// follower index can be yellow even when its primary shards are still initializing as we bootstrap them using snapshot/restore.
request.addParameter("wait_for_no_initializing_shards", "true");
request.addParameter("timeout", "5s");
request.addParameter("level", "shards");
});
}

protected int countCcrNodeTasks() throws IOException {
Expand Down

0 comments on commit 646fcb8

Please sign in to comment.