Browse Source

Dump wildfly log on start failure (#49892)

When testing wildfly with Elasticsearch, we currently dump the wildfly
log if the test fails. However, when starting wildfly we may fail to
find the port number wildfly started on, and fail with no output. This
change dumps the wildflog log when failing to find the http or
management ports.

relates #49374
Ryan Ernst 5 years ago
parent
commit
671d4005b2
1 changed files with 14 additions and 2 deletions
  1. 14 2
      qa/wildfly/build.gradle

+ 14 - 2
qa/wildfly/build.gradle

@@ -163,8 +163,10 @@ task startWildfly {
         }
       }
 
-      assert httpPort > 0
-      assert managementPort > 0
+      if (httpPort == 0 || managementPort == 0) {
+        String portType = httpPort == 0 ? "http" : "management"
+        throw new GradleException("Failed to find ${portType} port in wildfly log")
+      }
     }
   }
 }
@@ -188,6 +190,10 @@ if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
   final TaskExecutionAdapter logDumpListener = new TaskExecutionAdapter() {
     @Override
     void afterExecute(final Task task, final TaskState state) {
+      if (task != startWildfly && task != integTestRunner) {
+        // we might have been called from a parallel, unrelated task
+        return
+      }
       if (state.failure != null) {
         final File logFile = new File(wildflyInstall, "standalone/log/server.log")
         println("\nWildfly server log (from ${logFile}):")
@@ -204,12 +210,18 @@ if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
       }
     }
   }
+  startWildfly.doFirst {
+    project.gradle.addListener(logDumpListener)
+  }
   integTestRunner.doFirst {
     project.gradle.addListener(logDumpListener)
   }
   integTestRunner.doLast {
     project.gradle.removeListener(logDumpListener)
   }
+  startWildfly.doLast {
+    project.gradle.removeListener(logDumpListener)
+  }
   integTestRunner.finalizedBy(stopWildfly)
 } else {
   integTest.enabled = false