mirror of
https://github.com/bec-project/bec_atlas.git
synced 2025-07-14 07:01:48 +02:00
ci: moved checks to separate file
This commit is contained in:
43
backend/ci/healthchecks.py
Normal file
43
backend/ci/healthchecks.py
Normal 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()
|
Reference in New Issue
Block a user