fix org.apache.camel.quarkus.component.lra.it.LraTest failed
Fix LraTest on Mac OS X.
Fixes
@@ -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,10 +33,14 @@ 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 {
+ if (SystemUtils.IS_OS_LINUX) {
+ hostname = "localhost";
container = new GenericContainer(LRA_IMAGE)
.withNetworkMode("host")
.withCommand(
@@ -45,14 +50,30 @@ public class LraTestResource implements QuarkusTestResourceLifecycleManager {
"-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);
}
