Skip to content

Commit

Permalink
Add hardcoded DB password and username to Cassandra integration test (j…
Browse files Browse the repository at this point in the history
…aegertracing#5805)

## Which problem is this PR solving?
- Resolves jaegertracing#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]>
Signed-off-by: Mahad Zaryab <[email protected]>
  • Loading branch information
2 people authored and mahadzaryab1 committed Aug 31, 2024
1 parent 8948dd2 commit 38469d7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 11 deletions.
4 changes: 4 additions & 0 deletions cmd/jaeger/config-cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,13 @@ extensions:
some_storage:
cassandra:
keyspace: "jaeger_v1_dc1"
username: "cassandra"
password: "cassandra"
another_storage:
cassandra:
keyspace: "jaeger_v1_dc1"
username: "cassandra"
password: "cassandra"
receivers:
otlp:
protocols:
Expand Down
6 changes: 5 additions & 1 deletion docker-compose/cassandra/v3/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@ services:
ports:
- "9042:9042"
- "9160:9160"
# We enable password authentication that defaults to cassandra/cassandra superuser / pwd.
# https://cassandra.apache.org/doc/stable/cassandra/operating/security.html#authentication
command: >
/bin/sh -c "echo 'authenticator: PasswordAuthenticator' >> /etc/cassandra/cassandra.yaml && docker-entrypoint.sh cassandra -f"
networks:
- cassandra-net
healthcheck:
test: ["CMD", "cqlsh", "-e", "describe keyspaces"]
interval: 30s
timeout: 10s
retries: 5

networks:
cassandra-net:
driver: bridge
4 changes: 4 additions & 0 deletions docker-compose/cassandra/v4/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ services:
ports:
- "9042:9042"
- "9160:9160"
# We enable password authentication that defaults to cassandra/cassandra superuser / pwd.
# https://cassandra.apache.org/doc/stable/cassandra/operating/security.html#authentication
command: >
/bin/sh -c "echo 'authenticator: PasswordAuthenticator' >> /etc/cassandra/cassandra.yaml && docker-entrypoint.sh cassandra -f"
networks:
- cassandra-net
healthcheck:
Expand Down
12 changes: 9 additions & 3 deletions plugin/storage/integration/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package integration

import (
"context"
"os"
"testing"

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

func (s *CassandraStorageIntegration) initializeCassandra(t *testing.T) {
username := os.Getenv("CASSANDRA_USERNAME")
password := os.Getenv("CASSANDRA_USERNAME")
f := s.initializeCassandraFactory(t, []string{
"--cassandra.basic.allowed-authenticators=",
"--cassandra.password=password",
"--cassandra.username=username",
"--cassandra.basic.allowed-authenticators=org.apache.cassandra.auth.PasswordAuthenticator",
"--cassandra.password=" + password,
"--cassandra.username=" + username,
"--cassandra.keyspace=jaeger_v1_dc1",
"--cassandra-archive.keyspace=jaeger_v1_dc1_archive",
"--cassandra-archive.enabled=true",
"--cassandra-archive.servers=127.0.0.1",
"--cassandra-archive.basic.allowed-authenticators=org.apache.cassandra.auth.PasswordAuthenticator",
"--cassandra-archive.password=" + password,
"--cassandra-archive.username=" + username,
})
s.factory = f
var err error
Expand Down
28 changes: 21 additions & 7 deletions scripts/cassandra-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
# Copyright (c) 2024 The Jaeger Authors.
# SPDX-License-Identifier: Apache-2.0

set -uxf -o pipefail
set -euxf -o pipefail

export CASSANDRA_USERNAME="cassandra"
export CASSANDRA_PASSWORD="cassandra"
success="false"

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

dump_logs() {
local compose_file=$1
echo "::group::🚧 🚧 🚧 Cassandra logs"
docker compose -f "${compose_file}" logs
echo "::endgroup::"
}

teardown_cassandra() {
local compose_file=$1
if [[ "$success" == "false" ]]; then
dump_logs "${compose_file}"
fi
docker compose -f "$compose_file" down
exit "${exit_status}"
}

apply_schema() {
Expand All @@ -40,6 +53,8 @@ apply_schema() {
--env CQLSH_PORT=9042
--env "TEMPLATE=/cassandra-schema/${schema_version}.cql.tmpl"
--env "KEYSPACE=${keyspace}"
--env "CASSANDRA_USERNAME=${CASSANDRA_USERNAME}"
--env "CASSANDRA_PASSWORD=${CASSANDRA_PASSWORD}"
--network host
)
docker build -t ${image} ${schema_dir}
Expand All @@ -57,22 +72,21 @@ run_integration_test() {

setup_cassandra "${compose_file}"

# shellcheck disable=SC2064
trap "teardown_cassandra ${compose_file}" EXIT

apply_schema "$schema_version" "$primaryKeyspace"
apply_schema "$schema_version" "$archiveKeyspace"

if [ "${jaegerVersion}" = "v1" ]; then
STORAGE=cassandra make storage-integration-test
exit_status=$?
elif [ "${jaegerVersion}" == "v2" ]; then
STORAGE=cassandra make jaeger-v2-storage-integration-test
exit_status=$?
else
echo "Unknown jaeger version $jaegerVersion. Valid options are v1 or v2"
exit 1
fi

# shellcheck disable=SC2064
trap "teardown_cassandra ${compose_file}" EXIT
success="true"
}


Expand Down

0 comments on commit 38469d7

Please sign in to comment.