Skip to content

test(NODE-3735): update to use serverless uri #3359

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 4 commits into from
Aug 16, 2022
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
12 changes: 6 additions & 6 deletions .evergreen/config.in.yml
Original file line number Diff line number Diff line change
Expand Up @@ -189,17 +189,17 @@ functions:
export SERVERLESS="1"
export SERVERLESS_ATLAS_USER="${SERVERLESS_ATLAS_USER}"
export SERVERLESS_ATLAS_PASSWORD="${SERVERLESS_ATLAS_PASSWORD}"
export SERVERLESS_URI="${SERVERLESS_URI}"

export SINGLE_ATLASPROXY_SERVERLESS_URI="${SINGLE_ATLASPROXY_SERVERLESS_URI}"
export MULTI_ATLASPROXY_SERVERLESS_URI="${MULTI_ATLASPROXY_SERVERLESS_URI}"
echo "setting SERVERLESS_URI: $SERVERLESS_URI"

export MONGODB_URI="${SINGLE_ATLASPROXY_SERVERLESS_URI}"
export SINGLE_MONGOS_LB_URI="${SINGLE_ATLASPROXY_SERVERLESS_URI}"
export MONGODB_URI="${SERVERLESS_URI}"
export SINGLE_MONGOS_LB_URI="${SERVERLESS_URI}"

# Setting MULTI_MONGOS to the SINGLE_ATLAS is intentional
# 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="${SINGLE_ATLASPROXY_SERVERLESS_URI}"
export MULTI_MONGOS_LB_URI="${SERVERLESS_URI}"

bash ${PROJECT_DIRECTORY}/.evergreen/run-serverless-tests.sh

Expand Down
12 changes: 6 additions & 6 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,17 +168,17 @@ functions:
export SERVERLESS="1"
export SERVERLESS_ATLAS_USER="${SERVERLESS_ATLAS_USER}"
export SERVERLESS_ATLAS_PASSWORD="${SERVERLESS_ATLAS_PASSWORD}"
export SERVERLESS_URI="${SERVERLESS_URI}"

export SINGLE_ATLASPROXY_SERVERLESS_URI="${SINGLE_ATLASPROXY_SERVERLESS_URI}"
export MULTI_ATLASPROXY_SERVERLESS_URI="${MULTI_ATLASPROXY_SERVERLESS_URI}"
echo "setting SERVERLESS_URI: $SERVERLESS_URI"

export MONGODB_URI="${SINGLE_ATLASPROXY_SERVERLESS_URI}"
export SINGLE_MONGOS_LB_URI="${SINGLE_ATLASPROXY_SERVERLESS_URI}"
export MONGODB_URI="${SERVERLESS_URI}"
export SINGLE_MONGOS_LB_URI="${SERVERLESS_URI}"

# Setting MULTI_MONGOS to the SINGLE_ATLAS is intentional
# 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="${SINGLE_ATLASPROXY_SERVERLESS_URI}"
export MULTI_MONGOS_LB_URI="${SERVERLESS_URI}"

bash ${PROJECT_DIRECTORY}/.evergreen/run-serverless-tests.sh
start-load-balancer:
Expand Down
11 changes: 5 additions & 6 deletions .evergreen/run-serverless-tests.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
source "${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh"

