|
46 | 46 | import org.opensearch.common.action.ActionFuture;
|
47 | 47 | import org.opensearch.common.settings.Settings;
|
48 | 48 | import org.opensearch.common.unit.TimeValue;
|
| 49 | +import org.opensearch.index.IndexNotFoundException; |
49 | 50 | import org.opensearch.test.InternalTestCluster;
|
50 | 51 | import org.opensearch.test.OpenSearchIntegTestCase;
|
51 | 52 |
|
@@ -83,19 +84,17 @@ public void testSimpleLocalHealth() {
|
83 | 84 |
|
84 | 85 | public void testHealth() {
|
85 | 86 | logger.info("--> running cluster health on an index that does not exists");
|
86 |
| - ClusterHealthResponse healthResponse = client().admin() |
87 |
| - .cluster() |
88 |
| - .prepareHealth("test1") |
89 |
| - .setWaitForYellowStatus() |
90 |
| - .setTimeout("1s") |
91 |
| - .execute() |
92 |
| - .actionGet(); |
93 |
| - assertThat(healthResponse.isTimedOut(), equalTo(true)); |
94 |
| - assertThat(healthResponse.getStatus(), equalTo(ClusterHealthStatus.RED)); |
95 |
| - assertThat(healthResponse.getIndices().isEmpty(), equalTo(true)); |
96 |
| - |
| 87 | + expectThrows(IndexNotFoundException.class,()->{ |
| 88 | + client().admin() |
| 89 | + .cluster() |
| 90 | + .prepareHealth("test1") |
| 91 | + .setWaitForYellowStatus() |
| 92 | + .setTimeout("1s") |
| 93 | + .execute() |
| 94 | + .actionGet(); |
| 95 | + }); |
97 | 96 | logger.info("--> running cluster wide health");
|
98 |
| - healthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10s").execute().actionGet(); |
| 97 | + ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10s").execute().actionGet(); |
99 | 98 | assertThat(healthResponse.isTimedOut(), equalTo(false));
|
100 | 99 | assertThat(healthResponse.getStatus(), equalTo(ClusterHealthStatus.GREEN));
|
101 | 100 | assertThat(healthResponse.getIndices().isEmpty(), equalTo(true));
|
@@ -302,6 +301,7 @@ public void run() {
|
302 | 301 | }
|
303 | 302 |
|
304 | 303 | public void testWaitForEventsRetriesIfOtherConditionsNotMet() {
|
| 304 | + createIndex("index"); |
305 | 305 | final ActionFuture<ClusterHealthResponse> healthResponseFuture = client().admin()
|
306 | 306 | .cluster()
|
307 | 307 | .prepareHealth("index")
|
@@ -338,7 +338,6 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
|
338 | 338 | });
|
339 | 339 |
|
340 | 340 | try {
|
341 |
| - createIndex("index"); |
342 | 341 | assertFalse(client().admin().cluster().prepareHealth("index").setWaitForGreenStatus().get().isTimedOut());
|
343 | 342 |
|
344 | 343 | // at this point the original health response should not have returned: there was never a point where the index was green AND
|
|
0 commit comments