|
10 | 10 | import org.elasticsearch.ExceptionsHelper; |
11 | 11 | import org.elasticsearch.ResourceNotFoundException; |
12 | 12 | import org.elasticsearch.action.ActionFuture; |
| 13 | +import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; |
13 | 14 | import org.elasticsearch.action.admin.cluster.node.tasks.cancel.CancelTasksRequest; |
14 | 15 | import org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskRequest; |
15 | 16 | import org.elasticsearch.action.admin.cluster.node.tasks.get.GetTaskResponse; |
@@ -1940,14 +1941,19 @@ private Map<String, Object> setupTwoClusters() { |
1940 | 1941 | .setSettings(Settings.builder().put(remoteSettings.build())) |
1941 | 1942 | .setMapping("@timestamp", "type=date", "f", "type=text") |
1942 | 1943 | ); |
1943 | | - assertFalse( |
1944 | | - client(REMOTE_CLUSTER).admin() |
1945 | | - .cluster() |
1946 | | - .prepareHealth(TEST_REQUEST_TIMEOUT, remoteIndex) |
1947 | | - .setWaitForYellowStatus() |
1948 | | - .setTimeout(TimeValue.timeValueSeconds(10)) |
1949 | | - .get() |
1950 | | - .isTimedOut() |
| 1944 | + // Wait for yellow and no initializing shards so all assigned shards are STARTED before tests run searches. |
| 1945 | + ClusterHealthResponse healthResponse = client(REMOTE_CLUSTER).admin() |
| 1946 | + .cluster() |
| 1947 | + .prepareHealth(TEST_REQUEST_TIMEOUT, remoteIndex) |
| 1948 | + .setWaitForYellowStatus() |
| 1949 | + .setWaitForNoInitializingShards(true) |
| 1950 | + .setTimeout(TimeValue.timeValueSeconds(10)) |
| 1951 | + .get(); |
| 1952 | + assertFalse("remote index health check timed out", healthResponse.isTimedOut()); |
| 1953 | + assertEquals( |
| 1954 | + "remote index should have no initializing shards, had: " + healthResponse.getInitializingShards(), |
| 1955 | + 0, |
| 1956 | + healthResponse.getInitializingShards() |
1951 | 1957 | ); |
1952 | 1958 | indexDocs(client(REMOTE_CLUSTER), remoteIndex); |
1953 | 1959 |
|
|
0 commit comments