Skip to content

Commit c398c4d

Browse files
authored
Add deprecation warnings handling to GET /index requests in tests. (#67573)
1 parent c0709f1 commit c398c4d

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

qa/mixed-cluster/src/test/java/org/elasticsearch/backwards/SearchWithMinCompatibleSearchNodeIT.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void prepareTestData() throws IOException {
6666
bwcVersion = bwcNodes.get(0).getVersion();
6767
newVersion = newNodes.get(0).getVersion();
6868

69-
if (client().performRequest(new Request("HEAD", "/" + index)).getStatusLine().getStatusCode() == 404) {
69+
if (indexExists(index) == false) {
7070
createIndex(index, Settings.builder()
7171
.put(IndexMetadata.INDEX_NUMBER_OF_SHARDS_SETTING.getKey(), numShards)
7272
.put(IndexMetadata.SETTING_NUMBER_OF_REPLICAS, numReplicas).build());

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

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,14 @@ protected Map<String, Object> getIndexSettingsAsMap(String index) throws IOExcep
12521252
}
12531253

12541254
protected static boolean indexExists(String index) throws IOException {
1255-
Response response = client().performRequest(new Request("HEAD", "/" + index));
1255+
final Request getRequest = new Request("HEAD", "/" + index);
1256+
getRequest.setOptions(expectVersionSpecificWarnings(v -> {
1257+
final String typesWarning = "[types removal] The parameter include_type_name should be explicitly specified in get indices " +
1258+
"requests to prepare for 7.0. In 7.0 include_type_name will default to 'false', which means responses will omit the type " +
1259+
"name in mapping definitions.";
1260+
v.compatible(typesWarning);
1261+
}));
1262+
Response response = client().performRequest(getRequest);
12561263
return RestStatus.OK.getStatus() == response.getStatusLine().getStatusCode();
12571264
}
12581265

0 commit comments

Comments
 (0)