gnodet commented on code in PR #22287:
URL: https://github.com/apache/camel/pull/22287#discussion_r2999966433


##########
test-infra/camel-test-infra-common/src/main/java/org/apache/camel/test/infra/common/services/ContainerEnvironmentUtil.java:
##########
@@ -114,6 +114,9 @@ public static String containerName(Class cls) {
             if (annotation.serviceImplementationAlias().length > 0) {
                 name += "-" + annotation.serviceImplementationAlias()[0];
             }
+            // Append PID to avoid Docker container name conflicts when 
multiple
+            // modules run tests in parallel (e.g., via mvnd with multiple 
threads)
+            name += "-" + ProcessHandle.current().pid();

Review Comment:
   Also worth noting: the tests are **designed to share a single container** 
within a module. Test isolation is not achieved through container isolation but 
through **data partitioning** — each test method gets a unique Elasticsearch 
index prefix via `testNameExtension.getCurrentTestName()` (see 
`ElasticsearchTestSupport.createPrefix()`). This avoids the overhead of 
restarting Elasticsearch for each test class.
   
   The two modules (`camel-elasticsearch` and 
`camel-elasticsearch-rest-client`) were never sharing a container either — they 
run in separate surefire/failsafe forks (separate JVMs), each with its own 
`SingletonServiceHolder.INSTANCE`. The second JVM was simply crashing trying to 
create a container with an already-taken Docker name. The PID suffix makes both 
succeed with their own container, which is what was always intended.
   
   _Claude Code on behalf of Guillaume Nodet_



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to