|
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; |
@@ -1946,14 +1947,19 @@ private Map<String, Object> setupTwoClusters() { |
1946 | 1947 | .setSettings(Settings.builder().put(remoteSettings.build())) |
1947 | 1948 | .setMapping("@timestamp", "type=date", "f", "type=text") |
1948 | 1949 | ); |
1949 | | - assertFalse( |
1950 | | - client(REMOTE_CLUSTER).admin() |
1951 | | - .cluster() |
1952 | | - .prepareHealth(TEST_REQUEST_TIMEOUT, remoteIndex) |
1953 | | - .setWaitForYellowStatus() |
1954 | | - .setTimeout(TimeValue.timeValueSeconds(10)) |
1955 | | - .get() |
1956 | | - .isTimedOut() |
| 1950 | + // Wait for yellow and no initializing shards so all assigned shards are STARTED before tests run searches. |
| 1951 | + ClusterHealthResponse healthResponse = client(REMOTE_CLUSTER).admin() |
| 1952 | + .cluster() |
| 1953 | + .prepareHealth(TEST_REQUEST_TIMEOUT, remoteIndex) |
| 1954 | + .setWaitForYellowStatus() |
| 1955 | + .setWaitForNoInitializingShards(true) |
| 1956 | + .setTimeout(TimeValue.timeValueSeconds(10)) |
| 1957 | + .get(); |
| 1958 | + assertFalse("remote index health check timed out", healthResponse.isTimedOut()); |
| 1959 | + assertEquals( |
| 1960 | + "remote index should have no initializing shards, had: " + healthResponse.getInitializingShards(), |
| 1961 | + 0, |
| 1962 | + healthResponse.getInitializingShards() |
1957 | 1963 | ); |
1958 | 1964 | indexDocs(client(REMOTE_CLUSTER), remoteIndex); |
1959 | 1965 |
|
|
0 commit comments