Browse Source

[Rest Api Compatibility] Enhance error message with ref to dev guide (#86831)

When a rest api compatibility test fails a message should be enriched
to include a ref to a developers guide.
The developers guide contains more information on how to troubleshoot
the test failure, where to look for transform tests etc.

relates #85955
Przemyslaw Gomulka 3 years ago
parent
commit
12980fd8e3

+ 1 - 0
build-tools-internal/src/main/java/org/elasticsearch/gradle/internal/rest/compat/YamlRestCompatTestPlugin.java

@@ -198,6 +198,7 @@ public class YamlRestCompatTestPlugin implements Plugin<Project> {
         // setup the test task
         Provider<RestIntegTestTask> yamlRestCompatTestTask = RestTestUtil.registerTestTask(project, yamlCompatTestSourceSet, testTaskName);
         project.getTasks().withType(RestIntegTestTask.class).named(testTaskName).configure(testTask -> {
+            testTask.systemProperty("tests.restCompat", true);
             // Use test runner and classpath from "normal" yaml source set
             testTask.setTestClassesDirs(
                 yamlTestSourceSet.getOutput().getClassesDirs().plus(yamlCompatTestSourceSet.getOutput().getClassesDirs())

+ 12 - 0
test/framework/src/main/java/org/elasticsearch/test/junit/listeners/ReproduceInfoPrinter.java

@@ -91,9 +91,21 @@ public class ReproduceInfoPrinter extends RunListener {
         GradleMessageBuilder gradleMessageBuilder = new GradleMessageBuilder(b);
         gradleMessageBuilder.appendAllOpts(failure.getDescription());
 
+        if (isRestApiCompatibilityTest()) {
+            b.append(System.lineSeparator());
+            b.append(
+                "This is a Rest Api Compatibility Test. "
+                    + "See the developers guide for details how to troubleshoot - "
+                    + "https://github.com/elastic/elasticsearch/blob/master/REST_API_COMPATIBILITY.md"
+            );
+        }
         printToErr(b.toString());
     }
 
+    private boolean isRestApiCompatibilityTest() {
+        return Boolean.parseBoolean(System.getProperty("tests.restCompat", "false"));
+    }
+
     @SuppressForbidden(reason = "printing repro info")
     private static void printToErr(String s) {
         System.err.println(s);