Ver código fonte

Ignore warnings related to types deprecation in REST tests. (#35395)

Julie Tibshirani 7 anos atrás
pai
commit
bc799e4a6f

+ 8 - 4
test/framework/src/main/java/org/elasticsearch/test/rest/yaml/section/DoSection.java

@@ -301,10 +301,14 @@ public class DoSection implements ExecutableSection {
                      * 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);

+ 10 - 0
test/framework/src/test/java/org/elasticsearch/test/rest/yaml/section/DoSectionTests.java

@@ -128,6 +128,16 @@ public class DoSectionTests extends AbstractClientYamlTestFragmentParserTestCase
         }
     }
 
+    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" +