Skip to content

Commit 47e1ee6

Browse files
authored
Pass username/password to Cassandra docker-compose health check (#6214)
## Which problem is this PR solving? - Resolves #6215 ## Description of the changes - Added the username and password values for health check cmd - Added `healthcheck_cassandra` point to make sure the container is healthy as per the cmd. ## How was this change tested? - bash scripts/cassandra-integration-test.sh 4 v004 v1 - bash scripts/cassandra-integration-test.sh 4 v004 v2 ## Checklist - [x] I have read https://github.com/jaegertracing/jaeger/blob/master/CONTRIBUTING_GUIDELINES.md - [x] I have signed all commits - [ ] I have added unit tests for the new functionality - [x] I have run lint and test steps successfully - for `jaeger`: `make lint test` - for `jaeger-ui`: `yarn lint` and `yarn test` --------- Signed-off-by: Alok Kumar Singh <[email protected]>
1 parent 6585c6e commit 47e1ee6

File tree

3 files changed

+28
-2
lines changed

3 files changed

+28
-2
lines changed

docker-compose/cassandra/v4/docker-compose.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
services:
22
cassandra:
33
image: cassandra:4.1
4+
container_name: "cassandra-4"
45
ports:
56
- "9042:9042"
67
- "9160:9160"
@@ -11,7 +12,7 @@ services:
1112
networks:
1213
- cassandra-net
1314
healthcheck:
14-
test: ["CMD", "cqlsh", "-e", "describe keyspaces"]
15+
test: ["CMD", "cqlsh", "-u", "cassandra", "-p", "cassandra", "-e", "describe keyspaces"]
1516
interval: 30s
1617
timeout: 10s
1718
retries: 5

docker-compose/cassandra/v5/docker-compose.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
services:
22
cassandra:
33
image: cassandra:5.0
4+
container_name: "cassandra-5"
45
ports:
56
- "9042:9042"
67
- "9160:9160"
@@ -11,7 +12,7 @@ services:
1112
networks:
1213
- cassandra-net
1314
healthcheck:
14-
test: ["CMD", "cqlsh", "-e", "describe keyspaces"]
15+
test: ["CMD", "cqlsh", "-u", "cassandra", "-p", "cassandra", "-e", "describe keyspaces"]
1516
interval: 30s
1617
timeout: 10s
1718
retries: 5

scripts/cassandra-integration-test.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ set -euxf -o pipefail
88
export CASSANDRA_USERNAME="cassandra"
99
export CASSANDRA_PASSWORD="cassandra"
1010
success="false"
11+
timeout=600
12+
end_time=$((SECONDS + timeout))
1113

1214
usage() {
1315
echo $"Usage: $0 <cassandra_version> <schema_version>"
@@ -26,6 +28,26 @@ setup_cassandra() {
2628
docker compose -f "$compose_file" up -d
2729
}
2830

31+
healthcheck_cassandra() {
32+
local cas_version=$1
33+
local container_name="cassandra-${cas_version}"
34+
# Since the healthcheck in cassandra is done at the interval of 30s
35+
local wait_seconds=30
36+
37+
while [ $SECONDS -lt $end_time ]; do
38+
status=$(docker inspect -f '{{ .State.Health.Status }}' "${container_name}")
39+
if [[ ${status} == "healthy" ]]; then
40+
echo "$container_name is healthy"
41+
return 0
42+
fi
43+
echo "Waiting for $container_name to be healthy. Current status: $status"
44+
sleep $wait_seconds
45+
done
46+
47+
echo "❌ ERROR: $container_name did not become healthy in time"
48+
exit 1
49+
}
50+
2951
dump_logs() {
3052
local compose_file=$1
3153
echo "::group::🚧 🚧 🚧 Cassandra logs"
@@ -74,6 +96,8 @@ run_integration_test() {
7496
# shellcheck disable=SC2064
7597
trap "teardown_cassandra ${compose_file}" EXIT
7698

99+
healthcheck_cassandra "${major_version}"
100+
77101
apply_schema "$schema_version" "$primaryKeyspace"
78102
apply_schema "$schema_version" "$archiveKeyspace"
79103

0 commit comments

Comments
 (0)