Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.opensearch.common.action.ActionFuture;
import org.opensearch.common.settings.Settings;
import org.opensearch.common.unit.TimeValue;
import org.opensearch.index.IndexNotFoundException;
import org.opensearch.test.InternalTestCluster;
import org.opensearch.test.OpenSearchIntegTestCase;

Expand Down Expand Up @@ -83,19 +84,17 @@ public void testSimpleLocalHealth() {

public void testHealth() {
logger.info("--> running cluster health on an index that does not exists");
expectThrows(IndexNotFoundException.class, () -> {
client().admin().cluster().prepareHealth("test1").setWaitForYellowStatus().setTimeout("1s").execute().actionGet();
});
logger.info("--> running cluster wide health");
ClusterHealthResponse healthResponse = client().admin()
.cluster()
.prepareHealth("test1")
.setWaitForYellowStatus()
.setTimeout("1s")
.prepareHealth()
.setWaitForGreenStatus()
.setTimeout("10s")
.execute()
.actionGet();
assertThat(healthResponse.isTimedOut(), equalTo(true));
assertThat(healthResponse.getStatus(), equalTo(ClusterHealthStatus.RED));
assertThat(healthResponse.getIndices().isEmpty(), equalTo(true));

logger.info("--> running cluster wide health");
healthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10s").execute().actionGet();
assertThat(healthResponse.isTimedOut(), equalTo(false));
assertThat(healthResponse.getStatus(), equalTo(ClusterHealthStatus.GREEN));
assertThat(healthResponse.getIndices().isEmpty(), equalTo(true));
Expand Down Expand Up @@ -302,6 +301,7 @@ public void run() {
}

public void testWaitForEventsRetriesIfOtherConditionsNotMet() {
createIndex("index");
final ActionFuture<ClusterHealthResponse> healthResponseFuture = client().admin()
.cluster()
.prepareHealth("index")
Expand Down Expand Up @@ -338,7 +338,6 @@ public void clusterStateProcessed(String source, ClusterState oldState, ClusterS
});

try {
createIndex("index");
assertFalse(client().admin().cluster().prepareHealth("index").setWaitForGreenStatus().get().isTimedOut());

// at this point the original health response should not have returned: there was never a point where the index was green AND
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -419,13 +419,9 @@ static int prepareResponse(
}
}
if (CollectionUtils.isEmpty(request.indices()) == false) {
try {
indexNameExpressionResolver.concreteIndexNames(clusterState, IndicesOptions.strictExpand(), request);
waitForCounter++;
} catch (IndexNotFoundException e) {
response.setStatus(ClusterHealthStatus.RED); // no indices, make sure its RED
// missing indices, wait a bit more...
}
indexNameExpressionResolver.concreteIndexNames(clusterState, IndicesOptions.strictExpand(), request);
waitForCounter++;

}
if (!request.waitForNodes().isEmpty()) {
if (request.waitForNodes().startsWith(">=")) {
Expand Down
Loading