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

Conversation

ayushrakesh
Copy link

@ayushrakesh ayushrakesh commented Jun 18, 2024

Which problem is this PR solving?

Description of the changes

  • Modified the usage function to include the <db_password> argument
  • In check_arg function , checked the required no. of parameters - <cassandra_version>, <schema_version>, <jaeger_version>, and <db_password>, and passed to apply_schema function and handling it in main.

How was this change tested?

  • make test

Checklist

@ayushrakesh ayushrakesh requested a review from a team as a code owner June 18, 2024 07:21
@ayushrakesh ayushrakesh requested a review from albertteoh June 18, 2024 07:21
@hellspawn679
Copy link
Contributor

@ayushrakesh do we really need to increase the number of arguments passed this will cause the ci to fail and I don't think we should add password in github action
we can simply specify it in like we have done with primaryKeyspace

@ayushrakesh
Copy link
Author

@hellspawn679 should I use env variable?

@ayushrakesh
Copy link
Author

@hellspawn679 should I use env variable?

And further passing database password through Github action secrets -> in cassandra CI?

@yurishkuro
Copy link
Member

do we really need to increase the number of arguments passed this will cause the ci to fail and I don't think we should add password in github action we can simply specify it in like we have done with primaryKeyspace

+1. There is no need to complicate the CI scripts with ability to override password, if it's needed in the future we can add it. It still should not be required argument to the script, but an optional one.

@ayushrakesh
Copy link
Author

@yurishkuro @hellspawn679 so what should be done, db password should be passed as an optional parameter then what is the default value? Is it should be directly declared locally in run_integration function?

@yurishkuro
Copy link
Member

the docker command starting Cassandra may need to specify password. The same password should be hardcoded in the integration tests. We have two flavors of integration tests:

  • v1 (plugin/storage/integration) which are driven from code, and the password can be passed from code
  • v2 (cmd/jaeger/internal/integration) is accessing storage from our main binary, and password can be passed via configuration file cmd/jaeger/config-cassandra.yaml

@ayushrakesh
Copy link
Author

ayushrakesh commented Jun 22, 2024

index: tags: true logs: true process_tags: true password: "your_password_here"

index: tags: true logs: true process_tags: true password: "your_password_here"

@yurishkuro like this in both cassandra main and archive in cmd/jaeger/config-cassandra.yaml ? And in plugin/storage/integration/cassandra_test.go
using env variable?

@yurishkuro
Copy link
Member

As approach - yes. Exact syntax- you need to try.

@ayushrakesh
Copy link
Author

@yurishkuro Need to review, I have added different passwords for cassandra main and archive in cmd/jaeger/cassandra-config.yaml.

@@ -37,6 +37,7 @@ apply_schema() {
--env CQLSH_PORT=9042
--env "TEMPLATE=/cassandra-schema/${schema_version}.cql.tmpl"
--env "KEYSPACE=${keyspace}"
--env "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 only password and not user name?
  • we don't need any env variables, the pwd can be simply hardcoded here, since the db container is created just for this test

Copy link
Author

Choose a reason for hiding this comment

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

@yurishkuro Then what is the password?

Copy link
Member

Choose a reason for hiding this comment

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

whatever, make up a string, e.g. testpwd

run: bash scripts/cassandra-integration-test.sh ${{ matrix.version.major }} ${{ matrix.version.schema }} ${{ matrix.jaeger-version }}
env:
DB_PASSWORD: ${{ secrets.DB_PASSWORD }}
run: bash scripts/cassandra-integration-test.sh ${{ matrix.version.major }} ${{ matrix.version.schema }} ${{ matrix.jaeger-version }} $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.

we don't need to pass pwd here, it can be hardcoded in the script

Copy link
Author

Choose a reason for hiding this comment

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

@yurishkuro PR is revised now.

Copy link

codecov bot commented Jun 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.94%. Comparing base (44484ac) to head (6338bf9).
Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5644      +/-   ##
==========================================
- Coverage   96.38%   95.94%   -0.44%     
==========================================
  Files         329      329              
  Lines       16060    16060              
==========================================
- Hits        15479    15409      -70     
- Misses        404      482      +78     
+ Partials      177      169       -8     
Flag Coverage Δ
badger_v1 8.04% <ø> (ø)
badger_v2 1.92% <ø> (ø)
cassandra-3.x-v1 ?
cassandra-3.x-v2 ?
cassandra-4.x-v1 ?
cassandra-4.x-v2 ?
elasticsearch-7.x-v1 18.88% <ø> (+0.01%) ⬆️
elasticsearch-8.x-v1 19.08% <ø> (ø)
elasticsearch-8.x-v2 19.08% <ø> (ø)
grpc_v1 9.46% <ø> (-0.02%) ⬇️
grpc_v2 7.49% <ø> (ø)
kafka 9.76% <ø> (ø)
opensearch-1.x-v1 18.93% <ø> (+0.01%) ⬆️
opensearch-2.x-v1 18.92% <ø> (-0.02%) ⬇️
opensearch-2.x-v2 18.93% <ø> (+0.01%) ⬆️
unittests 94.22% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ayushrakesh
Copy link
Author

@yurishkuro Please review my revised PR.

@@ -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>)

Copy link
Member

@yurishkuro yurishkuro left a comment

Choose a reason for hiding this comment

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

Please provide proof of successful testing with scripts/cassandra-integration-test.sh script.

@@ -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?

@@ -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?

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?

@yurishkuro
Copy link
Member

no follow-up, closing

@yurishkuro yurishkuro closed this Aug 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use db password in Cassandra integration tests
3 participants