|
22 | 22 | import org.apache.http.util.EntityUtils; |
23 | 23 | import org.elasticsearch.Version; |
24 | 24 | import org.elasticsearch.client.Request; |
25 | | -import org.elasticsearch.client.RequestOptions; |
26 | 25 | import org.elasticsearch.client.Response; |
27 | 26 | import org.elasticsearch.client.ResponseException; |
28 | 27 | import org.elasticsearch.client.RestClient; |
29 | 28 | import org.elasticsearch.client.WarningFailureException; |
30 | | -import org.elasticsearch.client.WarningsHandler; |
31 | 29 | import org.elasticsearch.cluster.metadata.IndexMetaData; |
32 | 30 | import org.elasticsearch.common.Booleans; |
33 | 31 | import org.elasticsearch.common.CheckedFunction; |
@@ -135,11 +133,10 @@ public void testSearch() throws Exception { |
135 | 133 | mappingsAndSettings.endObject(); |
136 | 134 | } |
137 | 135 | mappingsAndSettings.endObject(); |
| 136 | + |
138 | 137 | Request createIndex = new Request("PUT", "/" + index); |
139 | 138 | createIndex.setJsonEntity(Strings.toString(mappingsAndSettings)); |
140 | | - RequestOptions.Builder options = createIndex.getOptions().toBuilder(); |
141 | | - options.setWarningsHandler(WarningsHandler.PERMISSIVE); |
142 | | - createIndex.setOptions(options); |
| 139 | + createIndex.setOptions(allowTypesRemovalWarnings()); |
143 | 140 | client().performRequest(createIndex); |
144 | 141 |
|
145 | 142 | count = randomIntBetween(2000, 3000); |
@@ -200,11 +197,10 @@ public void testNewReplicasWork() throws Exception { |
200 | 197 | mappingsAndSettings.endObject(); |
201 | 198 | } |
202 | 199 | mappingsAndSettings.endObject(); |
| 200 | + |
203 | 201 | Request createIndex = new Request("PUT", "/" + index); |
204 | 202 | createIndex.setJsonEntity(Strings.toString(mappingsAndSettings)); |
205 | | - RequestOptions.Builder options = createIndex.getOptions().toBuilder(); |
206 | | - options.setWarningsHandler(WarningsHandler.PERMISSIVE); |
207 | | - createIndex.setOptions(options); |
| 203 | + createIndex.setOptions(allowTypesRemovalWarnings()); |
208 | 204 | client().performRequest(createIndex); |
209 | 205 |
|
210 | 206 | int numDocs = randomIntBetween(2000, 3000); |
@@ -320,12 +316,10 @@ public void testShrink() throws IOException { |
320 | 316 | } |
321 | 317 | } |
322 | 318 | mappingsAndSettings.endObject(); |
| 319 | + |
323 | 320 | Request createIndex = new Request("PUT", "/" + index); |
324 | 321 | createIndex.setJsonEntity(Strings.toString(mappingsAndSettings)); |
325 | | - RequestOptions.Builder options = createIndex.getOptions().toBuilder(); |
326 | | - options.setWarningsHandler(WarningsHandler.PERMISSIVE); |
327 | | - expectWarnings(RestIndexAction.TYPES_DEPRECATION_MESSAGE); |
328 | | - createIndex.setOptions(options); |
| 322 | + createIndex.setOptions(allowTypesRemovalWarnings()); |
329 | 323 | client().performRequest(createIndex); |
330 | 324 |
|
331 | 325 | numDocs = randomIntBetween(512, 1024); |
@@ -401,11 +395,10 @@ public void testShrinkAfterUpgrade() throws IOException { |
401 | 395 | } |
402 | 396 | } |
403 | 397 | mappingsAndSettings.endObject(); |
| 398 | + |
404 | 399 | Request createIndex = new Request("PUT", "/" + index); |
405 | 400 | createIndex.setJsonEntity(Strings.toString(mappingsAndSettings)); |
406 | | - RequestOptions.Builder options = createIndex.getOptions().toBuilder(); |
407 | | - options.setWarningsHandler(WarningsHandler.PERMISSIVE); |
408 | | - createIndex.setOptions(options); |
| 401 | + createIndex.setOptions(allowTypesRemovalWarnings()); |
409 | 402 | client().performRequest(createIndex); |
410 | 403 |
|
411 | 404 | numDocs = randomIntBetween(512, 1024); |
@@ -489,7 +482,7 @@ public void testRollover() throws IOException { |
489 | 482 |
|
490 | 483 | if (isRunningAgainstOldCluster()) { |
491 | 484 | Request rolloverRequest = new Request("POST", "/" + index + "_write/_rollover"); |
492 | | - rolloverRequest.setOptions(allowTypeRemovalWarnings()); |
| 485 | + rolloverRequest.setOptions(allowTypesRemovalWarnings()); |
493 | 486 | rolloverRequest.setJsonEntity("{" |
494 | 487 | + " \"conditions\": {" |
495 | 488 | + " \"max_docs\": 5" |
@@ -911,7 +904,7 @@ public void testSnapshotRestore() throws IOException { |
911 | 904 | if (isRunningAgainstOldCluster() == false && getOldClusterVersion().major < 7) { |
912 | 905 | createTemplateRequest.addParameter(INCLUDE_TYPE_NAME_PARAMETER, "true"); |
913 | 906 | } |
914 | | - createTemplateRequest.setOptions(allowTypeRemovalWarnings()); |
| 907 | + createTemplateRequest.setOptions(allowTypesRemovalWarnings()); |
915 | 908 |
|
916 | 909 | client().performRequest(createTemplateRequest); |
917 | 910 |
|
@@ -1122,7 +1115,7 @@ && getOldClusterVersion().onOrAfter(Version.V_6_1_0) && getOldClusterVersion().b |
1122 | 1115 | if (isRunningAgainstAncientCluster() == false) { |
1123 | 1116 | getTemplateRequest.addParameter(INCLUDE_TYPE_NAME_PARAMETER, "true"); |
1124 | 1117 | } |
1125 | | - getTemplateRequest.setOptions(allowTypeRemovalWarnings()); |
| 1118 | + getTemplateRequest.setOptions(allowTypesRemovalWarnings()); |
1126 | 1119 |
|
1127 | 1120 | Map<String, Object> getTemplateResponse = entityAsMap(client().performRequest(getTemplateRequest)); |
1128 | 1121 | Map<String, Object> expectedTemplate = new HashMap<>(); |
|
0 commit comments