Skip to content

Fix timeout in testDowngradeRemoteClusterToBasic #52322

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Feb 17, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -969,14 +969,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 @@ -19,6 +19,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 @@ -48,7 +49,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 @@ -88,7 +89,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