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

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit f2cc9f8767b32fc4679de3326a0431783df41e38
Author: Claus Ibsen <[email protected]>
AuthorDate: Thu Sep 10 15:27:05 2026 +0200

    ci: Stop leaked infra services in InfrastructureITCase
    
    On CI the whole class failed as a cascade:
    
      runStopServiceTest              -> "infra ps" did not list PID 2112 
within 30s
      runServiceWithImplementationTest-> ps showed only the leaked ftp 2112
      sendMessageTest                 -> ps still showed ftp 2112, never the 
new 3798
    
    The first failure is a plain timeout: "infra run --background" forks a JVM
    and only writes its ~/.camel/infra-* files after initialize() returns, which
    on a loaded CI agent takes longer than the hard-coded 30 seconds.
    
    Once that assertion failed the test never reached its "infra stop", so the
    service leaked. That is what turned one slow start into three failures:
    "infra ps" renders a single row per alias, so a stale ftp instance keeps
    reporting its old PID and no later assertion on a new PID can ever match.
    
    Stop both services in an @AfterEach, and use the configurable
    ASSERTION_WAIT_SECONDS (300s on CI) instead of the hard-coded 30s. The stop
    is appended with "|| true" so it is tolerant of the service being running or
    not, in either direction.
    
    Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
    Signed-off-by: Claus Ibsen <[email protected]>
---
 .../camel/dsl/jbang/it/InfrastructureITCase.java   | 23 +++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git 
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/InfrastructureITCase.java
 
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/InfrastructureITCase.java
index bccece7ad867..4a63451e48f4 100644
--- 
a/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/InfrastructureITCase.java
+++ 
b/dsl/camel-jbang/camel-jbang-it/src/test/java/org/apache/camel/dsl/jbang/it/InfrastructureITCase.java
@@ -21,6 +21,7 @@ import java.time.Duration;
 import org.apache.camel.dsl.jbang.it.support.JBangTestSupport;
 import org.assertj.core.api.Assertions;
 import org.awaitility.Awaitility;
+import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Tag;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledIfSystemProperty;
@@ -35,6 +36,22 @@ public class InfrastructureITCase extends JBangTestSupport {
     private static final String IMPL_SERVICE = "artemis";
     private static final String IMPLEMENTATION = "amqp";
 
+    /**
+     * Stops the services started by the tests, even when a test failed before 
reaching its own stop command. A leaked
+     * service cascades into the following tests, because {@code infra ps} 
lists a single row per alias and would keep
+     * reporting the stale PID.
+     */
+    @AfterEach
+    public void stopInfraServices() {
+        stopInfraService(SERVICE);
+        stopInfraService(IMPL_SERVICE);
+    }
+
+    private void stopInfraService(String service) {
+        // best effort: the service may or may not be running, so never let 
the exit code fail the test
+        execInContainer(getMainCommand() + " infra stop " + service + " || 
true");
+    }
+
     private String getServicePID(String message) {
         return message.split(":")[1].replaceAll("[^0-9]", "");
     }
@@ -52,7 +69,7 @@ public class InfrastructureITCase extends JBangTestSupport {
         String PID = getServicePID(msg);
         Assertions.assertThat(msg).contains(String.format("Running %s in 
background", SERVICE));
         Awaitility.await()
-                .atMost(Duration.ofSeconds(30))
+                .atMost(Duration.ofSeconds(ASSERTION_WAIT_SECONDS))
                 .pollInterval(Duration.ofSeconds(1))
                 .untilAsserted(() -> Assertions.assertThat(execute("infra ps"))
                         .contains(PID));
@@ -68,7 +85,7 @@ public class InfrastructureITCase extends JBangTestSupport {
         String PID = getServicePID(msg);
         Assertions.assertThat(msg).contains(String.format("Running %s in 
background", IMPL_SERVICE));
         Awaitility.await()
-                .atMost(Duration.ofSeconds(30))
+                .atMost(Duration.ofSeconds(ASSERTION_WAIT_SECONDS))
                 .pollInterval(Duration.ofSeconds(1))
                 .untilAsserted(() -> Assertions.assertThat(execute("infra ps"))
                         .containsPattern(PID + "\\s+" + IMPL_SERVICE + "\\s+" 
+ IMPLEMENTATION));
@@ -83,7 +100,7 @@ public class InfrastructureITCase extends JBangTestSupport {
         String msg = execute("infra run --background " + SERVICE);
         String PID = getServicePID(msg);
         Awaitility.await()
-                .atMost(Duration.ofSeconds(30))
+                .atMost(Duration.ofSeconds(ASSERTION_WAIT_SECONDS))
                 .pollInterval(Duration.ofSeconds(1))
                 .untilAsserted(() -> Assertions.assertThat(execute("infra ps"))
                         .containsPattern(PID));

Reply via email to