-
Notifications
You must be signed in to change notification settings - Fork 1.8k
docs: add documentation for running aws integ tests locally #4830
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
base: main
Are you sure you want to change the base?
Changes from all commits
576e8c6
5587eba
04d1fc1
971f85d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,33 @@ | ||||||
| #!/usr/bin/env bash | ||||||
| set -euxo pipefail # Exit on error, undefined variable, and fail on pipe errors | ||||||
|
|
||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Generally, if we add a script that we plan to use for local testing, we also ensure that it is the same script used to run tests in CI. This ensures the script is always up-to-date.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't feel too strongly about including this script. The way we run tests in CI makes sense and I don't think we need to change it. |
||||||
| # NOTE: This script assumes that you've created an AWS SSO session already, as outlined in | ||||||
| # ./test/readme.md, section `AWS Profile`, and you have an AWS profile | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
| # named `drivers-test-secrets-role-857654397073` in your AWS config. | ||||||
|
|
||||||
| # Choose credential type: env-creds or session-creds | ||||||
| # export AWS_CREDENTIAL_TYPE="env-creds" | ||||||
| export AWS_CREDENTIAL_TYPE="session-creds" | ||||||
| export VERSION="latest" | ||||||
| export NODE_LTS_VERSION="24" | ||||||
| export AUTH="auth" | ||||||
| export ORCHESTRATION_FILE="auth-aws.json" | ||||||
| export TOPOLOGY="server" | ||||||
| export NODE_DRIVER="$DRIVERS_TOOLS/.." | ||||||
| export AWS_PROFILE="drivers-test-secrets-role-857654397073" | ||||||
|
|
||||||
| # Enable for verbose logging | ||||||
| # export MONGODB_LOG_ALL="debug" | ||||||
| # export MONGODB_LOG_PATH="stderr" | ||||||
|
|
||||||
| echo "Assuming AWS SSO role..." | ||||||
| aws sso login --sso-session drivers-test-secrets-session | ||||||
|
|
||||||
| echo "Installing dependencies..." | ||||||
| bash ${NODE_DRIVER}/.evergreen/install-dependencies.sh | ||||||
|
|
||||||
| echo "Bootstrapping orchestration..." | ||||||
| bash ${NODE_DRIVER}/.evergreen/run-orchestration.sh | ||||||
|
|
||||||
| echo "Running AWS integration tests with env-creds from $NODE_DRIVER ..." | ||||||
| bash ${NODE_DRIVER}/.evergreen/run-mongodb-aws-test.sh | ||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -39,6 +39,7 @@ about the types of tests and how to run them. | |
| - [Deployed Lambda Tests](#deployed-lambda-tests) | ||
| - [Kerberos Tests](#kerberos-tests) | ||
| - [AWS Authentication tests](#aws-authentication-tests) | ||
| - [AWS Profile](#aws-profile) | ||
| - [Container Tests](#container-tests) | ||
| - [GCP](#gcp) | ||
| - [Azure](#azure) | ||
|
|
@@ -647,6 +648,33 @@ Choose your AWS authentication credential type and export the `AWS_CREDENTIAL_TY | |
|
|
||
| 1. Run the `bash .evergreen/run-mongodb-aws-tests.sh`. | ||
|
|
||
| An example of performing the above is [`etc/run-aws-integ-tests.sh`](etc/run-aws-integ-tests.sh). | ||
|
|
||
| #### AWS Profile | ||
|
|
||
| Setup an AWS_PROFILE locally to be able to use AWS and to run AWS tests locally. | ||
|
|
||
| 1. Get SSO sign-in info from AWS | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are these steps just a duplicate of the docs here? https://wiki.corp.mongodb.com/spaces/DRIVERS/pages/239737385/Using+AWS+Secrets+Manager+to+Store+Testing+Secrets If so, I'd suggest just linking these docs instead
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, we do link to these docs (indirectly) in the secrets section of the readme
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The instructions are indirectly linked, so it did take a bit of experimentation to figure out what was necessary or not. I think it may be helpful to be explicit about these instructions, hence why I included them. What about adding a link to the wiki, but keeping this section as "quick setup" instructions? |
||
| 1. Navigate to https://corp.mongodb.com/app/UserHome | ||
| 2. Open AWS | ||
| 3. Choose `Drivers` account | ||
| 4. Choose `drivers-test-secrets-role` | ||
| 5. Click `Access Keys` | ||
| 6. Copy down `SSO start URL` and `SSO Region` | ||
| 2. Sign in locally | ||
| 1. Run `aws configure sso-session` | ||
| 2. Pick a name, like `drivers-test-secrets-session` | ||
| 3. Specify `SSO start URL` and `SSO Region` from earlier steps | ||
| 3. Add a profile | ||
| 1. Add the following profile to `~/.aws/config` | ||
|
|
||
| ```ini | ||
| [profile drivers-test-secrets-role-857654397073] | ||
| sso_session = drivers-test-secrets-session | ||
| sso_account_id = 857654397073 | ||
| sso_role_name = drivers-test-secrets-role | ||
| ``` | ||
|
|
||
| ### Container Tests | ||
|
|
||
| It may become required to run tests or debug code inside a live Azure or GCP container. The best way to do this is to leverage | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this environment variable used by any AWS auth variants in CI?
aWs there a particular reason this change was needed? iirc the AWS credential provider SDK fetches credentials from the environment first. So it's unclear how having the AWS_PROFILE set would interfere with AWS environment variable credential fetching.
https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-credential-providers/#:~:text=This%20credential%20provider%20will,exposed%20via%20process.env
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This variable is not used by any AWS auth variants in our CI.
The tests fetch the credentials from the environment, and this is fine in CI where we use env access/secret keys directly: we use the env creds to generate temporary/EC2/whatever credentials, then the new access/secret/token values overwrite the env vars, and the SDK picks up the newest values.
But running these locally with a profile configured I saw a different behavior: we use the profile to generate temporary/EC2/whatever credentials, then the new access/secret/token values are added to the env, in addition to the profile. When this happens, our tests fail with an auth error (you can verify this by commenting out the line
unset AWS_PROFILE) :Compare this to a run where the AWS_PROFILE is unset: