Skip to content

Commit b8e2c81

Browse files
Add hardcoded DB password and username to Cassandra integration test (#5805)
## Which problem is this PR solving? - Resolves #5643 ## Description of the changes - add db password and username to cassandra-integration-test.sh - add db password and username to config-cassandra.yaml - both password and username are hardcoded in the code ## How was this change tested? - `bash scripts/cassandra-integration-test.sh 3 v003 v1` - `bash scripts/cassandra-integration-test.sh 3 v003 v2` - `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: Ali-Alnosairi <[email protected]> Signed-off-by: Yuri Shkuro <[email protected]> Co-authored-by: Yuri Shkuro <[email protected]>
1 parent 922faf0 commit b8e2c81

File tree

5 files changed

+43
-11
lines changed

5 files changed

+43
-11
lines changed

cmd/jaeger/config-cassandra.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,13 @@ extensions:
2121
some_storage:
2222
cassandra:
2323
keyspace: "jaeger_v1_dc1"
24+
username: "cassandra"
25+
password: "cassandra"
2426
another_storage:
2527
cassandra:
2628
keyspace: "jaeger_v1_dc1"
29+
username: "cassandra"
30+
password: "cassandra"
2731
receivers:
2832
otlp:
2933
protocols:

docker-compose/cassandra/v3/docker-compose.yaml

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,18 @@ services:
44
ports:
55
- "9042:9042"
66
- "9160:9160"
7+
# We enable password authentication that defaults to cassandra/cassandra superuser / pwd.
8+
# https://cassandra.apache.org/doc/stable/cassandra/operating/security.html#authentication
9+
command: >
10+
/bin/sh -c "echo 'authenticator: PasswordAuthenticator' >> /etc/cassandra/cassandra.yaml && docker-entrypoint.sh cassandra -f"
711
networks:
812
- cassandra-net
913
healthcheck:
1014
test: ["CMD", "cqlsh", "-e", "describe keyspaces"]
1115
interval: 30s
1216
timeout: 10s
1317
retries: 5
14-
18+
1519
networks:
1620
cassandra-net:
1721
driver: bridge

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

+4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ services:
44
ports:
55
- "9042:9042"
66
- "9160:9160"
7+
# We enable password authentication that defaults to cassandra/cassandra superuser / pwd.
8+
# https://cassandra.apache.org/doc/stable/cassandra/operating/security.html#authentication
9+
command: >
10+
/bin/sh -c "echo 'authenticator: PasswordAuthenticator' >> /etc/cassandra/cassandra.yaml && docker-entrypoint.sh cassandra -f"
711
networks:
812
- cassandra-net
913
healthcheck:

plugin/storage/integration/cassandra_test.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ package integration
66

77
import (
88
"context"
9+
"os"
910
"testing"
1011

1112
"github.com/stretchr/testify/require"
@@ -50,14 +51,19 @@ func (*CassandraStorageIntegration) initializeCassandraFactory(t *testing.T, fla
5051
}
5152

5253
func (s *CassandraStorageIntegration) initializeCassandra(t *testing.T) {
54+
username := os.Getenv("CASSANDRA_USERNAME")
55+
password := os.Getenv("CASSANDRA_USERNAME")
5356
f := s.initializeCassandraFactory(t, []string{
54-
"--cassandra.basic.allowed-authenticators=",
55-
"--cassandra.password=password",
56-
"--cassandra.username=username",
57+
"--cassandra.basic.allowed-authenticators=org.apache.cassandra.auth.PasswordAuthenticator",
58+
"--cassandra.password=" + password,
59+
"--cassandra.username=" + username,
5760
"--cassandra.keyspace=jaeger_v1_dc1",
5861
"--cassandra-archive.keyspace=jaeger_v1_dc1_archive",
5962
"--cassandra-archive.enabled=true",
6063
"--cassandra-archive.servers=127.0.0.1",
64+
"--cassandra-archive.basic.allowed-authenticators=org.apache.cassandra.auth.PasswordAuthenticator",
65+
"--cassandra-archive.password=" + password,
66+
"--cassandra-archive.username=" + username,
6167
})
6268
s.factory = f
6369
var err error

scripts/cassandra-integration-test.sh

+21-7
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
# Copyright (c) 2024 The Jaeger Authors.
44
# SPDX-License-Identifier: Apache-2.0
55

6-
set -uxf -o pipefail
6+
set -euxf -o pipefail
7+
8+
export CASSANDRA_USERNAME="cassandra"
9+
export CASSANDRA_PASSWORD="cassandra"
10+
success="false"
711

812
usage() {
913
echo $"Usage: $0 <cassandra_version> <schema_version>"
@@ -23,10 +27,19 @@ setup_cassandra() {
2327
echo "docker_compose_file=${compose_file}" >> "${GITHUB_OUTPUT:-/dev/null}"
2428
}
2529

30+
dump_logs() {
31+
local compose_file=$1
32+
echo "::group::🚧 🚧 🚧 Cassandra logs"
33+
docker compose -f "${compose_file}" logs
34+
echo "::endgroup::"
35+
}
36+
2637
teardown_cassandra() {
2738
local compose_file=$1
39+
if [[ "$success" == "false" ]]; then
40+
dump_logs "${compose_file}"
41+
fi
2842
docker compose -f "$compose_file" down
29-
exit "${exit_status}"
3043
}
3144

3245
apply_schema() {
@@ -40,6 +53,8 @@ apply_schema() {
4053
--env CQLSH_PORT=9042
4154
--env "TEMPLATE=/cassandra-schema/${schema_version}.cql.tmpl"
4255
--env "KEYSPACE=${keyspace}"
56+
--env "CASSANDRA_USERNAME=${CASSANDRA_USERNAME}"
57+
--env "CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD}"
4358
--network host
4459
)
4560
docker build -t ${image} ${schema_dir}
@@ -57,22 +72,21 @@ run_integration_test() {
5772

5873
setup_cassandra "${compose_file}"
5974

75+
# shellcheck disable=SC2064
76+
trap "teardown_cassandra ${compose_file}" EXIT
77+
6078
apply_schema "$schema_version" "$primaryKeyspace"
6179
apply_schema "$schema_version" "$archiveKeyspace"
6280

6381
if [ "${jaegerVersion}" = "v1" ]; then
6482
STORAGE=cassandra make storage-integration-test
65-
exit_status=$?
6683
elif [ "${jaegerVersion}" == "v2" ]; then
6784
STORAGE=cassandra make jaeger-v2-storage-integration-test
68-
exit_status=$?
6985
else
7086
echo "Unknown jaeger version $jaegerVersion. Valid options are v1 or v2"
7187
exit 1
7288
fi
73-
74-
# shellcheck disable=SC2064
75-
trap "teardown_cassandra ${compose_file}" EXIT
89+
success="true"
7690
}
7791

7892

0 commit comments

Comments
 (0)