Skip to content

ci(NODE-6211): fix atlas connectivity tests in 5.x #4152

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 2 commits into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 12 additions & 18 deletions .evergreen/config.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -434,29 +434,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 <<EOT > 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
Expand Down
29 changes: 11 additions & 18 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -389,29 +389,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 <<EOT > 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
Expand Down
7 changes: 5 additions & 2 deletions .evergreen/run-atlas-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,9 @@ test/lambda/env.json
!encryption/lib
!encryption/test
!encryption/test/types

# files generated by tooling in drivers-evergreen-tools
secrets-export.sh
mo-expansion.sh
mo-expansion.yml
expansions.sh
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"check:test": "mocha --config test/mocha_mongodb.json test/integration",
"check:unit": "mocha test/unit",
"check:ts": "node ./node_modules/typescript/bin/tsc -v && node ./node_modules/typescript/bin/tsc --noEmit",
"check:atlas": "mocha --config test/manual/mocharc.json test/manual/atlas_connectivity.test.js",
"check:atlas": "mocha --config test/manual/mocharc.json test/manual/atlas_connectivity.test.ts",
"check:adl": "mocha --config test/mocha_mongodb.json test/manual/atlas-data-lake-testing",
"check:aws": "nyc mocha --config test/mocha_mongodb.json test/integration/auth/mongodb_aws.test.ts",
"check:oidc": "mocha --config test/mocha_mongodb.json test/manual/mongodb_oidc.prose.test.ts",
Expand Down
50 changes: 0 additions & 50 deletions test/manual/atlas_connectivity.test.js

This file was deleted.

51 changes: 51 additions & 0 deletions test/manual/atlas_connectivity.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import { LEGACY_HELLO_COMMAND, MongoClient } from '../mongodb';

/**
* ATLAS_CONNECTIVITY env variable is JSON
* Here's some typescript describing the shape:
*
* ```typescript
* interface AtlasConnectivity {
* [atlasDeployment: string]: [normalUri: string, srvUri: string]
* }
* ```
*
* It should be an object with descriptive strings about the deployment type and version (i.e. sharded_cluster_3_4)
* that map to a two string tuple that are the normal URI and SRV URI, order doesn't matter, but it should be that order.
*/

describe('Atlas Connectivity', function () {
let client: MongoClient;

afterEach(async function () {
await client?.close();
});

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({});
});
}
});