From 4c8efb6b94e35deac0dc7d05862242a08abf4e87 Mon Sep 17 00:00:00 2001 From: wyattb Date: Mon, 6 Jan 2025 12:50:03 -0500 Subject: [PATCH] integration tests fix --- scylla-server/integration_test.sh | 44 +++++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 11 deletions(-) diff --git a/scylla-server/integration_test.sh b/scylla-server/integration_test.sh index c270980c..4e0eb4b2 100755 --- a/scylla-server/integration_test.sh +++ b/scylla-server/integration_test.sh @@ -1,15 +1,37 @@ #!/bin/sh -echo "Starting db" -cd ../compose -docker compose up -d odyssey-timescale -cd ../scylla-server -echo "Migrating DB" -diesel migration run +# Navigate to the compose directory +echo "Navigating to compose directory..." +cd ../compose || { echo "Compose directory not found"; exit 1; } -echo "Running tests" -DATABASE_URL=postgresql://postgres:password@127.0.0.1:5432/postgres cargo test -- --test-threads=1 +# Remove any existing odyssey-timescale container +echo "Stopping and removing any existing odyssey-timescale container..." +docker rm -f odyssey-timescale 2>/dev/null || echo "No existing container to remove." -echo "Exiting" -cd ../compose -docker compose down \ No newline at end of file +# Start a new odyssey-timescale container +echo "Starting a new odyssey-timescale container..." +docker compose up -d odyssey-timescale || { echo "Failed to start odyssey-timescale"; exit 1; } + +# Wait for the database to initialize +echo "Waiting for the database to initialize..." +sleep 3 + +# Navigate to the scylla-server directory +cd ../scylla-server || { echo "scylla-server directory not found"; exit 1; } + +# Run database migrations +echo "Running database migrations..." +DATABASE_URL=postgresql://postgres:password@127.0.0.1:5432/postgres diesel migration run || { echo "Migration failed"; exit 1; } + +# Run tests +echo "Running tests..." +DATABASE_URL=postgresql://postgres:password@127.0.0.1:5432/postgres cargo test -- --test-threads=1 || { echo "Tests failed"; exit 1; } + +# Navigate back to the compose directory +cd ../compose || { echo "Compose directory not found"; exit 1; } + +# Stop and clean up containers +echo "Stopping and cleaning up containers..." +docker compose down || { echo "Failed to clean up containers"; exit 1; } + +echo "Script completed successfully!"