Optimize Cassandra-based Testcontainer configuration for SBDG Inline Caching Integration Tests.
Trying to fix test failures caused by Testcontainers running in Docker on Jenkins. The Cassandra Docker image/container is forked inside Docker running in Jenkins CI and is currently throwing: Caused by: org.testcontainers.containers.ContainerLaunchException: Timed out waiting for container port to open (172.17.0.1 ports: [49401] should be listening) at org.testcontainers.containers.wait.strategy.HostPortWaitStrategy.waitUntilReady(HostPortWaitStrategy.java:49) at org.testcontainers.containers.wait.strategy.AbstractWaitStrategy.waitUntilReady(AbstractWaitStrategy.java:35) at org.testcontainers.containers.GenericContainer.waitUntilContainerStarted(GenericContainer.java:892) at org.testcontainers.containers.GenericContainer.tryStart(GenericContainer.java:440) ... 85 more In the Testcontainers project, I found: https://github.com/testcontainers/testcontainers-java/issues/4360 And specifically: https://github.com/testcontainers/testcontainers-java/issues/4360#issuecomment-892481828 The Jenkins servers (worker nodes) were recently upgraded to: docker-ce (5:20.10.8~3-0~ubuntu-bionic) containerd.io (1.4.9-1)
This commit is contained in:
@@ -52,18 +52,19 @@ public abstract class TestCassandraConfiguration extends AbstractCassandraConfig
|
||||
private static final String KEYSPACE_NAME = "CustomerService";
|
||||
private static final String SESSION_NAME = "CustomerServiceCluster";
|
||||
|
||||
@NonNull @Override
|
||||
@NonNull
|
||||
@Override
|
||||
protected String getKeyspaceName() {
|
||||
return KEYSPACE_NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
protected String getLocalDataCenter() {
|
||||
return LOCAL_DATA_CENTER;
|
||||
}
|
||||
|
||||
@Nullable @Override
|
||||
@Nullable
|
||||
@Override
|
||||
protected String getSessionName() {
|
||||
return SESSION_NAME;
|
||||
}
|
||||
@@ -87,7 +88,7 @@ public abstract class TestCassandraConfiguration extends AbstractCassandraConfig
|
||||
return startupScripts;
|
||||
}
|
||||
|
||||
private List<String> readLines(Resource resource) {
|
||||
private @NonNull List<String> readLines(@NonNull Resource resource) {
|
||||
|
||||
BufferedReader resourceReader = null;
|
||||
|
||||
|
||||
@@ -42,8 +42,7 @@ public class TestcontainersCassandraConfiguration extends TestCassandraConfigura
|
||||
@SuppressWarnings("rawtypes")
|
||||
GenericContainer cassandraContainer() {
|
||||
|
||||
GenericContainer cassandraContainer = newCassandraContainer()
|
||||
.withExposedPorts(CASSANDRA_DEFAULT_PORT);
|
||||
GenericContainer cassandraContainer = newCustomCassandraContainer();
|
||||
|
||||
cassandraContainer.start();
|
||||
|
||||
@@ -52,11 +51,21 @@ public class TestcontainersCassandraConfiguration extends TestCassandraConfigura
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private GenericContainer newCassandraContainer() {
|
||||
return new GenericContainer(CASSANDRA_DOCKER_IMAGE_NAME);
|
||||
return new GenericContainer(CASSANDRA_DOCKER_IMAGE_NAME)
|
||||
.withExposedPorts(CASSANDRA_DEFAULT_PORT);
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
private GenericContainer newCustomCassandraContainer() {
|
||||
|
||||
return newCassandraContainer()
|
||||
.withEnv("HEAP_NEWSIZE", "128M")
|
||||
.withEnv("MAX_HEAP_SIZE", "1024M")
|
||||
.withEnv("JVM_OPTS", "-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.initial_token=0")
|
||||
.withEnv("CASSANDRA_SNITCH", "GossipingPropertyFileSnitch");
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("all")
|
||||
protected String getContactPoints() {
|
||||
return cassandraContainer().getContainerIpAddress();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user