Skip to content

Commit c20b92f

Browse files
authored
Respect CloseIndexRequest#waitForActiveShards in HLRC (#67374)
Also includes some changes for `master` that make #67246 a bit smaller. Relates #67158
1 parent 518d71d commit c20b92f

File tree

6 files changed

+6
-6
lines changed

6 files changed

+6
-6
lines changed

client/rest-high-level/src/main/java/org/elasticsearch/client/IndicesRequestConverters.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,7 @@ static Request closeIndex(CloseIndexRequest closeIndexRequest) {
137137
parameters.withTimeout(closeIndexRequest.timeout());
138138
parameters.withMasterTimeout(closeIndexRequest.masterNodeTimeout());
139139
parameters.withIndicesOptions(closeIndexRequest.indicesOptions());
140+
parameters.withWaitForActiveShards(closeIndexRequest.waitForActiveShards());
140141
request.addParameters(parameters.asMap());
141142
return request;
142143
}

client/rest-high-level/src/test/java/org/elasticsearch/client/IndicesRequestConvertersTests.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ public void testCloseIndex() {
426426
RequestConvertersTests.setRandomMasterTimeout(closeIndexRequest, expectedParams);
427427
RequestConvertersTests.setRandomIndicesOptions(closeIndexRequest::indicesOptions, closeIndexRequest::indicesOptions,
428428
expectedParams);
429+
RequestConvertersTests.setRandomWaitForActiveShards(closeIndexRequest::waitForActiveShards, expectedParams);
429430

430431
Request request = IndicesRequestConverters.closeIndex(closeIndexRequest);
431432
StringJoiner endpoint = new StringJoiner("/", "/", "").add(String.join(",", indices)).add("_close");

client/rest-high-level/src/test/java/org/elasticsearch/client/RankEvalIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public void testRankEvalRequest() throws IOException {
108108
}
109109

110110
// now try this when test2 is closed
111-
client().performRequest(new Request("POST", "index2/_close"));
111+
closeIndex("index2");
112112
rankEvalRequest.indicesOptions(IndicesOptions.fromParameters(null, "true", null, "false", SearchRequest.DEFAULT_INDICES_OPTIONS));
113113
response = execute(rankEvalRequest, highLevelClient()::rankEval, highLevelClient()::rankEvalAsync);
114114
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,8 +1217,7 @@ protected static boolean indexExists(String index) throws IOException {
12171217
}
12181218

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

12241223
protected static void openIndex(String index) throws IOException {

x-pack/plugin/ccr/qa/multi-cluster/src/test/java/org/elasticsearch/xpack/ccr/FollowIndexIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public void testFollowIndex() throws Exception {
8181
assertBusy(() -> verifyCcrMonitoring(leaderIndexName, followIndexName), 30, TimeUnit.SECONDS);
8282

8383
pauseFollow(followIndexName);
84-
assertOK(client().performRequest(new Request("POST", "/" + followIndexName + "/_close")));
84+
closeIndex(followIndexName);
8585
assertOK(client().performRequest(new Request("POST", "/" + followIndexName + "/_ccr/unfollow")));
8686
Exception e = expectThrows(ResponseException.class, () -> resumeFollow(followIndexName));
8787
assertThat(e.getMessage(), containsString("follow index [" + followIndexName + "] does not have ccr metadata"));

x-pack/plugin/searchable-snapshots/src/test/java/org/elasticsearch/xpack/searchablesnapshots/AbstractSearchableSnapshotsRestTestCase.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ public void testSearchResultsWhenFrozen() throws Exception {
142142

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

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

0 commit comments

Comments
 (0)