Fix timeout in testDowngradeRemoteClusterToBasic (#52322)

- ESCCRRestTestCase#ensureYellow does not work well with assertBusy
- Increases timeout to 60s

Closes #52036
This commit is contained in:
Nhat Nguyen 2020-02-17 15:05:42 -05:00 committed by GitHub
parent 48ccf36db9
commit bdb2e72ea4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 12 deletions

View File

@ -969,14 +969,18 @@ public abstract class ESRestTestCase extends ESTestCase {
}
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) {

View File

@ -19,6 +19,7 @@ import org.hamcrest.Matchers;
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;
@ -48,7 +49,7 @@ public class FollowIndexIT extends ESCCRRestTestCase {
assertBusy(() -> {
ensureYellow(index1);
verifyDocuments(index1, 5, "filtered_field:true");
});
}, 60, TimeUnit.SECONDS);
String index2 = "logs-20190102";
try (RestClient leaderClient = buildLeaderClient()) {
@ -88,7 +89,7 @@ public class FollowIndexIT extends ESCCRRestTestCase {
}
});
}
});
}, 60, TimeUnit.SECONDS);
// Manually following index2 also does not work after the downgrade:
Exception e = expectThrows(ResponseException.class, () -> followIndex("leader_cluster", index2));

View File

@ -215,14 +215,15 @@ public class ESCCRRestTestCase extends ESRestTestCase {
}
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 {