This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch main in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/main by this push: new 2ee467b fix org.apache.camel.quarkus.component.lra.it.LraTest failed #2523 (#2524) 2ee467b is described below commit 2ee467b96faa096ab822705b1230cfc7dd0b41f6 Author: Freeman(Yue) Fang <freeman.f...@gmail.com> AuthorDate: Thu Apr 29 02:19:19 2021 -0400 fix org.apache.camel.quarkus.component.lra.it.LraTest failed #2523 (#2524) Fix LraTest on Mac OS X. Fixes #2523 --- .../quarkus/component/lra/it/LraTestResource.java | 47 ++++++++++++++++------ 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/integration-tests/lra/src/test/java/org/apache/camel/quarkus/component/lra/it/LraTestResource.java b/integration-tests/lra/src/test/java/org/apache/camel/quarkus/component/lra/it/LraTestResource.java index aa539bf..f799209 100644 --- a/integration-tests/lra/src/test/java/org/apache/camel/quarkus/component/lra/it/LraTestResource.java +++ b/integration-tests/lra/src/test/java/org/apache/camel/quarkus/component/lra/it/LraTestResource.java @@ -21,6 +21,7 @@ import java.util.Map; import io.quarkus.test.common.QuarkusTestResourceLifecycleManager; import org.apache.camel.quarkus.test.AvailablePortFinder; import org.apache.camel.util.CollectionHelper; +import org.apache.commons.lang3.SystemUtils; import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.wait.strategy.Wait; @@ -32,27 +33,47 @@ public class LraTestResource implements QuarkusTestResourceLifecycleManager { private static final String LRA_IMAGE = "jbosstm/lra-coordinator:5.9.3.Final"; private GenericContainer container; + private String hostname; + private int lraPort; @Override public Map<String, String> start() { try { - container = new GenericContainer(LRA_IMAGE) - .withNetworkMode("host") - .withCommand( - "java", - "-jar", - "/deployments/lra-coordinator-swarm.jar", - "-Djava.net.preferIPv4Stack=true", - "-Dswarm.http.port=" + LRA_PORT) - .waitingFor(Wait.forLogMessage(".*WFSWARM99999.*", 1)); - - container.start(); + if (SystemUtils.IS_OS_LINUX) { + hostname = "localhost"; + container = new GenericContainer(LRA_IMAGE) + .withNetworkMode("host") + .withCommand( + "java", + "-jar", + "/deployments/lra-coordinator-swarm.jar", + "-Djava.net.preferIPv4Stack=true", + "-Dswarm.http.port=" + LRA_PORT) + .waitingFor(Wait.forLogMessage(".*WFSWARM99999.*", 1)); + container.start(); + lraPort = LRA_PORT; + } else { + hostname = "host.docker.internal"; + container = new GenericContainer(LRA_IMAGE) + .withNetworkMode("bridge") + .withExposedPorts(LRA_PORT) + .withCommand( + "java", + "-jar", + "/deployments/lra-coordinator-swarm.jar", + "-Djava.net.preferIPv4Stack=true", + "-Dswarm.http.port=" + LRA_PORT) + .waitingFor(Wait.forLogMessage(".*WFSWARM99999.*", 1)); + container.start(); + lraPort = container.getMappedPort(LRA_PORT); + } return CollectionHelper.mapOf( "camel.lra.coordinator-url", - String.format("http://%s:%d", container.getContainerIpAddress(), LRA_PORT), + String.format("http://%s:%d", container.getContainerIpAddress(), lraPort), "camel.lra.local-participant-url", - String.format("http://localhost:%s", System.getProperty("quarkus.http.test-port", "8081"))); + String.format("http://%s:%s", hostname, + System.getProperty("quarkus.http.test-port", "8081"))); } catch (Exception e) { throw new RuntimeException(e); }