if [ -z ${SERVERLESS+omitted} ]; then echo "SERVERLESS is unset" && exit 1; fi
if [ -z ${MULTI_ATLASPROXY_SERVERLESS_URI+omitted} ]; then echo "MULTI_ATLASPROXY_SERVERLESS_URI is unset" && exit 1; fi
if [ -z ${SINGLE_ATLASPROXY_SERVERLESS_URI+omitted} ]; then echo "SINGLE_ATLASPROXY_SERVERLESS_URI 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
Expand All @@ -16,10 +15,10 @@ npx mocha \
test/integration/crud/crud.spec.test.js \
test/integration/crud/crud.prose.test.js \
test/integration/retryable-reads/retryable_reads.spec.test.js \
test/integration/retryable-writes/retryable_writes.spec.test.js \
test/integration/sessions/sessions.spec.test.js \
test/integration/sessions/sessions.test.js \
test/integration/retryable-writes/retryable_writes.spec.test.ts \
test/integration/sessions/sessions.spec.test.ts \
test/integration/sessions/sessions.test.ts \
test/integration/transactions/transactions.spec.test.js \
test/integration/transactions/transactions.test.js \
test/integration/transactions/transactions.test.ts \
test/integration/versioned-api/versioned_api.spec.test.js \
test/integration/load-balancers/load_balancers.spec.test.js
9 changes: 4 additions & 5 deletions test/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,7 @@ The following steps will walk you through how to create and test a MongoDB Serve
AUTH: xxx
TOPOLOGY: xxx
SERVERLESS: xxx
MULTI_ATLASPROXY_SERVERLESS_URI: xxx
SINGLE_ATLASPROXY_SERVERLESS_URI: xxx
SERVERLESS_URI: xxx
```

1. Generate a sourceable environment file from `serverless-expansion.yml` by running the following command:
Expand All @@ -245,9 +244,9 @@ The following steps will walk you through how to create and test a MongoDB Serve

1. Update the following variables in `serverless.env`, so that they are equivalent to what our Evergreen builds do:

- Change `MONGODB_URI` to have the same value as `SINGLE_ATLASPROXY_SERVERLESS_URI`.
- Add `SINGLE_MONGOS_LB_URI` and set it to the value of `SINGLE_ATLASPROXY_SERVERLESS_URI`.
- Add `MULTI_MONGOS_LB_URI` and set it to the value of `SINGLE_ATLASPROXY_SERVERLESS_URI`.
- 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. Source the environment variables using a command like `source serverless.env`.

Expand Down
25 changes: 16 additions & 9 deletions test/tools/runner/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,10 @@ export class TestConfiguration {
hostAddresses,
hostAddress: hostAddresses[0],
host: hostAddresses[0].host,
port: typeof hostAddresses[0].host === 'string' ? hostAddresses[0].port : undefined,
port:
typeof hostAddresses[0].host === 'string' && !this.isServerless
? hostAddresses[0].port
: undefined,
db: url.pathname.slice(1) ? url.pathname.slice(1) : 'integration_tests',
replicaSet: url.searchParams.get('replicaSet'),
proxyURIParams: url.searchParams.get('proxyHost')
Expand All @@ -112,7 +115,9 @@ export class TestConfiguration {
}

get isLoadBalanced() {
return !!this.singleMongosLoadBalancerUri && !!this.multiMongosLoadBalancerUri;
return (
!!this.singleMongosLoadBalancerUri && !!this.multiMongosLoadBalancerUri && !this.isServerless
);
}

writeConcern() {
Expand Down Expand Up @@ -194,7 +199,7 @@ export class TestConfiguration {
delete dbOptions.writeConcern;
}

if (this.topologyType === TopologyType.LoadBalanced) {
if (this.topologyType === TopologyType.LoadBalanced && !this.isServerless) {
dbOptions.loadBalanced = true;
}

Expand All @@ -203,10 +208,10 @@ export class TestConfiguration {
}

const urlOptions: url.UrlObject = {
protocol: 'mongodb',
protocol: this.isServerless ? 'mongodb+srv' : 'mongodb',
slashes: true,
hostname: dbHost,
port: dbPort,
port: this.isServerless ? null : dbPort,
query: dbOptions,
pathname: '/'
};
Expand Down Expand Up @@ -267,7 +272,8 @@ export class TestConfiguration {

const FILLER_HOST = 'fillerHost';

const url = new URL(`mongodb://${FILLER_HOST}`);
const protocol = this.isServerless ? 'mongodb+srv' : 'mongodb';
const url = new URL(`${protocol}://${FILLER_HOST}`);

if (options.replicaSet) {
url.searchParams.append('replicaSet', options.replicaSet);
Expand All @@ -294,7 +300,7 @@ export class TestConfiguration {
url.password = password;
}

if (this.isLoadBalanced) {
if (this.isLoadBalanced && !this.isServerless) {
url.searchParams.append('loadBalanced', 'true');
}

Expand All @@ -319,7 +325,8 @@ export class TestConfiguration {
}

let actualHostsString;
if (options.useMultipleMongoses) {
// Ignore multi mongos options in serverless testing.
if (options.useMultipleMongoses && !this.isServerless) {
if (this.isLoadBalanced) {
const multiUri = new ConnectionString(this.multiMongosLoadBalancerUri);
if (multiUri.isSRV) {
Expand All @@ -331,7 +338,7 @@ export class TestConfiguration {
actualHostsString = this.options.hostAddresses.map(ha => ha.toString()).join(',');
}
} else {
if (this.isLoadBalanced) {
if (this.isLoadBalanced || this.isServerless) {
const singleUri = new ConnectionString(this.singleMongosLoadBalancerUri);
actualHostsString = singleUri.hosts[0].toString();
} else {
Expand Down