diff --git a/.evergreen/config.in.yml b/.evergreen/config.in.yml
index 382fc175078..2144e856388 100644
--- a/.evergreen/config.in.yml
+++ b/.evergreen/config.in.yml
@@ -238,27 +238,13 @@ functions:
. ./set-temp-creds.sh
popd
- MONGODB_URI="${MONGODB_URI}" \
- AUTH=${AUTH} SSL=${SSL} TEST_CSFLE=true \
- MONGODB_API_VERSION="${MONGODB_API_VERSION}"
-
export MONGODB_API_VERSION="${MONGODB_API_VERSION}"
export AUTH="auth"
export SSL="ssl"
- export SERVERLESS="1"
- export SERVERLESS_ATLAS_USER="${SERVERLESS_ATLAS_USER}"
- export SERVERLESS_ATLAS_PASSWORD="${SERVERLESS_ATLAS_PASSWORD}"
- export SERVERLESS_URI="${SERVERLESS_URI}"
+ export TEST_CSFLE=true
- echo "setting SERVERLESS_URI: $SERVERLESS_URI"
-
- export MONGODB_URI="${SERVERLESS_URI}"
- export SINGLE_MONGOS_LB_URI="${SERVERLESS_URI}"
-
- # Setting MULTI_MONGOS to the SERVERLESS_URI is intentional
- # LB tests pick one host out of the comma separated list
- # so just passing the one host is equivalent
- export MULTI_MONGOS_LB_URI="${SERVERLESS_URI}"
+ source secrets-export.sh
+ source serverless.env
bash ${PROJECT_DIRECTORY}/.evergreen/run-serverless-tests.sh
@@ -1171,29 +1157,10 @@ tasks:
type: setup
params:
binary: bash
- add_expansions_to_env: true
env:
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
- GCPKMS_GCLOUD: ${GCPKMS_GCLOUD}
- GCPKMS_PROJECT: ${GCPKMS_PROJECT}
- GCPKMS_ZONE: ${GCPKMS_ZONE}
- GCPKMS_INSTANCENAME: ${GCPKMS_INSTANCENAME}
args:
- - src/.evergreen/setup-gcp-testing.sh
- # Run Mocha test over on GCE instance
- - command: subprocess.exec
- type: test
- params:
- working_dir: src
- binary: bash
- env:
- GCPKMS_GCLOUD: ${GCPKMS_GCLOUD}
- GCPKMS_PROJECT: ${GCPKMS_PROJECT}
- GCPKMS_ZONE: ${GCPKMS_ZONE}
- GCPKMS_INSTANCENAME: ${GCPKMS_INSTANCENAME}
- GCPKMS_CMD: "env EXPECTED_GCPKMS_OUTCOME=success bash src/.evergreen/run-gcp-kms-tests.sh"
- args:
- - ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/run-command.sh
+ - src/.evergreen/run-deployed-gcp-kms-tests.sh
- name: "test-gcpkms-fail-task"
# test-gcpkms-fail-task runs in a non-GCE environment.
@@ -1230,9 +1197,10 @@ tasks:
type: setup
params:
binary: bash
- add_expansions_to_env: true
+ env:
+ DRIVERS_TOOLS: ${DRIVERS_TOOLS}
args:
- - src/.evergreen/copy-driver-to-azure-and-run.sh
+ - src/.evergreen/run-deployed-azure-kms-tests.sh
- name: "test-azurekms-fail-task"
commands:
@@ -1427,32 +1395,24 @@ task_groups:
setup_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: "fetch source"
- - command: shell.exec
- params:
- shell: bash
- script: |
- ${PREPARE_SHELL}
- set +o xtrace
- LOADBALANCED=ON \
- SERVERLESS_DRIVERS_GROUP=${SERVERLESS_DRIVERS_GROUP} \
- SERVERLESS_API_PUBLIC_KEY=${SERVERLESS_API_PUBLIC_KEY} \
- SERVERLESS_API_PRIVATE_KEY=${SERVERLESS_API_PRIVATE_KEY} \
- bash ${DRIVERS_TOOLS}/.evergreen/serverless/create-instance.sh
- - command: expansions.update
+ - command: subprocess.exec
params:
- file: serverless-expansion.yml
+ working_dir: "src"
+ binary: bash
+ env:
+ DRIVERS_TOOLS: ${DRIVERS_TOOLS}
+ args:
+ - .evergreen/setup-serverless.sh
+
teardown_group:
- func: "upload test results"
- - command: shell.exec
+ - command: subprocess.exec
params:
- script: |
- ${PREPARE_SHELL}
- set +o xtrace
- SERVERLESS_DRIVERS_GROUP=${SERVERLESS_DRIVERS_GROUP} \
- SERVERLESS_API_PUBLIC_KEY=${SERVERLESS_API_PUBLIC_KEY} \
- SERVERLESS_API_PRIVATE_KEY=${SERVERLESS_API_PRIVATE_KEY} \
- SERVERLESS_INSTANCE_NAME=${SERVERLESS_INSTANCE_NAME} \
- bash ${DRIVERS_TOOLS}/.evergreen/serverless/delete-instance.sh
+ working_dir: "src"
+ binary: bash
+ args:
+ - ${DRIVERS_TOOLS}/.evergreen/serverless/delete-instance.sh
+
tasks:
- ".serverless"
@@ -1467,21 +1427,11 @@ task_groups:
binary: bash
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/setup.sh
- - command: expansions.update
- # Load the GCPKMS_GCLOUD, GCPKMS_INSTANCE, GCPKMS_REGION, and GCPKMS_ZONE expansions.
- params:
- file: src/testgcpkms-expansions.yml
teardown_group:
- command: subprocess.exec
params:
binary: bash
- add_expansions_to_env: true
- env:
- GCPKMS_GCLOUD: ${GCPKMS_GCLOUD}
- GCPKMS_PROJECT: ${GCPKMS_PROJECT}
- GCPKMS_ZONE: ${GCPKMS_ZONE}
- GCPKMS_INSTANCENAME: ${GCPKMS_INSTANCENAME}
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/teardown.sh
tasks:
@@ -1500,10 +1450,6 @@ task_groups:
AZUREKMS_VMNAME_PREFIX: "NODE_DRIVER"
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/setup.sh
- - command: expansions.update
- # Load AZUREKMS_VMNAME into the expansions.
- params:
- file: src/testazurekms-expansions.yml
teardown_group:
# Load expansions again. The setup task may have failed before running `expansions.update`.
@@ -1513,7 +1459,6 @@ task_groups:
- command: subprocess.exec
params:
binary: bash
- add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/teardown.sh
tasks:
diff --git a/.evergreen/config.yml b/.evergreen/config.yml
index 828e804f6f9..fa117c60268 100644
--- a/.evergreen/config.yml
+++ b/.evergreen/config.yml
@@ -209,27 +209,13 @@ functions:
. ./set-temp-creds.sh
popd
- MONGODB_URI="${MONGODB_URI}" \
- AUTH=${AUTH} SSL=${SSL} TEST_CSFLE=true \
- MONGODB_API_VERSION="${MONGODB_API_VERSION}"
-
export MONGODB_API_VERSION="${MONGODB_API_VERSION}"
export AUTH="auth"
export SSL="ssl"
- export SERVERLESS="1"
- export SERVERLESS_ATLAS_USER="${SERVERLESS_ATLAS_USER}"
- export SERVERLESS_ATLAS_PASSWORD="${SERVERLESS_ATLAS_PASSWORD}"
- export SERVERLESS_URI="${SERVERLESS_URI}"
-
- echo "setting SERVERLESS_URI: $SERVERLESS_URI"
-
- export MONGODB_URI="${SERVERLESS_URI}"
- export SINGLE_MONGOS_LB_URI="${SERVERLESS_URI}"
+ export TEST_CSFLE=true
- # Setting MULTI_MONGOS to the SERVERLESS_URI is intentional
- # LB tests pick one host out of the comma separated list
- # so just passing the one host is equivalent
- export MULTI_MONGOS_LB_URI="${SERVERLESS_URI}"
+ source secrets-export.sh
+ source serverless.env
bash ${PROJECT_DIRECTORY}/.evergreen/run-serverless-tests.sh
start-load-balancer:
@@ -1130,28 +1116,10 @@ tasks:
type: setup
params:
binary: bash
- add_expansions_to_env: true
env:
DRIVERS_TOOLS: ${DRIVERS_TOOLS}
- GCPKMS_GCLOUD: ${GCPKMS_GCLOUD}
- GCPKMS_PROJECT: ${GCPKMS_PROJECT}
- GCPKMS_ZONE: ${GCPKMS_ZONE}
- GCPKMS_INSTANCENAME: ${GCPKMS_INSTANCENAME}
- args:
- - src/.evergreen/setup-gcp-testing.sh
- - command: subprocess.exec
- type: test
- params:
- working_dir: src
- binary: bash
- env:
- GCPKMS_GCLOUD: ${GCPKMS_GCLOUD}
- GCPKMS_PROJECT: ${GCPKMS_PROJECT}
- GCPKMS_ZONE: ${GCPKMS_ZONE}
- GCPKMS_INSTANCENAME: ${GCPKMS_INSTANCENAME}
- GCPKMS_CMD: env EXPECTED_GCPKMS_OUTCOME=success bash src/.evergreen/run-gcp-kms-tests.sh
args:
- - ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/run-command.sh
+ - src/.evergreen/run-deployed-gcp-kms-tests.sh
- name: test-gcpkms-fail-task
commands:
- command: expansions.update
@@ -1184,9 +1152,10 @@ tasks:
type: setup
params:
binary: bash
- add_expansions_to_env: true
+ env:
+ DRIVERS_TOOLS: ${DRIVERS_TOOLS}
args:
- - src/.evergreen/copy-driver-to-azure-and-run.sh
+ - src/.evergreen/run-deployed-azure-kms-tests.sh
- name: test-azurekms-fail-task
commands:
- command: expansions.update
@@ -4458,32 +4427,22 @@ task_groups:
setup_group_timeout_secs: 1800
setup_group:
- func: fetch source
- - command: shell.exec
- params:
- shell: bash
- script: |
- ${PREPARE_SHELL}
- set +o xtrace
- LOADBALANCED=ON \
- SERVERLESS_DRIVERS_GROUP=${SERVERLESS_DRIVERS_GROUP} \
- SERVERLESS_API_PUBLIC_KEY=${SERVERLESS_API_PUBLIC_KEY} \
- SERVERLESS_API_PRIVATE_KEY=${SERVERLESS_API_PRIVATE_KEY} \
- bash ${DRIVERS_TOOLS}/.evergreen/serverless/create-instance.sh
- - command: expansions.update
+ - command: subprocess.exec
params:
- file: serverless-expansion.yml
+ working_dir: src
+ binary: bash
+ env:
+ DRIVERS_TOOLS: ${DRIVERS_TOOLS}
+ args:
+ - .evergreen/setup-serverless.sh
teardown_group:
- func: upload test results
- - command: shell.exec
+ - command: subprocess.exec
params:
- script: |
- ${PREPARE_SHELL}
- set +o xtrace
- SERVERLESS_DRIVERS_GROUP=${SERVERLESS_DRIVERS_GROUP} \
- SERVERLESS_API_PUBLIC_KEY=${SERVERLESS_API_PUBLIC_KEY} \
- SERVERLESS_API_PRIVATE_KEY=${SERVERLESS_API_PRIVATE_KEY} \
- SERVERLESS_INSTANCE_NAME=${SERVERLESS_INSTANCE_NAME} \
- bash ${DRIVERS_TOOLS}/.evergreen/serverless/delete-instance.sh
+ working_dir: src
+ binary: bash
+ args:
+ - ${DRIVERS_TOOLS}/.evergreen/serverless/delete-instance.sh
tasks:
- .serverless
- name: test_gcpkms_task_group
@@ -4497,19 +4456,10 @@ task_groups:
binary: bash
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/setup.sh
- - command: expansions.update
- params:
- file: src/testgcpkms-expansions.yml
teardown_group:
- command: subprocess.exec
params:
binary: bash
- add_expansions_to_env: true
- env:
- GCPKMS_GCLOUD: ${GCPKMS_GCLOUD}
- GCPKMS_PROJECT: ${GCPKMS_PROJECT}
- GCPKMS_ZONE: ${GCPKMS_ZONE}
- GCPKMS_INSTANCENAME: ${GCPKMS_INSTANCENAME}
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/teardown.sh
tasks:
@@ -4527,9 +4477,6 @@ task_groups:
AZUREKMS_VMNAME_PREFIX: NODE_DRIVER
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/setup.sh
- - command: expansions.update
- params:
- file: src/testazurekms-expansions.yml
teardown_group:
- command: expansions.update
params:
@@ -4537,7 +4484,6 @@ task_groups:
- command: subprocess.exec
params:
binary: bash
- add_expansions_to_env: true
args:
- ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/teardown.sh
tasks:
diff --git a/.evergreen/copy-driver-to-azure-and-run.sh b/.evergreen/run-deployed-azure-kms-tests.sh
similarity index 99%
rename from .evergreen/copy-driver-to-azure-and-run.sh
rename to .evergreen/run-deployed-azure-kms-tests.sh
index 46fc4aa2e39..45a596656ca 100644
--- a/.evergreen/copy-driver-to-azure-and-run.sh
+++ b/.evergreen/run-deployed-azure-kms-tests.sh
@@ -2,12 +2,11 @@
set -o errexit
source "${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/secrets-export.sh"
+source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
if [ -z ${AZUREKMS_RESOURCEGROUP+omitted} ]; then echo "AZUREKMS_RESOURCEGROUP is unset" && exit 1; fi
if [ -z ${AZUREKMS_VMNAME+omitted} ]; then echo "AZUREKMS_VMNAME is unset" && exit 1; fi
-source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
-
export AZUREKMS_PUBLICKEYPATH=/tmp/testazurekms_publickey
export AZUREKMS_PRIVATEKEYPATH=/tmp/testazurekms_privatekey
diff --git a/.evergreen/setup-gcp-testing.sh b/.evergreen/run-deployed-gcp-kms-tests.sh
similarity index 88%
rename from .evergreen/setup-gcp-testing.sh
rename to .evergreen/run-deployed-gcp-kms-tests.sh
index b74191bd86d..3db1571beee 100644
--- a/.evergreen/setup-gcp-testing.sh
+++ b/.evergreen/run-deployed-gcp-kms-tests.sh
@@ -1,6 +1,7 @@
#! /usr/bin/env bash
source "${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/secrets-export.sh"
+source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
# Assert required environment variables are present without printing them
if [ -z ${GCPKMS_GCLOUD+omitted} ]; then echo "GCPKMS_GCLOUD is unset" && exit 1; fi
@@ -10,8 +11,6 @@ if [ -z ${GCPKMS_INSTANCENAME+omitted} ]; then echo "GCPKMS_INSTANCENAME is unse
set -o errexit
-source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
-
export GCPKMS_SRC=node-driver-source.tgz
export GCPKMS_DST=$GCPKMS_INSTANCENAME:
@@ -28,3 +27,6 @@ echo "decompressing node driver tar on gcp ... begin"
export GCPKMS_CMD="tar -xzf $GCPKMS_SRC"
"${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/run-command.sh"
echo "decompressing node driver tar on gcp ... end"
+
+export GCPKMS_CMD="env EXPECTED_GCPKMS_OUTCOME=success bash src/.evergreen/run-gcp-kms-tests.sh"
+bash ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/run-command.sh
\ No newline at end of file
diff --git a/.evergreen/run-serverless-tests.sh b/.evergreen/run-serverless-tests.sh
index 6134745d072..547d3a01866 100755
--- a/.evergreen/run-serverless-tests.sh
+++ b/.evergreen/run-serverless-tests.sh
@@ -3,7 +3,6 @@
source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
if [ -z ${SERVERLESS+omitted} ]; then echo "SERVERLESS is unset" && exit 1; fi
-if [ -z ${SERVERLESS_URI+omitted} ]; then echo "SERVERLESS_URI is unset" && exit 1; fi
if [ -z ${SINGLE_MONGOS_LB_URI+omitted} ]; then echo "SINGLE_MONGOS_LB_URI is unset" && exit 1; fi
if [ -z ${MULTI_MONGOS_LB_URI+omitted} ]; then echo "MULTI_MONGOS_LB_URI is unset" && exit 1; fi
if [ -z ${MONGODB_URI+omitted} ]; then echo "MONGODB_URI is unset" && exit 1; fi
diff --git a/.evergreen/setup-serverless.sh b/.evergreen/setup-serverless.sh
new file mode 100644
index 00000000000..c5c7d6c57ca
--- /dev/null
+++ b/.evergreen/setup-serverless.sh
@@ -0,0 +1,14 @@
+#!/usr/bin/env bash
+
+bash ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/serverless
+bash ${DRIVERS_TOOLS}/.evergreen/serverless/create-instance.sh
+
+cp ${DRIVERS_TOOLS}/.evergreen/serverless/secrets-export.sh .
+
+# generate a source-able expansion file
+cat serverless-expansion.yml | sed 's/: /=/g' > serverless.env
+
+echo 'export MONGODB_URI="${SERVERLESS_URI}"' >> serverless.env
+echo 'export SINGLE_MONGOS_LB_URI="${SERVERLESS_URI}"' >> serverless.env
+echo 'export MULTI_MONGOS_LB_URI="${SERVERLESS_URI}"' >> serverless.env
+echo 'export SERVERLESS=1' >> serverless.env
diff --git a/test/readme.md b/test/readme.md
index bce66e7c070..7e369a63c4b 100644
--- a/test/readme.md
+++ b/test/readme.md
@@ -5,13 +5,39 @@ about the types of tests and how to run them.
## Table of Contents
-- [About the Tests](#about-the-tests)
-- [Running the Tests Locally](#running-the-tests-locally)
-- [Running the Tests in Evergreen](#running-the-tests-in-evergreen)
-- [Using a Pre-Release Version of a Dependent Library](#using-a-pre-release-version-of-a-dependent-library)
-- [Manually Testing the Driver](#manually-testing-the-driver)
-- [Writing Tests](#writing-tests)
-- [Testing with Special Environments](#testing-with-special-environments)
+- [MongoDB Node Driver Test Automation](#mongodb-node-driver-test-automation)
+ - [Table of Contents](#table-of-contents)
+ - [About the Tests](#about-the-tests)
+ - [Spec Tests](#spec-tests)
+ - [Running the Tests Locally](#running-the-tests-locally)
+ - [Testing With Authorization-Enabled](#testing-with-authorization-enabled)
+ - [Testing Different MongoDB Topologies](#testing-different-mongodb-topologies)
+ - [Running Individual Tests](#running-individual-tests)
+ - [Running the Tests in Evergreen](#running-the-tests-in-evergreen)
+ - [Manually Kicking Off Evergreen Builds](#manually-kicking-off-evergreen-builds)
+ - [Evergreen UI](#evergreen-ui)
+ - [Evergreen CLI](#evergreen-cli)
+ - [Setup](#setup)
+ - [Running the Build](#running-the-build)
+ - [Using a Pre-Release Version of a Dependent Library](#using-a-pre-release-version-of-a-dependent-library)
+ - [Manually Testing the Driver](#manually-testing-the-driver)
+ - [Writing Tests](#writing-tests)
+ - [Framework](#framework)
+ - [Skipping Tests](#skipping-tests)
+ - [Running Benchmarks](#running-benchmarks)
+ - [Configuration](#configuration)
+ - [Testing with Special Environments](#testing-with-special-environments)
+ - [Serverless](#serverless)
+ - [Load Balanced](#load-balanced)
+ - [Client-Side Field-Level Encryption (CSFLE)](#client-side-field-level-encryption-csfle)
+ - [Testing driver changes with mongosh](#testing-driver-changes-with-mongosh)
+ - [Point mongosh to the driver](#point-mongosh-to-the-driver)
+ - [Run specific package tests](#run-specific-package-tests)
+ - [KMIP FLE support tests](#kmip-fle-support-tests)
+ - [Deployed KMS Tests](#deployed-kms-tests)
+ - [Azure KMS](#azure-kms)
+ - [GCP KMS](#gcp-kms)
+ - [TODO Special Env Sections](#todo-special-env-sections)
## About the Tests
@@ -23,16 +49,16 @@ tests will be skipped.
Below is a summary of the types of test automation in this repo.
-| Type of Test | Test Location | About the Tests | How to Run Tests |
-| ----------------------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Unit | `/test/unit` | The unit tests test individual pieces of code, typically functions. These tests do **not** interact with a real database, so mocks are used instead.
The unit test directory mirrors the `/src` directory structure with test file names matching the source file names of the code they test. | `npm run check:unit` |
-| Integration | `/test/integration` | The integration tests test that a given feature or piece of a feature is working as expected. These tests do **not** use mocks; instead, they interact with a real database.
The integration test directory follows the `test/spec` directory structure representing the different functional areas of the driver.
**Note:** The `.gitkeep` files are intentionally left to ensure that this directory structure is preserved even as the actual test files are moved around. | `npm run check:test` |
-| Benchmark | `/test/benchmarks` | The benchmark tests report how long a designated set of tests take to run. They are used to measure performance. | `npm run check:bench` |
-| Specialized Environment | `/test/manual` | The specalized environment tests are functional tests that require specialized environment setups in Evergreen.
**Note**: "manual" in the directory path does not refer to tests that should be run manually. These tests are automated. These tests have a special Evergreen configuration and run in isolation from the other tests. | There is no single script for running all of the specialized environment tests. Instead, you can run the appropriate script based on the specialized environment you want to use:
- `npm run check:atlas` to test Atlas
- `npm run check:adl` to test Atlas Data Lake
- `npm run check:ocsp` to test OCSP
- `npm run check:kerberos` to test Kerberos
- `npm run check:tls` to test TLS
- `npm run check:ldap` to test LDAP authorization |
-| TypeScript Definition | `/test/types` | The TypeScript definition tests verify the type definitions are correct. | `npm run check:tsd` |
-| GitHub Actions | `/test/action` | Tests that run as GitHub Actions such as dependency checking. | Currently, only `npm run check:dependencies` but could be expanded to more in the future. |
-| Code Examples | `/test/integration/node-specific/examples` | Code examples that are also paired with tests that show they are working examples. | Currently, `npm run check:lambda` to test the AWS Lambda example with default auth and `npm run check:lambda:aws` to test the AWS Lambda example with AWS auth. |
-| Explicit Resource Management | `/test/explicit-resource-management` | Tests that use explicit resource management with the driver's disposable resources. | `bash .evergreen/run-resource-management-feature-integration.sh` |
+| Type of Test | Test Location | About the Tests | How to Run Tests |
+| ---------------------------- | ------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
+| Unit | `/test/unit` | The unit tests test individual pieces of code, typically functions. These tests do **not** interact with a real database, so mocks are used instead.
The unit test directory mirrors the `/src` directory structure with test file names matching the source file names of the code they test. | `npm run check:unit` |
+| Integration | `/test/integration` | The integration tests test that a given feature or piece of a feature is working as expected. These tests do **not** use mocks; instead, they interact with a real database.
The integration test directory follows the `test/spec` directory structure representing the different functional areas of the driver.
**Note:** The `.gitkeep` files are intentionally left to ensure that this directory structure is preserved even as the actual test files are moved around. | `npm run check:test` |
+| Benchmark | `/test/benchmarks` | The benchmark tests report how long a designated set of tests take to run. They are used to measure performance. | `npm run check:bench` |
+| Specialized Environment | `/test/manual` | The specalized environment tests are functional tests that require specialized environment setups in Evergreen.
**Note**: "manual" in the directory path does not refer to tests that should be run manually. These tests are automated. These tests have a special Evergreen configuration and run in isolation from the other tests. | There is no single script for running all of the specialized environment tests. Instead, you can run the appropriate script based on the specialized environment you want to use:
- `npm run check:atlas` to test Atlas
- `npm run check:adl` to test Atlas Data Lake
- `npm run check:ocsp` to test OCSP
- `npm run check:kerberos` to test Kerberos
- `npm run check:tls` to test TLS
- `npm run check:ldap` to test LDAP authorization |
+| TypeScript Definition | `/test/types` | The TypeScript definition tests verify the type definitions are correct. | `npm run check:tsd` |
+| GitHub Actions | `/test/action` | Tests that run as GitHub Actions such as dependency checking. | Currently, only `npm run check:dependencies` but could be expanded to more in the future. |
+| Code Examples | `/test/integration/node-specific/examples` | Code examples that are also paired with tests that show they are working examples. | Currently, `npm run check:lambda` to test the AWS Lambda example with default auth and `npm run check:lambda:aws` to test the AWS Lambda example with AWS auth. |
+| Explicit Resource Management | `/test/explicit-resource-management` | Tests that use explicit resource management with the driver's disposable resources. | `bash .evergreen/run-resource-management-feature-integration.sh` |
### Spec Tests
@@ -295,89 +321,72 @@ When you run the benchmarks verify that the BSON version has been picked by the
- bson: 6.10.1 (installed from npm): (.../mongodb/node_modules/bson)
```
-## Testing with Special Environments
-
-In order to test some features, you will need to generate and set a specialized group of environment variables. The subsections below will walk you through how to generate and set the environment variables for these features.
+## Secrets
-We recommend using a different terminal for each specialized environment to avoid the environment variables from one specialized environment impacting the test runs for another specialized environment.
+Secrets needed for testing in special environments are managed in a drivers-wide AWS secrets manager vault.
-Before you begin any of the subsections below, clone the [drivers-evergreen-tools repo](https://github.com/mongodb-labs/drivers-evergreen-tools.git).
+drivers-evergreen-tools contains scripts that can fetch secrets from secrets manager for local use and use in CI in the [.evergreen/secrets_handling folder](https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/secrets_handling/README.md).
-We recommend creating an environment variable named `DRIVERS_TOOLS` that stores the path to your local copy of the `driver-evergreen-tools` repo:
+Local use of secrets manager requires:
-```sh
-export DRIVERS_TOOLS="/path/to/your/copy/of/drivers-evergreen-tools"
-```
+- the AWS SDK installed
+- an AWS profile with access to the AWS vault has been configured
-### Serverless
+(see instructions in the secrets handling readme).
-The following steps will walk you through how to create and test a MongoDB Serverless instance.
+Here's an example usage of the tooling in drivers-evergreen-tools that configures credentials for CSFLE:
-1. Create the following environment variables using a command like:
+```bash
+bash ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/csfle
+source secrets-export.sh
+```
- ```sh
- export PROJECT="node-driver"
- ```
+1. The `setup-secrets` script authenticates with AWS, fetches credentials and writes them to a bash file called `secrets-export.sh`.
+2. The setup-secrets accepts a space separated list of all the vaults from which to fetch credentials. in this case, we fetch credentials from the `drivers/csfle` vault.
+3. Source `secrets-export.sh` to load the credentials into the environment.
- > **Note:** MongoDB employees can pull these values from the Evergreen project's configuration.
+> [!IMPORTANT]
+> Make sure `secrets-export.sh` is in the .gitignore of any Github repo you might be using these tools in to avoid leaking credentials. This is already done for this repo.
- | Variable Name | Description |
- | ---------------------------- | ---------------------------------------------------------------------------------------------------------------- |
- | `Project` | The name of the Evergreen project where the tests will be run (e.g., `mongo-node-driver-next`) |
- | `SERVERLESS_DRIVERS_GROUP` | The Atlas organization where you will be creating the serverless instance |
- | `SERVERLESS_API_PUBLIC_KEY` | The [Atlas API Public Key][atlas-api-key] for the organization where you will be creating a serverless instance |
- | `SERVERLESS_API_PRIVATE_KEY` | The [Atlas API Private Key][atlas-api-key] for the organization where you will be creating a serverless instance |
- | `SERVERLESS_ATLAS_USER` | The [SCRAM username][scram-auth] for the Atlas user who has permission to create a serverless instance |
- | `SERVERLESS_ATLAS_PASSWORD` | The [SCRAM password][scram-auth] for the Atlas user who has permission to create a serverless instance |
+## Testing with Special Environments
- _**Remember**_ some of these are sensitive credentials, so keep them safe and only put them in your environment when you need them.
+In order to test some features, you will need to generate and set a specialized group of environment variables. The subsections below will walk you through how to generate and set the environment variables for these features.
-1. Run the [create-instance][create-instance-script] script:
+We recommend using a different terminal for each specialized environment to avoid the environment variables from one specialized environment impacting the test runs for another specialized environment.
- ```sh
- $DRIVERS_TOOLS/.evergreen/serverless/create-instance.sh
- ```
+Before you begin any of the subsections below, clone the [drivers-evergreen-tools repo](https://github.com/mongodb-labs/drivers-evergreen-tools.git).
- The script will take a few minutes to run. When it is finished, a new file named `serverless-expansion.yml` will be created in the current working directory. The file will contain information about an Evergreen expansion:
+We recommend creating an environment variable named `DRIVERS_TOOLS` that stores the path to your local copy of the `driver-evergreen-tools` repo (code examples in this section will assume this has been done):
- ```yml
- MONGODB_URI: xxx
- MONGODB_SRV_URI: xxx
- SERVERLESS_INSTANCE_NAME: xxx
- SSL: xxx
- AUTH: xxx
- TOPOLOGY: xxx
- SERVERLESS: xxx
- SERVERLESS_URI: xxx
- ```
+```sh
+export DRIVERS_TOOLS="/path/to/your/copy/of/drivers-evergreen-tools"
+```
-1. Generate a sourceable environment file from `serverless-expansion.yml` by running the following command:
+### Serverless
- ```sh
- cat serverless-expansion.yml | sed 's/: /=/g' > serverless.env
- ```
+The following steps will walk you through how to create and test a MongoDB Serverless instance.
- A new file named `serverless.env` is automatically created.
+> [!IMPORTANT]
+> If you set up an Atlas cluster for local use, you MUST delete it when you are finished with it using the [delete-instance script](https://github.com/mongodb-labs/drivers-evergreen-tools/blob/master/.evergreen/serverless/delete-instance.sh).
-1. Update the following variables in `serverless.env`, so that they are equivalent to what our Evergreen builds do:
+This script uses aws secrets manager to fetch credentials. Make sure you are logged into AWS and have your profile set correctly.
- - Change `MONGODB_URI` to have the same value as `SERVERLESS_URI`.
- - Add `SINGLE_MONGOS_LB_URI` and set it to the value of `SERVERLESS_URI`.
- - Add `MULTI_MONGOS_LB_URI` and set it to the value of `SERVERLESS_URI`.
+1. Run the setup-serverless script:
-1. Source the environment variables using a command like `source serverless.env`.
+```bash
+bash .evergreen/setup-serverless.sh
+```
-1. Export **each** of the environment variables that were created in `serverless.env`. For example:
+2. Source the expansions and secrets:
- ```sh
- export SINGLE_MONGOS_LB_URI
- ```
-
-1. Comment out the line in `.evergreen/run-serverless-tests.sh` that sources `install-dependencies.sh`.
+```bash
+source secrets-export.sh
+source serverless.env
+```
-1. Run the `.evergreen/run-serverless-tests.sh` script directly to test serverless instances from your local machine.
+3. Comment out the line in `.evergreen/run-serverless-tests.sh` that sources `install-dependencies.sh` (this downloads node and npm and is only used in CI).
-> Hint: If the test script fails with an error along the lines of `Uncaught TypeError: Cannot read properties of undefined (reading 'processId')`, ensure you do **not** have the `FAKE_MONGODB_SERVICE_ID` environment variable set.
+4. Run the `.evergreen/run-serverless-tests.sh` script directly to test serverless instances from your local machine.
### Load Balanced
@@ -499,15 +508,15 @@ The following steps will walk you through how to run the tests for CSFLE.
```
> **Note:** MongoDB employees can pull these values from the Evergreen project's configuration.
- | Variable Name |Description |
- | -----------------------|---------------------------------------------------------------- |
- | `AWS_ACCESS_KEY_ID` | The AWS access key ID used to generate KMS messages |
- | `AWS_SECRET_ACCESS_KEY`| The AWS secret access key used to generate KMS messages |
- | `AWS_REGION` | The AWS region where the KMS resides (e.g., `us-east-1`) |
- | `AWS_CMK_ID` | The Customer Master Key for the KMS |
- | `CSFLE_KMS_PROVIDERS` | The raw EJSON description of the KMS providers. An example of the format is provided below. |
- | `KMIP_TLS_CA_FILE` | /path/to/mongodb-labs/drivers-evergreen-tools/.evergreen/x509gen/ca.pem|
- | `KMIP_TLS_CERT_FILE` | /path/to/mongodb-labs/drivers-evergreen-tools/.evergreen/x509gen/client.pem |
+ | Variable Name | Description |
+ | ----------------------- | ------------------------------------------------------------------------------------------- |
+ | `AWS_ACCESS_KEY_ID` | The AWS access key ID used to generate KMS messages |
+ | `AWS_SECRET_ACCESS_KEY` | The AWS secret access key used to generate KMS messages |
+ | `AWS_REGION` | The AWS region where the KMS resides (e.g., `us-east-1`) |
+ | `AWS_CMK_ID` | The Customer Master Key for the KMS |
+ | `CSFLE_KMS_PROVIDERS` | The raw EJSON description of the KMS providers. An example of the format is provided below. |
+ | `KMIP_TLS_CA_FILE` | /path/to/mongodb-labs/drivers-evergreen-tools/.evergreen/x509gen/ca.pem |
+ | `KMIP_TLS_CERT_FILE` | /path/to/mongodb-labs/drivers-evergreen-tools/.evergreen/x509gen/client.pem |
The value of the `CSFLE_KMS_PROVIDERS` variable will have the following format:
@@ -663,6 +672,63 @@ lerna run test --scope @mongosh/service-provider-server
npx mocha --config test/mocha_mongodb.json test/integration/client-side-encryption/
```
+### Deployed KMS Tests
+
+CSFLE supports automatic KMS credential fetching for Azure, GCP and AWS. In order to e2e test GCP and Azure, we must run the tests on an actual GCP or Azure host (our ). This is supported by drivers-evergreen-tools.
+
+The basic idea is to
+
+1. Provision an Azure or GCP server.
+2. Set up a cluster on the server.
+3. Copy the driver and tests to the server and run the tests on the server.
+4. Copy the results back.
+
+All of this is handled in the csfle/azurekms and csfle/gcpkms folders in drivers-evergreen-tools.
+
+> [!IMPORTANT]
+> Azure VMs and GCP VMs must be destroyed with their corresponding `teardown.sh` scripts.
+
+#### Azure KMS
+
+1. Provision an Azure server. You must set the `AZUREKMS_VMNAME_PREFIX` variable:
+
+```bash
+export AZUREKMS_VMNAME_PREFIX: "NODE_DRIVER"
+bash ${DRIVERS_TOOLS}/.evergreen/csfle/azurekms/setup.sh
+```
+
+2. Comment out the following line in `run-deployed-azure-kms-tests.sh`:
+
+```bash
+source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
+```
+
+3. Run the tests:
+
+```bash
+bash .evergreen/run-deployed-azure-kms-tests.sh
+```
+
+#### GCP KMS
+
+1. Provision an GCP server.
+
+```bash
+bash ${DRIVERS_TOOLS}/.evergreen/csfle/gcpkms/setup.sh
+```
+
+1. Comment out the following line in `run-deployed-gcp-kms-tests.sh`:
+
+```bash
+source $DRIVERS_TOOLS/.evergreen/init-node-and-npm-env.sh
+```
+
+3. Run the tests:
+
+```bash
+bash .evergreen/run-deployed-gcp-kms-tests.sh
+```
+
### TODO Special Env Sections
- Kerberos
diff --git a/test/tools/runner/config.ts b/test/tools/runner/config.ts
index af596980c3f..ed1510505b5 100644
--- a/test/tools/runner/config.ts
+++ b/test/tools/runner/config.ts
@@ -86,7 +86,6 @@ export class TestConfiguration {
serverApi?: ServerApi;
activeResources: number;
isSrv: boolean;
- serverlessCredentials: { username: string | undefined; password: string | undefined };
constructor(
private uri: string,