21 lines
643 B
Python
21 lines
643 B
Python
"""Initialize the single-datacenter test cluster using the checked-in CQL schema."""
|
|
|
|
import os
|
|
from pathlib import Path
|
|
|
|
from cassandra.cluster import Cluster
|
|
|
|
cluster = Cluster([os.getenv("CASSANDRA_HOST", "cassandra")], connect_timeout=10)
|
|
try:
|
|
session = cluster.connect()
|
|
schema = Path("/app/deploy/cassandra.cql").read_text()
|
|
schema = "\n".join(
|
|
line for line in schema.splitlines() if not line.startswith("--")
|
|
)
|
|
for statement in schema.split(";"):
|
|
if statement.strip():
|
|
session.execute(statement, timeout=30)
|
|
print("Cassandra test schema initialized")
|
|
finally:
|
|
cluster.shutdown()
|