This is an automated email from the ASF dual-hosted git repository.

jamesnetherton pushed a commit to branch 3.27.x
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 349c63c36822c9c5fd2647b863359c8e1172ba32
Author: Lukas Lowinger <[email protected]>
AuthorDate: Mon Oct 27 17:33:04 2025 +0100

    Improve master-openshift test to capture log of child process
---
 .../component/master/it/MasterOpenShiftTest.java   | 74 +++++++++++++---------
 1 file changed, 44 insertions(+), 30 deletions(-)

diff --git 
a/integration-tests/master-openshift/src/test/java/org/apache/camel/quarkus/component/master/it/MasterOpenShiftTest.java
 
b/integration-tests/master-openshift/src/test/java/org/apache/camel/quarkus/component/master/it/MasterOpenShiftTest.java
index e764ac4f52..4e83e18b28 100644
--- 
a/integration-tests/master-openshift/src/test/java/org/apache/camel/quarkus/component/master/it/MasterOpenShiftTest.java
+++ 
b/integration-tests/master-openshift/src/test/java/org/apache/camel/quarkus/component/master/it/MasterOpenShiftTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.quarkus.component.master.it;
 
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
 import java.nio.file.Path;
@@ -37,6 +38,8 @@ import org.eclipse.microprofile.config.Config;
 import org.eclipse.microprofile.config.ConfigProvider;
 import org.junit.jupiter.api.BeforeAll;
 import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.zeroturnaround.exec.ProcessExecutor;
 import org.zeroturnaround.exec.StartedProcess;
 
@@ -47,6 +50,7 @@ import static org.hamcrest.Matchers.emptyString;
 @QuarkusTest
 class MasterOpenShiftTest {
 
+    private static final Logger LOG = 
LoggerFactory.getLogger(MasterOpenShiftTest.class);
     @KubernetesTestServer
     private KubernetesServer mockOpenShiftServer;
 
@@ -69,38 +73,47 @@ class MasterOpenShiftTest {
         jvmArgs.add("-Dkubernetes.trust.certificates=" + 
config.getValue("kubernetes.trust.certificates", String.class));
         jvmArgs.add(
                 "-Dkubernetes.auth.tryServiceAccount=" + 
config.getValue("kubernetes.auth.tryServiceAccount", String.class));
-        jvmArgs.add("-Dhttp2.disable=" + config.getValue("http2.disable", 
String.class));
 
         // Start secondary application process faking KubernetesClusterService 
so it assumes being run from a pod named follower
-        Consumer<ProcessExecutor> customizer = pe -> 
pe.environment("HOSTNAME", "follower");
-        QuarkusProcessExecutor followerProcessExecutor = new 
QuarkusProcessExecutor(customizer, jvmArgs.toArray(String[]::new));
-        StartedProcess followerProcess = null;
-
-        try {
-            // Verify that this process is the cluster leader
-            Awaitility.await().atMost(10, TimeUnit.SECONDS).with().until(() -> 
{
-                return readLeaderFile("leader").equals("leader");
-            });
-
-            // Start the follower process and wait until fully initialized
-            followerProcess = followerProcessExecutor.start();
-            awaitStartup(followerProcessExecutor);
-
-            // Verify the follower hasn't taken the leader role yet
-            assertThat(readLeaderFile("follower"), emptyString());
-
-            // Stop camel and delete the lease mock to trigger fail-over
-            
RestAssured.given().get("/master/camel/stop/leader").then().statusCode(204);
-            mockOpenShiftServer.getClient().leases().delete();
-
-            // Verify that the secondary application has been elected as the
-            // cluster leader
-            Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> {
-                return readLeaderFile("follower").equals("leader");
-            });
-        } finally {
-            if (followerProcess != null && 
followerProcess.getProcess().isAlive()) {
-                followerProcessExecutor.destroy();
+        try (ByteArrayOutputStream standardStream = new 
ByteArrayOutputStream();
+                ByteArrayOutputStream errorStream = new 
ByteArrayOutputStream()) {
+            Consumer<ProcessExecutor> customizer = pe -> 
pe.environment("HOSTNAME", "follower")
+                    .redirectOutputAlsoTo(standardStream)
+                    .redirectErrorAlsoTo(errorStream);
+            QuarkusProcessExecutor followerProcessExecutor = new 
QuarkusProcessExecutor(customizer,
+                    jvmArgs.toArray(String[]::new));
+            StartedProcess followerProcess = null;
+
+            try {
+                // Verify that this process is the cluster leader
+                Awaitility.await().atMost(10, 
TimeUnit.SECONDS).with().until(() -> {
+                    return readLeaderFile("leader").equals("leader");
+                });
+
+                // Start the follower process and wait until fully initialized
+                followerProcess = followerProcessExecutor.start();
+                awaitStartup(followerProcessExecutor);
+
+                // Verify the follower hasn't taken the leader role yet
+                assertThat(readLeaderFile("follower"), emptyString());
+
+                // Stop camel and delete the lease mock to trigger fail-over
+                
RestAssured.given().get("/master/camel/stop/leader").then().statusCode(204);
+                mockOpenShiftServer.getClient().leases().delete();
+
+                // Verify that the secondary application has been elected as 
the
+                // cluster leader
+                Awaitility.await().atMost(10, TimeUnit.SECONDS).until(() -> {
+                    return readLeaderFile("follower").equals("leader");
+                });
+            } finally {
+                LOG.info("Follower process standard log[start] {}", 
standardStream);
+                LOG.info("Follower process standard log[end]");
+                LOG.info("Follower process error log[start] {}", errorStream);
+                LOG.info("Follower process error log[end]");
+                if (followerProcess != null && 
followerProcess.getProcess().isAlive()) {
+                    followerProcessExecutor.destroy();
+                }
             }
         }
     }
@@ -116,6 +129,7 @@ class MasterOpenShiftTest {
             int status = 
RestAssured.given().port(port).get("/q/health").then().extract().statusCode();
             return status == 200;
         } catch (Exception e) {
+            LOG.error("App is not healthy yet", e);
             return false;
         }
     }

Reply via email to