-
Notifications
You must be signed in to change notification settings - Fork 1.8k
chore: add instructions on howto test specialized environments #3009
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
6926527
chore: add instructions on howto test specialized environments
nbbeeken 381a5dd
chore: note about stopping the lb
nbbeeken 9e17b4d
chore: move the write up to the root of the test directory
nbbeeken 8e5331a
chore: update paths
nbbeeken 9c81145
Apply Daria's suggestions from code review
nbbeeken 8057656
fix: phrasing
nbbeeken 5774e27
Apply suggestions from code review
nbbeeken File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -62,3 +62,7 @@ lib/ | |
output | ||
|
||
serverless-expansion.yml | ||
serverless.env | ||
|
||
lb-expansion.yml | ||
lb.env |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
# How to test | ||
|
||
## Special Environments | ||
|
||
There are collections of tests that test features requiring a specialized set of environment variables to be generated and set in order to run. Look below for the section that applies to the feature you are trying to test. | ||
|
||
### Serverless | ||
|
||
Find the following script in driver-evergreen-tools and make sure you have the following environment variables defined. | ||
_**Remember**_ some of these are sensitive credentials so keep them safe and only put them in your environment when you need them. | ||
|
||
- `PROJECT` | ||
- `SERVERLESS_DRIVERS_GROUP` | ||
- `SERVERLESS_API_PUBLIC_KEY` | ||
- `SERVERLESS_API_PRIVATE_KEY` | ||
- `SERVERLESS_ATLAS_USER` | ||
- `SERVERLESS_ATLAS_PASSWORD` | ||
- `LOADBALANCED` | ||
|
||
```sh | ||
$DRIVERS_TOOLS/.evergreen/serverless/create-instance.sh | ||
``` | ||
|
||
this will output an evergreen expansion in `serverless-expansion.yml` in the current working directory. | ||
|
||
```yml | ||
MONGODB_URI: xxx | ||
MONGODB_SRV_URI: xxx | ||
SERVERLESS_INSTANCE_NAME: xxx | ||
SSL: xxx | ||
AUTH: xxx | ||
TOPOLOGY: xxx | ||
SERVERLESS: xxx | ||
MULTI_ATLASPROXY_SERVERLESS_URI: xxx | ||
SINGLE_ATLASPROXY_SERVERLESS_URI: xxx | ||
``` | ||
|
||
Since it's a flat yaml file, you can run the following to get a sourceable environment file: | ||
|
||
```sh | ||
cat serverless-expansion.yml | sed 's/: /=/g' > serverless.env | ||
``` | ||
|
||
Before sourcing `serverless.env`, make some adjustments that are equivalent to what our EVG does: | ||
|
||
- Change `MONGODB_URI` to be the same as `SINGLE_ATLASPROXY_SERVERLESS_URI` | ||
- Add `SINGLE_MONGOS_LB_URI` and `MULTI_MONGOS_LB_URI` and set them to `SINGLE_ATLASPROXY_SERVERLESS_URI` | ||
|
||
Lastly, comment out the `source` of `install-dependencies.sh` command in `.evergreen/run-serverless-tests.sh` and you can run that script directly to test serverless instances from your local machine. | ||
|
||
### Load Balanced | ||
|
||
You'll first need to start a sharded cluster using your favorite MongoDB orchestration tool of choice. | ||
The tool should create a cluster with two mongos so you have a uri like `MONGODB_URI=mongodb://host1,host2/` | ||
Then you need to start a load balancer: you can install `haproxy` on macos via `brew` and use the script provided in drivers-evergreen-tools. | ||
|
||
```sh | ||
$DRIVERS_TOOLS/.evergreen/run-load-balancer.sh start | ||
``` | ||
|
||
This will output an evergreen expansion file: `lb-expansion.yml` | ||
|
||
```yaml | ||
SINGLE_MONGOS_LB_URI: "mongodb://127.0.0.1:8000/?loadBalanced=true" | ||
MULTI_MONGOS_LB_URI: "mongodb://127.0.0.1:8001/?loadBalanced=true" | ||
``` | ||
|
||
Since it's a flat yaml file, you can run the following to get a sourceable environment file: | ||
|
||
```sh | ||
cat lb-expansion.yml | sed 's/: /=/g' > lb.env | ||
``` | ||
|
||
You have to add an additional environment variable to the end of this `lb.env` file: | ||
|
||
```sh | ||
FAKE_MONGODB_SERVICE_ID="true" | ||
``` | ||
|
||
This enables logic in the driver to stick in a fake service id on responses since that's what a real LB deployment is required to do. | ||
With those variables sourced, you can run the whole test suite as you normally would. | ||
|
||
> Please note, `FAKE_MONGODB_SERVICE_ID` will no longer be needed with the completion of [NODE-3431](https://jira.mongodb.org/browse/NODE-3431). | ||
|
||
```sh | ||
npm run check:test | ||
``` | ||
|
||
Take note of the `[ topology type: load-balanced ]` printout from mocha to make sure it picked up the environment as expected. | ||
|
||
When you are done testing you can shutdown the haproxy load balancer with: | ||
|
||
```sh | ||
$DRIVERS_TOOLS/.evergreen/run-load-balancer.sh stop | ||
``` | ||
|
||
### CSFLE | ||
|
||
As long as certain environment variables are present and mongodb-client-encryption is installed, FLE will run with a regular mocha execution: `npm run check:test`. | ||
|
||
Define the following variables in your environment: | ||
|
||
- `AWS_ACCESS_KEY_ID` | ||
- `AWS_SECRET_ACCESS_KEY` | ||
- `CSFLE_KMS_PROVIDERS` | ||
- `AWS_REGION` | ||
- `AWS_CMK_ID` | ||
|
||
### TODO Special Env Sections | ||
|
||
- Kerberos | ||
- AWS Authentication | ||
- OCSP | ||
- TLS | ||
- Atlas Data Lake | ||
- LDAP | ||
- Snappy (maybe in general, how to test optional dependencies) | ||
- Atlas connectivity |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.