This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 882e6bd231f6 test-infra: Fix Docker container name collisions in
parallel execution
882e6bd231f6 is described below
commit 882e6bd231f6953aa624b1fe3e4fd182caab3b07
Author: Guillaume Nodet <[email protected]>
AuthorDate: Sat Mar 28 17:56:24 2026 +0100
test-infra: Fix Docker container name collisions in parallel execution
- Append PID + AtomicInteger counter to container names in
ContainerEnvironmentUtil.containerName() for cross-JVM (mvnd) and
within-JVM (parallel test classes) uniqueness
- Skip the suffix when camel.infra.fixedPort=true (camel infra run)
to preserve clean names like camel-postgres for docker exec usability
- Remove hardcoded withName("nameserver") from RocketMQNameserverContainer
that bypassed ContainerEnvironmentUtil (network alias is sufficient)
---
.../camel/test/infra/common/services/ContainerEnvironmentUtil.java | 7 +++++++
.../test/infra/rocketmq/services/RocketMQNameserverContainer.java | 1 -
2 files changed, 7 insertions(+), 1 deletion(-)
diff --git
a/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
index 689e6ef7fb67..69cdf3a32ba8 100644
---
a/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
+++
b/test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java
@@ -21,6 +21,7 @@ import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
import com.github.dockerjava.api.model.Version;
import com.github.dockerjava.api.model.VersionComponent;
@@ -35,6 +36,7 @@ public final class ContainerEnvironmentUtil {
public static final String INFRA_PORT_PROPERTY = "camel.infra.port";
public static final String INFRA_FIXED_PORT_PROPERTY =
"camel.infra.fixedPort";
private static final Logger LOG =
LoggerFactory.getLogger(ContainerEnvironmentUtil.class);
+ private static final AtomicInteger INSTANCE_COUNTER = new AtomicInteger(0);
private static boolean dockerAvailable;
private static boolean environmentCheckState;
@@ -114,6 +116,11 @@ public final class ContainerEnvironmentUtil {
if (annotation.serviceImplementationAlias().length > 0) {
name += "-" + annotation.serviceImplementationAlias()[0];
}
+ // In fixed port mode (camel infra run), use clean names for
docker exec usability
+ // Otherwise, append PID + counter for cross-JVM and within-JVM
uniqueness
+ if
(!Boolean.parseBoolean(System.getProperty(INFRA_FIXED_PORT_PROPERTY, "false")))
{
+ name += "-" + ProcessHandle.current().pid() + "-" +
INSTANCE_COUNTER.incrementAndGet();
+ }
} else {
LOG.warn("InfraService annotation not Found to determine container
name alias.");
}
diff --git
a/test-infra/camel-test-infra-rocketmq/src/main/java/org/apache/camel/test/infra/rocketmq/services/RocketMQNameserverContainer.java
b/test-infra/camel-test-infra-rocketmq/src/main/java/org/apache/camel/test/infra/rocketmq/services/RocketMQNameserverContainer.java
index a0b7aaaef837..e3fcf19fcdc1 100644
---
a/test-infra/camel-test-infra-rocketmq/src/main/java/org/apache/camel/test/infra/rocketmq/services/RocketMQNameserverContainer.java
+++
b/test-infra/camel-test-infra-rocketmq/src/main/java/org/apache/camel/test/infra/rocketmq/services/RocketMQNameserverContainer.java
@@ -32,7 +32,6 @@ public class RocketMQNameserverContainer extends
GenericContainer<RocketMQNamese
addExposedPort(RocketMQProperties.ROCKETMQ_NAMESRV_PORT);
withTmpFs(Collections.singletonMap("/home/rocketmq/logs", "rw"));
withCommand("sh", "mqnamesrv");
- withCreateContainerCmdModifier(cmd -> cmd.withName("nameserver"));
waitingFor(Wait.forListeningPort());
}