Skip to content

Commit

Permalink
fix org.apache.camel.quarkus.component.lra.it.LraTest failed #2523 (#…
Browse files Browse the repository at this point in the history
…2524)

Fix LraTest on Mac OS X.

Fixes #2523
  • Loading branch information
ffang committed Apr 29, 2021
1 parent b49cde7 commit 2ee467b
Showing 1 changed file with 34 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
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;

Expand All @@ -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);
}
Expand Down

0 comments on commit 2ee467b

Please sign in to comment.