diff --git a/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java b/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java index a12ac03f18d..74d40306e6f 100644 --- a/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java +++ b/modules/cassandra/src/main/java/org/testcontainers/containers/CassandraContainer.java @@ -68,13 +68,6 @@ public CassandraContainer(DockerImageName dockerImageName) { addExposedPort(CQL_PORT); this.enableJmxReporting = false; - - withEnv("CASSANDRA_SNITCH", "GossipingPropertyFileSnitch"); - withEnv("JVM_OPTS", "-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.initial_token=0"); - withEnv("HEAP_NEWSIZE", "128M"); - withEnv("MAX_HEAP_SIZE", "1024M"); - withEnv("CASSANDRA_ENDPOINT_SNITCH", "GossipingPropertyFileSnitch"); - withEnv("CASSANDRA_DC", DEFAULT_LOCAL_DATACENTER); } @Override @@ -131,6 +124,19 @@ protected void optionallyMapResourceParameterAsVolume(String pathNameInContainer .ifPresent(mountableFile -> withCopyFileToContainer(mountableFile, pathNameInContainer)); } + /** + * Set up environment variables to allow Cassandra to start up. You may choose to override this method for example + * if you want to set your own variables to run multi-node clusters. + */ + protected void initEnv() { + withEnv("CASSANDRA_SNITCH", "GossipingPropertyFileSnitch"); + withEnv("JVM_OPTS", "-Dcassandra.skip_wait_for_gossip_to_settle=0 -Dcassandra.initial_token=0"); + withEnv("HEAP_NEWSIZE", "128M"); + withEnv("MAX_HEAP_SIZE", "1024M"); + withEnv("CASSANDRA_ENDPOINT_SNITCH", "GossipingPropertyFileSnitch"); + withEnv("CASSANDRA_DC", getLocalDatacenter()); + } + /** * Initialize Cassandra with the custom overridden Cassandra configuration *