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

Added db password in cassandra-integration-test #5644

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci-cassandra.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ jobs:
uses: step-security/harden-runner@17d0e2bd7d51742c71671bd19fa12bdc9d40a3d6 # v2.8.1
with:
egress-policy: audit # TODO: change to 'egress-policy: block' after couple of runs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exclude this file from the PR, since it's not changing (git checkout main <file>)

- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7

- uses: actions/setup-go@cdcb36043654635271a94b9a6d1392de5bb323a7 # v5.0.1
with:
go-version: 1.22.x

- name: Run cassandra integration tests
id: test-execution
run: bash scripts/cassandra-integration-test.sh ${{ matrix.version.major }} ${{ matrix.version.schema }} ${{ matrix.jaeger-version }}
Expand Down
6 changes: 6 additions & 0 deletions cmd/jaeger/config-cassandra.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ extensions:
tags: true
logs: true
process_tags: true
username: "${CASSANDRA_MAIN_USERNAME}"
password: "${CASSANDRA_MAIN_PASSWORD}"

cassandra_archive:
servers: 127.0.0.1
port: 9042
Expand All @@ -32,6 +35,9 @@ extensions:
tags: true
logs: true
process_tags: true
username: "${CASSANDRA_ARCHIVE_USERNAME}"
password: "${CASSANDRA_ARCHIVE_PASSWORD}"

receivers:
otlp:
protocols:
Expand Down
2 changes: 2 additions & 0 deletions docker-compose/cassandra/v3/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
ports:
- "9042:9042"
- "9160:9160"
environment:
- DB_PASSWORD=${DB_PASSWORD}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what about username?

networks:
- cassandra-net
healthcheck:
Expand Down
2 changes: 2 additions & 0 deletions docker-compose/cassandra/v4/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
ports:
- "9042:9042"
- "9160:9160"
environment:
- DB_PASSWORD=${DB_PASSWORD}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why DB_PASSWORD? Do you have a link to the docs showing that it's a recognized var?

networks:
- cassandra-net
healthcheck:
Expand Down
13 changes: 12 additions & 1 deletion plugin/storage/integration/cassandra_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package integration

import (
"context"
"os"
"testing"

"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -54,16 +55,26 @@ func (*CassandraStorageIntegration) initializeCassandraFactory(t *testing.T, fla
logger := zaptest.NewLogger(t, zaptest.WrapOptions(zap.AddCaller()))
f := cassandra.NewFactory()
v, command := config.Viperize(f.AddFlags)

// Modify to fetch password from environment variable
password := os.Getenv("DB_PASSWORD")
require.NotEmpty(t, password, "DB_PASSWORD environment variable must be set")

// Add the Cassandra password flag
flags = append(flags, "--cassandra.password="+password)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is already set in the next function, why is it here again?


require.NoError(t, command.ParseFlags(flags))
f.InitFromViper(v, logger)
require.NoError(t, f.Initialize(metrics.NullFactory, logger))
return f
}

func (s *CassandraStorageIntegration) initializeCassandra(t *testing.T) {
password := os.Getenv("DB_PASSWORD")

f := s.initializeCassandraFactory(t, []string{
"--cassandra.basic.allowed-authenticators=",
"--cassandra.password=password",
"--cassandra.password=" + password,
"--cassandra.username=username",
"--cassandra.keyspace=jaeger_v1_dc1",
"--cassandra-archive.keyspace=jaeger_v1_dc1_archive",
Expand Down
4 changes: 3 additions & 1 deletion scripts/cassandra-integration-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -uxf -o pipefail

usage() {
echo $"Usage: $0 <cassandra_version> <schema_version>"
echo $"Usage: $0 <cassandra_version> <schema_version> <jaeger_version>"
exit 1
}

Expand Down Expand Up @@ -37,6 +37,8 @@ apply_schema() {
--env CQLSH_PORT=9042
--env "TEMPLATE=/cassandra-schema/${schema_version}.cql.tmpl"
--env "KEYSPACE=${keyspace}"
--env "DB_USERNAME=testUserName"
--env "DB_PASSWORD=testPwd"
--network host
)
docker build -t ${image} ${schema_dir}
Expand Down