Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hardcoded DB password and username to Cassandra integration test #5805

Merged
merged 11 commits into from
Aug 23, 2024
Merged
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"
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved
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}"
yurishkuro marked this conversation as resolved.
Show resolved Hide resolved

# 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
Loading