Skip to content
Closed
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
353 changes: 348 additions & 5 deletions .evergreen/config.yml

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions .evergreen/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,18 @@ functions:

UNIFIED=${UNIFIED} MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-custom-csfle-tests.sh

"run custom snappy tests":
- command: subprocess.exec
params:
working_dir: "src"
timeout_secs: 60
env:
MONGODB_URI: ${MONGODB_URI}
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
binary: bash
args:
- "${PROJECT_DIRECTORY}/.evergreen/run-snappy-version-test.sh"

"upload test results":
- command: attach.xunit_results
params:
Expand Down
121 changes: 65 additions & 56 deletions .evergreen/generate_evergreen_tasks.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const fs = require('fs');
const yaml = require('js-yaml');

const LATEST_EFFECTIVE_VERSION = '5.0';
const MONGODB_VERSIONS = ['latest', '4.4', '4.2', '4.0', '3.6', '3.4', '3.2', '3.0', '2.6'];
const AWS_AUTH_VERSIONS = ['latest', '4.4'];
const OCSP_VERSIONS = ['latest', '4.4'];
const TLS_VERSIONS = ['latest', '4.2']; // also test on 4.2 because 4.4+ currently skipped on windows
const MONGODB_VERSIONS = ['latest', '5.0', '4.4', '4.2', '4.0', '3.6', '3.4', '3.2', '3.0', '2.6'];
const AWS_AUTH_VERSIONS = ['latest', '5.0', '4.4'];
const OCSP_VERSIONS = ['latest', '5.0', '4.4'];
const TLS_VERSIONS = ['latest', '5.0', '4.4', '4.2'];
const NODE_VERSIONS = ['fermium', 'erbium', 'dubnium', 'carbon', 'boron', 'argon'];
const TOPOLOGIES = ['server', 'replica_set', 'sharded_cluster'].concat([
'server-unified',
Expand Down Expand Up @@ -74,10 +74,7 @@ const OPERATING_SYSTEMS = [
)
);

const WINDOWS_SKIP_TAGS = new Set([
'atlas-connect',
'auth'
]);
const WINDOWS_SKIP_TAGS = new Set(['atlas-connect', 'auth']);

const BASE_TASKS = [];
const TASKS = [];
Expand Down Expand Up @@ -109,9 +106,7 @@ function makeTask({ mongoVersion, topology }) {
}

MONGODB_VERSIONS.forEach(mongoVersion => {
TOPOLOGIES.forEach(topology =>
BASE_TASKS.push(makeTask({ mongoVersion, topology }))
);
TOPOLOGIES.forEach(topology => BASE_TASKS.push(makeTask({ mongoVersion, topology })));
});

TASKS.push(
Expand All @@ -125,7 +120,8 @@ TASKS.push(
tags: ['auth', 'kerberos', 'legacy'],
commands: [
{ func: 'install dependencies' },
{ func: 'run kerberos tests',
{
func: 'run kerberos tests',
vars: {
UNIFIED: 0
}
Expand All @@ -137,7 +133,8 @@ TASKS.push(
tags: ['auth', 'kerberos', 'unified'],
commands: [
{ func: 'install dependencies' },
{ func: 'run kerberos tests',
{
func: 'run kerberos tests',
vars: {
UNIFIED: 1
}
Expand Down Expand Up @@ -296,7 +293,7 @@ OCSP_VERSIONS.forEach(VERSION => {
const AWS_AUTH_TASKS = [];

AWS_AUTH_VERSIONS.forEach(VERSION => {
const name = (ex) => `aws-${VERSION}-auth-test-${ex.split(' ').join('-')}`;
const name = ex => `aws-${VERSION}-auth-test-${ex.split(' ').join('-')}`;
// AWS_AUTH_TASKS.push(name);

const aws_funcs = [
Expand Down Expand Up @@ -325,10 +322,10 @@ AWS_AUTH_VERSIONS.forEach(VERSION => {
{ func: 'setup aws env' },
fn
]
}))
}));

TASKS.push(...aws_tasks);
AWS_AUTH_TASKS.push(...aws_tasks.map(t => t.name))
AWS_AUTH_TASKS.push(...aws_tasks.map(t => t.name));
});

const BUILD_VARIANTS = [];
Expand All @@ -342,31 +339,33 @@ const getTaskList = (() => {
return memo[key];
}
const taskList = BASE_TASKS.concat(TASKS);
const ret = taskList.filter(task => {
if (task.name.match(/^aws/)) return false;
const ret = taskList
.filter(task => {
if (task.name.match(/^aws/)) return false;

// skip unsupported tasks on windows
if (os.match(/^windows/) && task.tags.filter(tag => WINDOWS_SKIP_TAGS.has(tag)).length) {
return false;
}
// skip unsupported tasks on windows
if (os.match(/^windows/) && task.tags.filter(tag => WINDOWS_SKIP_TAGS.has(tag)).length) {
return false;
}

const tasksWithVars = task.commands.filter(task => !!task.vars);
if (!tasksWithVars.length) {
return true;
}
const tasksWithVars = task.commands.filter(task => !!task.vars);
if (!tasksWithVars.length) {
return true;
}

// kerberos tests don't require mongo orchestration
if (task.tags.filter(tag => tag === 'kerberos').length) {
return true;
}
// kerberos tests don't require mongo orchestration
if (task.tags.filter(tag => tag === 'kerberos').length) {
return true;
}

const { VERSION } = tasksWithVars[0].vars || {};
if (VERSION === 'latest') {
return semver.satisfies(semver.coerce(LATEST_EFFECTIVE_VERSION), mongoVersion);
}
const { VERSION } = tasksWithVars[0].vars || {};
if (VERSION === 'latest') {
return semver.satisfies(semver.coerce(LATEST_EFFECTIVE_VERSION), mongoVersion);
}

return semver.satisfies(semver.coerce(VERSION), mongoVersion);
}).map(x => x.name);
return semver.satisfies(semver.coerce(VERSION), mongoVersion);
})
.map(x => x.name);

memo[key] = ret;
return ret;
Expand Down Expand Up @@ -419,38 +418,48 @@ SINGLETON_TASKS.push({
]
});

SINGLETON_TASKS.push({
name: 'run-custom-csfle-tests',
tags: ['run-custom-csfle-tests'],
const oneOffFuncs = [
{ func: 'run custom csfle tests', vars: { UNIFIED: 1, NODE_LTS_NAME: 'erbium' } },
{ func: 'run custom snappy tests', vars: { UNIFIED: 1, NODE_LTS_NAME: 'erbium' } }
];

const oneOffFuncAsTasks = oneOffFuncs.map(oneOffFunc => ({
name: `${oneOffFunc.func.split(' ').join('-')}`,
tags: ['run-custom-dependency-tests'],
commands: [
{
func: 'install dependencies',
vars: {
NODE_LTS_NAME: 'erbium',
},
NODE_LTS_NAME: 'erbium'
}
},
{
func: 'bootstrap mongo-orchestration',
vars: {
VERSION: '4.4',
VERSION: '5.0',
TOPOLOGY: 'server'
}
},
{ func: 'run custom csfle tests' }
oneOffFunc
]
});
}));

BUILD_VARIANTS.push({
name: 'lint',
display_name: 'lint',
run_on: 'rhel70',
tasks: ['run-checks']
}, {
name: 'ubuntu1804-custom-csfle-tests',
display_name: 'Custom FLE Version Test',
run_on: 'ubuntu1804-test',
tasks: ['run-custom-csfle-tests']
});
SINGLETON_TASKS.push(...oneOffFuncAsTasks);

BUILD_VARIANTS.push(
{
name: 'lint',
display_name: 'lint',
run_on: 'rhel70',
tasks: ['run-checks']
},
{
name: 'ubuntu1804-custom-dependency-tests',
display_name: 'Custom Dependency Version Test',
run_on: 'ubuntu1804-large',
tasks: oneOffFuncAsTasks.map(({ name }) => name)
}
);

// special case for MONGODB-AWS authentication
BUILD_VARIANTS.push({
Expand All @@ -464,7 +473,7 @@ BUILD_VARIANTS.push({
});

const fileData = yaml.safeLoad(fs.readFileSync(`${__dirname}/config.yml.in`, 'utf8'));
fileData.tasks = (fileData.tasks || []).concat(BASE_TASKS).concat(TASKS).concat(SINGLETON_TASKS);
fileData.tasks = (fileData.tasks || []).concat(BASE_TASKS, TASKS, SINGLETON_TASKS);
fileData.buildvariants = (fileData.buildvariants || []).concat(BUILD_VARIANTS);

fs.writeFileSync(`${__dirname}/config.yml`, yaml.safeDump(fileData, { lineWidth: 120 }), 'utf8');
19 changes: 19 additions & 0 deletions .evergreen/init-nvm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#! /usr/bin/env bash

export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"

if [[ "$OS" == "Windows_NT" ]]; then
NVM_HOME=$(cygpath -w "$NVM_DIR")
export NVM_HOME
NVM_SYMLINK=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
export NVM_SYMLINK
NVM_ARTIFACTS_PATH=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
export NVM_ARTIFACTS_PATH
PATH=$(cygpath $NVM_SYMLINK):$(cygpath $NVM_HOME):$PATH
export PATH
echo "updated path on windows PATH=$PATH"
else
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
fi
12 changes: 12 additions & 0 deletions .evergreen/run-snappy-version-test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#! /usr/bin/env bash

source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
export MONGODB_URI="${MONGODB_URI}"

npm i --no-save snappy@6

npx mocha test/unit/snappy.test.js

npm i --no-save snappy@7

npx mocha test/unit/snappy.test.js
16 changes: 16 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [3.6.12](https://github.com/mongodb/node-mongodb-native/compare/v3.6.11...v3.6.12) (2021-08-30)


### Bug Fixes

* **NODE-3487:** check for nullish aws mechanism property ([#2957](https://github.com/mongodb/node-mongodb-native/issues/2957)) ([5902b4c](https://github.com/mongodb/node-mongodb-native/commit/5902b4c13a977c659af94b1fbcbcfbe5e7ca4db4))
* **NODE-3528:** add support for snappy v7 ([#2947](https://github.com/mongodb/node-mongodb-native/issues/2947)) ([54f5c2d](https://github.com/mongodb/node-mongodb-native/commit/54f5c2d682828bc751242cf4e90ea73f0342c842))

### [3.6.11](https://github.com/mongodb/node-mongodb-native/compare/v3.6.10...v3.6.11) (2021-08-05)


### Bug Fixes

* **NODE-1843:** bulk operations ignoring provided sessions [PORT] ([#2898](https://github.com/mongodb/node-mongodb-native/issues/2898)) ([9244b17](https://github.com/mongodb/node-mongodb-native/commit/9244b1771e538f7b685fd6d4aa83d9da84b20093))
* **NODE-3199:** unable to bundle driver due to uncaught require ([#2903](https://github.com/mongodb/node-mongodb-native/issues/2903)) ([60efe9d](https://github.com/mongodb/node-mongodb-native/commit/60efe9d0030477da462d326c2e2ddc5fe6c0ffff))

### [3.6.10](https://github.com/mongodb/node-mongodb-native/compare/v3.6.9...v3.6.10) (2021-07-06)


Expand Down
9 changes: 6 additions & 3 deletions lib/bulk/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1176,8 +1176,11 @@ class BulkOperationBase {
* @param {function} callback
*/
bulkExecute(_writeConcern, options, callback) {
if (typeof options === 'function') (callback = options), (options = {});
options = options || {};
if (typeof options === 'function') {
callback = options;
}

const finalOptions = Object.assign({}, this.s.options, options);

if (typeof _writeConcern === 'function') {
callback = _writeConcern;
Expand All @@ -1203,7 +1206,7 @@ class BulkOperationBase {
const emptyBatchError = toError('Invalid Operation, no operations specified');
return this._handleEarlyError(emptyBatchError, callback);
}
return { options, callback };
return { options: finalOptions, callback };
}

/**
Expand Down
5 changes: 4 additions & 1 deletion lib/core/auth/mongo_credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ class MongoCredentials {
this.password = process.env.AWS_SECRET_ACCESS_KEY;
}

if (!this.mechanismProperties.AWS_SESSION_TOKEN && process.env.AWS_SESSION_TOKEN) {
if (
this.mechanismProperties.AWS_SESSION_TOKEN == null &&
process.env.AWS_SESSION_TOKEN != null
) {
this.mechanismProperties.AWS_SESSION_TOKEN = process.env.AWS_SESSION_TOKEN;
}
}
Expand Down
32 changes: 17 additions & 15 deletions lib/core/auth/mongodb_aws.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const url = require('url');

let aws4;
try {
// Ensure you always wrap an optional require in the try block NODE-3199
aws4 = require('aws4');
} catch (e) {
// don't do anything;
Expand Down Expand Up @@ -50,12 +51,21 @@ class MongoDBAWS extends AuthProvider {
return;
}

const username = credentials.username;
const password = credentials.password;
const db = credentials.source;
const token = credentials.mechanismProperties.AWS_SESSION_TOKEN;
const bson = this.bson;

const accessKeyId = credentials.username;
const secretAccessKey = credentials.password;
const sessionToken = credentials.mechanismProperties.AWS_SESSION_TOKEN;

// If all three defined, include sessionToken, else include username and pass, else no credentials
const awsCredentials =
accessKeyId && secretAccessKey && sessionToken
? { accessKeyId, secretAccessKey, sessionToken }
: accessKeyId && secretAccessKey
? { accessKeyId, secretAccessKey }
: undefined;

crypto.randomBytes(32, (err, nonce) => {
if (err) {
callback(err);
Expand Down Expand Up @@ -108,18 +118,14 @@ class MongoDBAWS extends AuthProvider {
path: '/',
body
},
{
accessKeyId: username,
secretAccessKey: password,
token
}
awsCredentials
);

const authorization = options.headers.Authorization;
const date = options.headers['X-Amz-Date'];
const payload = { a: authorization, d: date };
if (token) {
payload.t = token;
if (sessionToken) {
payload.t = sessionToken;
}

const saslContinue = {
Expand Down Expand Up @@ -163,6 +169,7 @@ function makeTempCredentials(credentials, callback) {
if (process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI) {
request(
`${AWS_RELATIVE_URI}${process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}`,
undefined,
(err, res) => {
if (err) return callback(err);
done(res);
Expand Down Expand Up @@ -214,11 +221,6 @@ function deriveRegion(host) {
}

function request(uri, options, callback) {
if (typeof options === 'function') {
callback = options;
options = {};
}

options = Object.assign(
{
method: 'GET',
Expand Down
Loading