ci: moved checks to separate file

This commit is contained in:
2024-11-19 21:48:23 +01:00
parent cda6265f64
commit a01778b67d
2 changed files with 52 additions and 7 deletions

View File

@ -0,0 +1,43 @@
import sys
import time
from cassandra.cluster import Cluster
SCYLLA_HOST = "scylla"
SCYLLA_KEYSPACE = "test_bec_atlas"
def wait_for_scylladb():
print("Waiting for ScyllaDB to be ready...")
while True:
try:
cluster = Cluster([SCYLLA_HOST])
session = cluster.connect()
session.set_keyspace(SCYLLA_KEYSPACE)
print("Connected to ScyllaDB")
break
except Exception as e:
print(f"ScyllaDB not ready yet: {e}")
time.sleep(5)
def create_keyspace():
print(f"Creating keyspace '{SCYLLA_KEYSPACE}' if not exists...")
try:
cluster = Cluster([SCYLLA_HOST])
session = cluster.connect()
session.execute(
f"""
CREATE KEYSPACE IF NOT EXISTS {SCYLLA_KEYSPACE}
WITH replication = {{'class': 'SimpleStrategy', 'replication_factor': 1}}
"""
)
print(f"Keyspace '{SCYLLA_KEYSPACE}' created successfully.")
except Exception as e:
print(f"Failed to create keyspace: {e}")
sys.exit(1)
if __name__ == "__main__":
wait_for_scylladb()
create_keyspace()