Skip to content

Commit

Permalink
Check for container start up using cqlsh (#1136)
Browse files Browse the repository at this point in the history
  • Loading branch information
maheshrajamani authored Jun 3, 2024
1 parent 9497ec4 commit 4d84b17
Showing 1 changed file with 12 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,15 +165,13 @@ public void stop() {

private GenericContainer<?> baseCassandraContainer(boolean reuse) {
String image = this.getCassandraImage();
String startupMessage = ".*Created default superuser role.*\\n";
GenericContainer<?> container = null;
if (this.isDse()) {
container =
new GenericContainer<>(image)
.withCopyFileToContainer(
MountableFile.forClasspathResource("dse.yaml"),
"/opt/dse/resources/dse/conf/dse.yaml");
startupMessage = ".*DSE startup complete.*\\n";
} else if (this.isHcd()) {
container =
new GenericContainer<>(image)
Expand All @@ -198,16 +196,20 @@ private GenericContainer<?> baseCassandraContainer(boolean reuse) {
.withExposedPorts(new Integer[] {7000, 9042})
.withLogConsumer(
(new Slf4jLogConsumer(LoggerFactory.getLogger("cassandra-docker")))
.withPrefix("CASSANDRA"))
.waitingFor(Wait.forLogMessage(startupMessage, 1))
.withStartupTimeout(this.getCassandraStartupTimeout())
.withReuse(reuse);
if (this.isDse() || this.isHcd()) {
container.withEnv("CLUSTER_NAME", getClusterName()).withEnv("DS_LICENSE", "accept");
.withPrefix("CASSANDRA"));
if (isHcd() || isDse()) {
container
.waitingFor(
Wait.forSuccessfulCommand(
"cqlsh -u cassandra -p cassandra -e \"describe keyspaces\""))
.withEnv("CLUSTER_NAME", getClusterName())
.withEnv("DS_LICENSE", "accept");
} else {
container.withEnv("CASSANDRA_CLUSTER_NAME", getClusterName());
container
.waitingFor(Wait.forLogMessage(".*Created default superuser role.*\\n", 1))
.withEnv("CASSANDRA_CLUSTER_NAME", getClusterName());
}

container.withStartupTimeout(this.getCassandraStartupTimeout()).withReuse(reuse);
return container;
}

Expand Down

0 comments on commit 4d84b17

Please sign in to comment.