Skip to content
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
86 changes: 75 additions & 11 deletions .evergreen/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,24 @@ functions:
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} NO_EXIT=${NO_EXIT|1} \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh
run serverless tests:
- command: timeout.update
params:
exec_timeout_secs: 1800
- command: shell.exec
type: test
params:
working_dir: src
script: |
${PREPARE_SHELL}
# Disable xtrace (just in case it was accidentally set).
set +x
MONGODB_URI="${MONGODB_URI}" \
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
AUTH="auth" SSL="ssl" SERVERLESS=1 \
SERVERLESS_ATLAS_USER="${SERVERLESS_ATLAS_USER}" \
SERVERLESS_ATLAS_PASSWORD="${SERVERLESS_ATLAS_PASSWORD}" \
bash ${PROJECT_DIRECTORY}/.evergreen/run-serverless-tests.sh
start-load-balancer:
- command: shell.exec
params:
Expand Down Expand Up @@ -605,18 +623,12 @@ functions:
- command: attach.xunit_results
params:
file: src/xunit.xml
pre:
- func: fetch source
- func: prepare resources
- func: windows fix
- func: fix absolute paths
- func: make files executable
post:
- func: upload test results
- func: cleanup
ignore:
- '*.md'
tasks:
- name: test-serverless
tags:
- serverless
commands:
- func: run serverless tests
- name: test-latest-server
tags:
- latest
Expand Down Expand Up @@ -1689,6 +1701,51 @@ tasks:
- func: run bson-ext test
vars:
NODE_LTS_NAME: erbium
task_groups:
- name: serverless_task_group
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800
setup_group:
- func: fetch source
- func: prepare resources
- command: shell.exec
params:
shell: bash
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} \
bash ${DRIVERS_TOOLS}/.evergreen/serverless/create-instance.sh
- command: expansions.update
params:
file: serverless-expansion.yml
teardown_group:
- func: upload test results
- command: shell.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
tasks:
- .serverless
pre:
- func: fetch source
- func: prepare resources
- func: windows fix
- func: fix absolute paths
- func: make files executable
post:
- func: upload test results
- func: cleanup
ignore:
- '*.md'
buildvariants:
- name: macos-1014-erbium
display_name: macOS 10.14 Node Erbium
Expand Down Expand Up @@ -1975,3 +2032,10 @@ buildvariants:
- aws-4.4-auth-test-run-aws-auth-test-with-aws-credentials-as-environment-variables
- aws-4.4-auth-test-run-aws-auth-test-with-aws-credentials-and-session-token-as-environment-variables
- aws-4.4-auth-test-run-aws-ECS-auth-test
- name: ubuntu1804-test-serverless
display_name: Serverless Test
run_on: ubuntu1804-test
expansions:
NODE_LTS_NAME: erbium
tasks:
- serverless_task_group
60 changes: 60 additions & 0 deletions .evergreen/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,25 @@ functions:
NODE_VERSION=${NODE_VERSION} SKIP_DEPS=${SKIP_DEPS|1} NO_EXIT=${NO_EXIT|1} \
bash ${PROJECT_DIRECTORY}/.evergreen/run-tests.sh

"run serverless tests":
- command: timeout.update
params:
exec_timeout_secs: 1800
- command: shell.exec
type: test
params:
working_dir: "src"
script: |
${PREPARE_SHELL}
# Disable xtrace (just in case it was accidentally set).
set +x
MONGODB_URI="${MONGODB_URI}" \
MONGODB_API_VERSION="${MONGODB_API_VERSION}" \
AUTH="auth" SSL="ssl" SERVERLESS=1 \
SERVERLESS_ATLAS_USER="${SERVERLESS_ATLAS_USER}" \
SERVERLESS_ATLAS_PASSWORD="${SERVERLESS_ATLAS_PASSWORD}" \
bash ${PROJECT_DIRECTORY}/.evergreen/run-serverless-tests.sh

"start-load-balancer":
- command: shell.exec
params:
Expand Down Expand Up @@ -648,6 +667,47 @@ functions:
params:
file: "src/xunit.xml"

tasks:
- name: "test-serverless"
tags: ["serverless"]
commands:
- func: "run serverless tests"

task_groups:
- name: serverless_task_group
setup_group_can_fail_task: true
setup_group_timeout_secs: 1800 # 30 minutes
setup_group:
- func: "fetch source"
- func: "prepare resources"
- command: shell.exec
params:
shell: "bash"
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} \
bash ${DRIVERS_TOOLS}/.evergreen/serverless/create-instance.sh
- command: expansions.update
params:
file: serverless-expansion.yml
teardown_group:
- func: "upload test results"
- command: shell.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
tasks:
- ".serverless"

pre:
- func: "fetch source"
- func: "prepare resources"
Expand Down
11 changes: 11 additions & 0 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -626,6 +626,17 @@ SINGLETON_TASKS.push({
]
});

// special case for serverless testing
BUILD_VARIANTS.push({
name: 'ubuntu1804-test-serverless',
display_name: 'Serverless Test',
run_on: 'ubuntu1804-test',
expansions: {
NODE_LTS_NAME: LOWEST_LTS
},
tasks: ['serverless_task_group']
});

