diff --git a/.evergreen/config.in.yml b/.evergreen/config.in.yml index 2845e14065f..2f40498ff54 100644 --- a/.evergreen/config.in.yml +++ b/.evergreen/config.in.yml @@ -440,29 +440,23 @@ functions: rm -rf ./node_modules/@aws-sdk/credential-providers "run atlas tests": - - command: shell.exec - type: test + # This creates secrets-export.sh, which is later sourced by run-tests.sh + - command: subprocess.exec params: - silent: true working_dir: "src" - script: | - cat < prepare_atlas_connectivity.sh - export ATLAS_CONNECTIVITY='${ATLAS_CONNECTIVITY}' - EOT - - command: shell.exec + binary: bash + args: + - -c + - ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/atlas_connect + - command: subprocess.exec type: test params: working_dir: "src" - script: | - # Disable xtrace (just in case it was accidentally set). - set +x - . ./prepare_atlas_connectivity.sh - rm -f ./prepare_atlas_connectivity.sh - - export PROJECT_DIRECTORY="$(pwd)" - export NODE_LTS_VERSION='${NODE_LTS_VERSION}' - - bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh + binary: bash + env: + NODE_LTS_VERSION: ${NODE_LTS_VERSION} + args: + - .evergreen/run-atlas-tests.sh "run socks5 tests": - command: shell.exec diff --git a/.evergreen/config.yml b/.evergreen/config.yml index d80f3d3f4c8..a53a9d702c9 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -395,29 +395,22 @@ functions: source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh" rm -rf ./node_modules/@aws-sdk/credential-providers run atlas tests: - - command: shell.exec - type: test + - command: subprocess.exec params: - silent: true working_dir: src - script: | - cat < prepare_atlas_connectivity.sh - export ATLAS_CONNECTIVITY='${ATLAS_CONNECTIVITY}' - EOT - - command: shell.exec + binary: bash + args: + - '-c' + - ${DRIVERS_TOOLS}/.evergreen/secrets_handling/setup-secrets.sh drivers/atlas_connect + - command: subprocess.exec type: test params: working_dir: src - script: | - # Disable xtrace (just in case it was accidentally set). - set +x - . ./prepare_atlas_connectivity.sh - rm -f ./prepare_atlas_connectivity.sh - - export PROJECT_DIRECTORY="$(pwd)" - export NODE_LTS_VERSION='${NODE_LTS_VERSION}' - - bash ${PROJECT_DIRECTORY}/.evergreen/run-atlas-tests.sh + binary: bash + env: + NODE_LTS_VERSION: ${NODE_LTS_VERSION} + args: + - .evergreen/run-atlas-tests.sh run socks5 tests: - command: shell.exec type: test diff --git a/.evergreen/run-atlas-tests.sh b/.evergreen/run-atlas-tests.sh index c65b8512a77..694cefaf431 100644 --- a/.evergreen/run-atlas-tests.sh +++ b/.evergreen/run-atlas-tests.sh @@ -2,9 +2,12 @@ set -o errexit # Exit the script with error if any of the commands fail -source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh" +if test -f secrets-export.sh; then + source secrets-export.sh +fi -set -o xtrace +PROJECT_DIRECTORY=${PROJECT_DIRECTORY:-"."} +source "${PROJECT_DIRECTORY}/.evergreen/init-node-and-npm-env.sh" node -v diff --git a/test/manual/atlas_connectivity.test.ts b/test/manual/atlas_connectivity.test.ts index dc55bbe7930..a49ed0bafc6 100644 --- a/test/manual/atlas_connectivity.test.ts +++ b/test/manual/atlas_connectivity.test.ts @@ -15,47 +15,37 @@ import { LEGACY_HELLO_COMMAND, MongoClient } from '../mongodb'; */ describe('Atlas Connectivity', function () { - const { ATLAS_CONNECTIVITY = '' } = process.env; - if (ATLAS_CONNECTIVITY === '') throw new Error('ATLAS_CONNECTIVITY not defined in env'); - - const CONFIGS: Record = - JSON.parse(ATLAS_CONNECTIVITY); - let client: MongoClient; afterEach(async function () { - await client.close(); + await client?.close(); }); - for (const configName of Object.keys(CONFIGS)) { - context(configName, function () { - for (const connectionString of CONFIGS[configName]) { - const name = connectionString.includes('mongodb+srv') ? 'mongodb+srv' : 'normal'; - - beforeEach(function () { - if (configName === 'replica_set_4_4_free') { - const today = new Date(); - // Making this April 1st so it is a monday - const april1st2024 = new Date('2024-04-01'); - if (today < april1st2024) { - if (this.currentTest) - this.currentTest.skipReason = - 'TODO(NODE-6027): Un-skip replica_set_4_4_free after March 29th 2024'; - this.skip(); - } - } - }); - - it(name, async function () { - this.timeout(40000); - - client = new MongoClient(connectionString); - - await client.connect(); - await client.db('admin').command({ [LEGACY_HELLO_COMMAND]: 1 }); - await client.db('test').collection('test').findOne({}); - }); - } + const environments = [ + 'ATLAS_SERVERLESS', + 'ATLAS_SRV_SERVERLESS', + 'ATLAS_FREE', + 'ATLAS_SRV_FREE', + 'ATLAS_REPL', + 'ATLAS_SRV_REPL', + 'ATLAS_SHRD', + 'ATLAS_SRV_SHRD', + 'ATLAS_TLS11', + 'ATLAS_SRV_TLS11', + 'ATLAS_TLS12', + 'ATLAS_SRV_TLS12' + ]; + + for (const environment of environments) { + it(`${environment} connects successfully`, async function () { + this.timeout(40000); + + // eslint-disable-next-line @typescript-eslint/no-non-null-assertion + client = new MongoClient(process.env[environment]!); + + await client.connect(); + await client.db('admin').command({ [LEGACY_HELLO_COMMAND]: 1 }); + await client.db('test').collection('test').findOne({}); }); } });