|
21 | 21 |
|
22 | 22 | import org.elasticsearch.action.admin.cluster.health.ClusterHealthResponse; |
23 | 23 | import org.elasticsearch.action.search.SearchResponse; |
| 24 | +import org.elasticsearch.action.support.ActiveShardCount; |
24 | 25 | import org.elasticsearch.action.support.IndicesOptions; |
25 | 26 | import org.elasticsearch.cluster.health.ClusterHealthStatus; |
26 | 27 | import org.elasticsearch.cluster.metadata.IndexMetaData; |
@@ -159,6 +160,22 @@ public void testAutoExpandNumberOfReplicas0ToData() throws IOException { |
159 | 160 | assertThat(clusterHealth.getIndices().get("test").getNumberOfReplicas(), equalTo(1)); |
160 | 161 | assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 2)); |
161 | 162 |
|
| 163 | + if (randomBoolean()) { |
| 164 | + assertAcked(client().admin().indices().prepareClose("test").setWaitForActiveShards(ActiveShardCount.ALL)); |
| 165 | + |
| 166 | + clusterHealth = client().admin().cluster().prepareHealth() |
| 167 | + .setWaitForEvents(Priority.LANGUID) |
| 168 | + .setWaitForGreenStatus() |
| 169 | + .setWaitForActiveShards(numShards.numPrimaries * 2) |
| 170 | + .execute().actionGet(); |
| 171 | + logger.info("--> done cluster health, status {}", clusterHealth.getStatus()); |
| 172 | + assertThat(clusterHealth.isTimedOut(), equalTo(false)); |
| 173 | + assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN)); |
| 174 | + assertThat(clusterHealth.getIndices().get("test").getActivePrimaryShards(), equalTo(numShards.numPrimaries)); |
| 175 | + assertThat(clusterHealth.getIndices().get("test").getNumberOfReplicas(), equalTo(1)); |
| 176 | + assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 2)); |
| 177 | + } |
| 178 | + |
162 | 179 | final long settingsVersion = |
163 | 180 | client().admin().cluster().prepareState().get().getState().metaData().index("test").getSettingsVersion(); |
164 | 181 |
|
@@ -248,6 +265,22 @@ public void testAutoExpandNumberReplicas1ToData() throws IOException { |
248 | 265 | assertThat(clusterHealth.getIndices().get("test").getNumberOfReplicas(), equalTo(1)); |
249 | 266 | assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 2)); |
250 | 267 |
|
| 268 | + if (randomBoolean()) { |
| 269 | + assertAcked(client().admin().indices().prepareClose("test").setWaitForActiveShards(ActiveShardCount.ALL)); |
| 270 | + |
| 271 | + clusterHealth = client().admin().cluster().prepareHealth() |
| 272 | + .setWaitForEvents(Priority.LANGUID) |
| 273 | + .setWaitForGreenStatus() |
| 274 | + .setWaitForActiveShards(numShards.numPrimaries * 2) |
| 275 | + .execute().actionGet(); |
| 276 | + logger.info("--> done cluster health, status {}", clusterHealth.getStatus()); |
| 277 | + assertThat(clusterHealth.isTimedOut(), equalTo(false)); |
| 278 | + assertThat(clusterHealth.getStatus(), equalTo(ClusterHealthStatus.GREEN)); |
| 279 | + assertThat(clusterHealth.getIndices().get("test").getActivePrimaryShards(), equalTo(numShards.numPrimaries)); |
| 280 | + assertThat(clusterHealth.getIndices().get("test").getNumberOfReplicas(), equalTo(1)); |
| 281 | + assertThat(clusterHealth.getIndices().get("test").getActiveShards(), equalTo(numShards.numPrimaries * 2)); |
| 282 | + } |
| 283 | + |
251 | 284 | final long settingsVersion = |
252 | 285 | client().admin().cluster().prepareState().get().getState().metaData().index("test").getSettingsVersion(); |
253 | 286 | logger.info("--> add another node, should increase the number of replicas"); |
|
0 commit comments