Skip to content

Commit f6c0a24

Browse files
authored
[Test] Add client param indexExists (#115180)
This allows us to use the admin client to easily check whether an index exists (that may not be visible to the standard client)
1 parent 2ff6bb0 commit f6c0a24

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

test/framework/src/main/java/org/elasticsearch/test/rest/ESRestTestCase.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1896,7 +1896,11 @@ protected Map<String, Object> getIndexMappingAsMap(String index) throws IOExcept
18961896
}
18971897

18981898
protected static boolean indexExists(String index) throws IOException {
1899-
Response response = client().performRequest(new Request("HEAD", "/" + index));
1899+
return indexExists(client(), index);
1900+
}
1901+
1902+
protected static boolean indexExists(RestClient client, String index) throws IOException {
1903+
Response response = client.performRequest(new Request("HEAD", "/" + index));
19001904
return RestStatus.OK.getStatus() == response.getStatusLine().getStatusCode();
19011905
}
19021906

0 commit comments

Comments
 (0)