From bc799e4a6fb8bf2e294cd61bb6b6c4e7a4018248 Mon Sep 17 00:00:00 2001 From: Julie Tibshirani Date: Tue, 13 Nov 2018 11:56:01 -0800 Subject: [PATCH] Ignore warnings related to types deprecation in REST tests. (#35395) --- .../test/rest/yaml/section/DoSection.java | 12 ++++++++---- .../test/rest/yaml/section/DoSectionTests.java | 10 ++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) 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..c63e726ea2a0a 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 @@ -301,10 +301,14 @@ void checkWarningHeaders(final List warningHeaders, final Version master * 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. */ - } else { - if (expected.remove(message) == false) { - unexpected.add(header); - } + } else // noinspection StatementWithEmptyBody + if (message.startsWith("[types removal]")) { + /* + * 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 { 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" +