Skip to content

Commit

Permalink
Properly wait for cqlsh readiness
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrf committed Apr 3, 2024
1 parent 566ec53 commit daedd10
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 11 deletions.
11 changes: 11 additions & 0 deletions .github/insist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
insist () {
command=$1
attempts=0
max_attempts=240
while ! eval "$command" ; do
[[ $attempts -ge $max_attempts ]] && echo "Failed!" && exit 1
attempts=$((attempts+1))
sleep 1;
echo "waiting... (${attempts}/${max_attempts})"
done
}
8 changes: 8 additions & 0 deletions .github/wait-for-cql.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash

service=$1

source insist.sh

echo "Waiting for CQL to be ready in service ${service}"
insist 'docker compose -f docker-compose-tests.yml exec ${service} bash -c "cqlsh -e '"'"'describe cluster'"'"'" > /dev/null'
12 changes: 4 additions & 8 deletions .github/wait-for-port.sh
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
#!/usr/bin/env bash

port=$1

source insist.sh

echo "Waiting for successful HTTP status code on port ${port}"
attempts=0
max_attempts=240
while ! curl -s "http://127.0.0.1:$port" > /dev/null ; do
[[ $attempts -ge $max_attempts ]] && echo "Failed!" && exit 1
attempts=$((attempts+1))
sleep 1;
echo "waiting... (${attempts}/${max_attempts})"
done
insist 'curl -s "http://127.0.0.1:$port" > /dev/null'
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ jobs:
- name: Set up services
run: |
docker compose -f docker-compose-tests.yml up &
.github/wait-for-port.sh 9042 # ScyllaDB
.github/wait-for-port.sh 8000 # ScyllaDB Alternator
.github/wait-for-port.sh 8001 # DynamoDB
.github/wait-for-port.sh 9043 # Cassandra
.github/wait-for-port.sh 9044 # ScyllaDB (used as a source)
.github/wait-for-cql.sh scylla
.github/wait-for-cql.sh cassandra
.github/wait-for-cql.sh scylla-source
.github/wait-for-port.sh 8080 # Spark master
.github/wait-for-port.sh 8081 # Spark worker
- name: Run tests
Expand Down

0 comments on commit daedd10

Please sign in to comment.