diff --git a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java index c0cabc13a8abd..c21d80602c9a2 100644 --- a/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java +++ b/test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java @@ -293,18 +293,21 @@ void checkWarningHeaders(final List warningHeaders, final Version master if (matches) { final String message = matcher.group(1); // noinspection StatementWithEmptyBody - if (masterVersion.before(Version.V_7_0_0) + if ((masterVersion.before(Version.V_7_0_0) && message.equals("the default number of shards will change from [5] to [1] in 7.0.0; " + "if you wish to continue using the default of [5] shards, " - + "you must manage this on the create index request or with an index template")) { + + "you must manage this on the create index request or with an index template")) + || message.startsWith("[types removal]")) { /* - * This warning header will come back in the vast majority of our tests that create an index when running against an - * older master. Rather than rewrite our tests to assert this warning header, we assume that it is expected. + * We ignore two classes of warning headers: + * - The default number of shards warning will come back in the vast majority of our tests that + * create an index when running against an older master. Rather than rewrite our tests to assert + * this warning header, we assume that it is expected. + * - We skip warnings related to types deprecation so that we can continue to run the many + * mixed-version tests that used typed APIs. */ - } else { - if (expected.remove(message) == false) { - unexpected.add(header); - } + } else if (expected.remove(message) == false) { + unexpected.add(header); } } else { unmatched.add(header); diff --git a/test/framework/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java b/test/framework/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java index 0af7fe6845026..0a04fb06891d6 100644 --- a/test/framework/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java +++ b/test/framework/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java @@ -128,6 +128,16 @@ public void testWarningHeaders() { } } + public void testIgnoreTypesWarnings() { + String legitimateWarning = DeprecationLogger.formatWarning("warning"); + String typesWarning = DeprecationLogger.formatWarning("[types removal] " + + "The endpoint /{index}/{type}/_count is deprecated, use /{index}/_count instead."); + + DoSection section = new DoSection(new XContentLocation(1, 1)); + section.setExpectedWarningHeaders(singletonList("warning")); + section.checkWarningHeaders(Arrays.asList(legitimateWarning, typesWarning), Version.CURRENT); + } + public void testParseDoSectionNoBody() throws Exception { parser = createParser(YamlXContent.yamlXContent, "get:\n" +