Skip to content

Commit

Permalink
Minor tidy-up for close-index REST requests
Browse files Browse the repository at this point in the history
Some changes for `master` that make elastic#67246 a bit easier.

Relates elastic#67158
  • Loading branch information
DaveCTurner committed Jan 12, 2021
1 parent 443f882 commit da1b219
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ static Request closeIndex(CloseIndexRequest closeIndexRequest) {
parameters.withTimeout(closeIndexRequest.timeout());
parameters.withMasterTimeout(closeIndexRequest.masterNodeTimeout());
parameters.withIndicesOptions(closeIndexRequest.indicesOptions());
parameters.withWaitForActiveShards(closeIndexRequest.waitForActiveShards());
request.addParameters(parameters.asMap());
return request;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,7 @@ public void testCloseIndex() {
RequestConvertersTests.setRandomMasterTimeout(closeIndexRequest, expectedParams);
RequestConvertersTests.setRandomIndicesOptions(closeIndexRequest::indicesOptions, closeIndexRequest::indicesOptions,
expectedParams);
RequestConvertersTests.setRandomWaitForActiveShards(closeIndexRequest::waitForActiveShards, expectedParams);

Request request = IndicesRequestConverters.closeIndex(closeIndexRequest);
StringJoiner endpoint = new StringJoiner("/", "/", "").add(String.join(",", indices)).add("_close");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public void testRankEvalRequest() throws IOException {
}

// now try this when test2 is closed
client().performRequest(new Request("POST", "index2/_close"));
closeIndex("index2");
rankEvalRequest.indicesOptions(IndicesOptions.fromParameters(null, "true", null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1217,8 +1217,7 @@ protected static boolean indexExists(String index) throws IOException {
}

protected static void closeIndex(String index) throws IOException {
Response response = client().performRequest(new Request("POST", "/" + index + "/_close"));
assertThat(response.getStatusLine().getStatusCode(), equalTo(RestStatus.OK.getStatus()));
assertOK(client().performRequest(new Request(HttpPost.METHOD_NAME, "/" + index + "/_close")));
}

protected static void openIndex(String index) throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testFollowIndex() throws Exception {
assertBusy(() -> verifyCcrMonitoring(leaderIndexName, followIndexName), 30, TimeUnit.SECONDS);

pauseFollow(followIndexName);
assertOK(client().performRequest(new Request("POST", "/" + followIndexName + "/_close")));
closeIndex(followIndexName);
assertOK(client().performRequest(new Request("POST", "/" + followIndexName + "/_ccr/unfollow")));
Exception e = expectThrows(ResponseException.class, () -> resumeFollow(followIndexName));
assertThat(e.getMessage(), containsString("follow index [" + followIndexName + "] does not have ccr metadata"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ public void testSearchResultsWhenFrozen() throws Exception {

public void testCloseAndReopen() throws Exception {
runSearchableSnapshotsTest((restoredIndexName, numDocs) -> {
final Request closeRequest = new Request(HttpPost.METHOD_NAME, restoredIndexName + "/_close");
assertOK(client().performRequest(closeRequest));
closeIndex(restoredIndexName);
ensureGreen(restoredIndexName);

final Request openRequest = new Request(HttpPost.METHOD_NAME, restoredIndexName + "/_open");
Expand Down

0 comments on commit da1b219

Please sign in to comment.