rerouted mapped port and passed it to nb5

This commit is contained in:
Mike Yaacoub 2023-02-02 18:23:41 -05:00
parent b8f2067265
commit 85c989bd41

View File

@ -22,7 +22,9 @@ import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.testcontainers.containers.CassandraContainer;
import org.testcontainers.containers.GenericContainer;
import org.testcontainers.containers.Network;
import org.testcontainers.containers.wait.CassandraQueryWaitStrategy;
import org.testcontainers.containers.wait.strategy.AbstractWaitStrategy;
import org.testcontainers.containers.wait.strategy.Wait;
import org.testcontainers.utility.DockerImageName;
@ -40,9 +42,9 @@ public class ExampleContainersIntegrationTest {
private static String hostIP = "127.0.0.1";
private static String datacenter = "datacenter1";
private static String mappedPort9042 = "9042";
private static final Integer EXPOSED_PORT = 9042;
public static CassandraContainer<?> cass = new CassandraContainer<>(DockerImageName.parse("cassandra:latest")).withCreateContainerCmdModifier(cmd -> cmd.withNetworkMode("host")).withAccessToHost(true)
.withExposedPorts(EXPOSED_PORT).waitingFor(Wait.forLogMessage(".*cassandra:latest started.*", 1));
private static final CassandraContainer cass = (CassandraContainer) new CassandraContainer().withExposedPorts(9042);
@BeforeAll
public static void initContainer() {
//STEP0:Start the test container and expose the 9042 port on the local host.
@ -52,8 +54,8 @@ public class ExampleContainersIntegrationTest {
datacenter = cass.getLocalDatacenter();
//When running with a local Docker daemon, exposed ports will usually be reachable on localhost.
// However, in some CI environments they may instead be reachable on a different host.
mappedPort9042 = cass.getMappedPort(9042).toString();
hostIP = cass.getHost();
}
@BeforeEach
@ -74,7 +76,7 @@ public class ExampleContainersIntegrationTest {
//STEP2: Run the example cassandra workload using the default params (
ProcessResult runResult = invoker.run("run-workload", 30, "java", "-jar", JARNAME, "run",
"driver=cql", "workload=cql-keyvalue", "host="+hostIP, "localdc="+datacenter
"driver=cql", "workload=cql-keyvalue", "host="+hostIP, "localdc="+datacenter, "port="+ mappedPort9042
);
assertThat(runResult.exception).isNull();
String runOut = String.join("\n", runResult.getStdoutData());