const fileData = yaml.safeLoad(fs.readFileSync(`${__dirname}/config.yml.in`, 'utf8'));
fileData.tasks = (fileData.tasks || []).concat(BASE_TASKS).concat(TASKS).concat(SINGLETON_TASKS);
fileData.buildvariants = (fileData.buildvariants || []).concat(BUILD_VARIANTS);
Expand Down
13 changes: 13 additions & 0 deletions .evergreen/run-serverless-tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash
source "${PROJECT_DIRECTORY}/.evergreen/install-dependencies.sh"

SERVERLESS_ATLAS_USER="${SERVERLESS_ATLAS_USER}" \
SERVERLESS_ATLAS_PASSWORD="${SERVERLESS_ATLAS_PASSWORD}" \
SERVERLESS=1 AUTH=auth SSL=ssl \
MONGODB_URI=${MONGODB_URI} npx mocha \
test/functional/crud_spec.test.js \
test/functional/retryable_reads.test.js \
test/functional/retryable_writes.test.js \
test/functional/sessions.test.js \
test/functional/transactions.test.js \
test/functional/versioned-api.test.js
Comment on lines +7 to +13
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this list specified in a spec or something? I foresee us changing filenames / commands for our upcoming test upgrades, what do we need to filter on here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes this list comes from the spec:

Tests defined in the following specifications MUST be included in a driver's
Atlas Serverless testing suite, including prose tests:

- CRUD, including the v1 and unified tests
- Retryable Writes
- Retryable Reads
- Versioned API
- Driver Sessions
- Transactions (excluding convenient API)

5 changes: 4 additions & 1 deletion test/functional/crud_spec.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ function enforceServerVersionLimits(requires, scenario) {
if (versionLimits.length) {
requires.mongodb = versionLimits.join(' ');
}
if (scenario.serverless) {
requires.serverless = scenario.serverless;
}
}

function findScenarios() {
Expand All @@ -35,7 +38,7 @@ const readScenarios = findScenarios('v1', 'read');
const writeScenarios = findScenarios('v1', 'write');

const testContext = {};
describe('CRUD spec', function () {
describe('CRUD spec v1', function () {
beforeEach(function () {
const configuration = this.configuration;
const client = configuration.newClient();
Expand Down
6 changes: 5 additions & 1 deletion test/functional/sessions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ describe('Sessions', function () {
});

describe('withSession', {
metadata: { requires: { mongodb: '>=3.6.0' } },
metadata: {
requires: {
mongodb: '>=3.6.0'
}
},
test: function () {
beforeEach(function () {
return test.setup(this.configuration);
Expand Down
6 changes: 6 additions & 0 deletions test/functional/spec-runner/context.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ class TestRunnerContext {
this.user = opts.user;
this.password = opts.password;
this.authSource = opts.authSource;
if (process.env.SERVERLESS) {
this.user = process.env.SERVERLESS_ATLAS_USER;
this.password = process.env.SERVERLESS_ATLAS_PASSWORD;
this.authSource = 'admin';
this.serverless = true;
}
this.sharedClient = null;
this.failPointClients = [];
this.appliedFailPoints = [];
Expand Down
44 changes: 30 additions & 14 deletions test/functional/spec-runner/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const { EJSON } = require('bson');
const { isRecord } = require('../../../src/utils');
const TestRunnerContext = require('./context').TestRunnerContext;
const resolveConnectionString = require('./utils').resolveConnectionString;
const { shouldRunServerlessTest } = require('../../tools/utils');

// Promise.try alternative https://stackoverflow.com/questions/60624081/promise-try-without-bluebird/60624164?noredirect=1#comment107255389_60624164
function promiseTry(callback) {
Expand Down Expand Up @@ -110,7 +111,12 @@ function parseRunOn(runOn) {
}

const mongodb = version.join(' ');
return { topology, mongodb, authEnabled: !!config.authEnabled };
return {
topology,
mongodb,
authEnabled: !!config.authEnabled,
serverless: config.serverless
};
});
}

Expand Down Expand Up @@ -167,6 +173,13 @@ function shouldRunSpecTest(configuration, requires, spec, filter) {
return false;
}

if (
requires.serverless &&
!shouldRunServerlessTest(requires.serverless, !!process.env.SERVERLESS)
) {
return false;
}

if (
spec.operations.some(
op => op.name === 'waitForEvent' && op.arguments.event === 'PoolReadyEvent'
Expand All @@ -191,20 +204,23 @@ function prepareDatabaseForSuite(suite, context) {

if (context.skipPrepareDatabase) return Promise.resolve();

const setupPromise = db
.admin()
.command({ killAllSessions: [] })
.catch(err => {
if (
err.message.match(/no such (cmd|command)/) ||
err.message.match(/Failed to kill on some hosts/) ||
err.code === 11601
) {
return;
}
// Note: killAllSession is not supported on serverless, see CLOUDP-84298
const setupPromise = context.serverless
? Promise.resolve()
: db
.admin()
.command({ killAllSessions: [] })
.catch(err => {
if (
err.message.match(/no such (cmd|command)/) ||
err.message.match(/Failed to kill on some hosts/) ||
err.code === 11601
) {
return;
}

throw err;
});
throw err;
});

if (context.collectionName == null || context.dbName === 'admin') {
return setupPromise;
Expand Down
Loading