Skip to content

Commit 1848ea3

Browse files
committed
Apply Spotless formatting
Signed-off-by: Prakash Bhardwaj <bhardwajprakash653@gmail.com>
1 parent ff4cc79 commit 1848ea3

2 files changed

Lines changed: 20 additions & 21 deletions

File tree

client/rest-high-level/src/test/java/org/opensearch/client/ClusterClientIT.java

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -339,13 +339,18 @@ public void testClusterHealthNotFoundIndex() throws IOException {
339339
createIndex("index", Settings.EMPTY);
340340
ClusterHealthRequest request = new ClusterHealthRequest("notexisted-index");
341341
request.timeout("5s");
342-
ClusterHealthResponse response = execute(request, highLevelClient().cluster()::health, highLevelClient().cluster()::healthAsync);
343342

344-
assertThat(response, notNullValue());
345-
assertThat(response.isTimedOut(), equalTo(true));
346-
assertThat(response.status(), equalTo(RestStatus.REQUEST_TIMEOUT));
347-
assertThat(response.getStatus(), equalTo(ClusterHealthStatus.RED));
348-
assertNoIndices(response);
343+
// After the fix, querying non-existent index should return 404 instead of timeout
344+
OpenSearchException exception = expectThrows(
345+
OpenSearchException.class,
346+
() -> execute(request, highLevelClient().cluster()::health, highLevelClient().cluster()::healthAsync)
347+
);
348+
349+
assertThat(exception.status(), equalTo(RestStatus.NOT_FOUND));
350+
assertThat(
351+
exception.getMessage(),
352+
equalTo("OpenSearch exception [type=index_not_found_exception, reason=no such index [notexisted-index]]")
353+
);
349354
}
350355

351356
public void testRemoteInfo() throws Exception {

server/src/internalClusterTest/java/org/opensearch/cluster/ClusterHealthIT.java

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -86,18 +86,18 @@ public void testHealth() {
8686
logger.info("--> running cluster health on an index that does not exists");
8787
IndexNotFoundException exception = expectThrows(
8888
IndexNotFoundException.class,
89-
() -> client().admin()
90-
.cluster()
91-
.prepareHealth("test1")
92-
.setWaitForYellowStatus()
93-
.setTimeout("1s")
94-
.execute()
95-
.actionGet()
89+
() -> client().admin().cluster().prepareHealth("test1").setWaitForYellowStatus().setTimeout("1s").execute().actionGet()
9690
);
9791
assertThat(exception.getMessage(), equalTo("no such index [test1]"));
9892

9993
logger.info("--> running cluster wide health");
100-
ClusterHealthResponse healthResponse = client().admin().cluster().prepareHealth().setWaitForGreenStatus().setTimeout("10s").execute().actionGet();
94+
ClusterHealthResponse healthResponse = client().admin()
95+
.cluster()
96+
.prepareHealth()
97+
.setWaitForGreenStatus()
98+
.setTimeout("10s")
99+
.execute()
100+
.actionGet();
101101
assertThat(healthResponse.isTimedOut(), equalTo(false));
102102
assertThat(healthResponse.getStatus(), equalTo(ClusterHealthStatus.GREEN));
103103
assertThat(healthResponse.getIndices().isEmpty(), equalTo(true));
@@ -114,13 +114,7 @@ public void testHealth() {
114114
logger.info("--> running cluster health on an index that does exists and an index that doesn't exists");
115115
IndexNotFoundException exception2 = expectThrows(
116116
IndexNotFoundException.class,
117-
() -> client().admin()
118-
.cluster()
119-
.prepareHealth("test1", "test2")
120-
.setWaitForYellowStatus()
121-
.setTimeout("1s")
122-
.execute()
123-
.actionGet()
117+
() -> client().admin().cluster().prepareHealth("test1", "test2").setWaitForYellowStatus().setTimeout("1s").execute().actionGet()
124118
);
125119
assertThat(exception2.getMessage(), equalTo("no such index [test2]"));
126120
}

0 commit comments

Comments
 (0)