Skip to content

Commit 4c25984

Browse files
authored
chore: sync 3.6 changes to 3.7 (#2963)
1 parent e5975af commit 4c25984

24 files changed

+7743
-754
lines changed

.evergreen/config.yml

Lines changed: 348 additions & 5 deletions
Large diffs are not rendered by default.

.evergreen/config.yml.in

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -525,6 +525,18 @@ functions:
525525

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

528+
"run custom snappy tests":
529+
- command: subprocess.exec
530+
params:
531+
working_dir: "src"
532+
timeout_secs: 60
533+
env:
534+
MONGODB_URI: ${MONGODB_URI}
535+
PROJECT_DIRECTORY: ${PROJECT_DIRECTORY}
536+
binary: bash
537+
args:
538+
- "${PROJECT_DIRECTORY}/.evergreen/run-snappy-version-test.sh"
539+
528540
"upload test results":
529541
- command: attach.xunit_results
530542
params:

.evergreen/generate_evergreen_tasks.js

Lines changed: 63 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ const yaml = require('js-yaml');
66

77
const LATEST_EFFECTIVE_VERSION = '5.0';
88
const LEGACY_MONGODB_VERSIONS = new Set(['4.4', '4.2', '4.0', '3.6', '3.4', '3.2', '3.0', '2.6']);
9-
const MONGODB_VERSIONS = ['latest'].concat(Array.from(LEGACY_MONGODB_VERSIONS));
10-
const AWS_AUTH_VERSIONS = ['latest', '4.4'];
11-
const OCSP_VERSIONS = ['latest', '4.4'];
12-
const TLS_VERSIONS = ['latest', '4.2']; // also test on 4.2 because 4.4+ currently skipped on windows
9+
const MONGODB_VERSIONS = ['latest', '5.0'].concat(Array.from(LEGACY_MONGODB_VERSIONS));
10+
const AWS_AUTH_VERSIONS = ['latest', '5.0', '4.4'];
11+
const OCSP_VERSIONS = ['latest', '5.0', '4.4'];
12+
const TLS_VERSIONS = ['latest', '5.0', '4.2']; // also test on 4.2 because 4.4+ currently skipped on windows
1313
const NODE_VERSIONS = ['fermium', 'erbium', 'dubnium', 'carbon', 'boron', 'argon'];
1414
const LEGACY_TOPOLOGIES = new Set(['server', 'replica_set', 'sharded_cluster']);
1515
const UNIFIED_TOPOLOGIES = Array.from(LEGACY_TOPOLOGIES).map(topology => `${topology}-unified`);
@@ -154,7 +154,8 @@ TASKS.push(
154154
tags: ['auth', 'kerberos', 'legacy'],
155155
commands: [
156156
{ func: 'install dependencies' },
157-
{ func: 'run kerberos tests',
157+
{
158+
func: 'run kerberos tests',
158159
vars: {
159160
UNIFIED: 0
160161
}
@@ -166,7 +167,8 @@ TASKS.push(
166167
tags: ['auth', 'kerberos', 'unified'],
167168
commands: [
168169
{ func: 'install dependencies' },
169-
{ func: 'run kerberos tests',
170+
{
171+
func: 'run kerberos tests',
170172
vars: {
171173
UNIFIED: 1
172174
}
@@ -325,7 +327,7 @@ OCSP_VERSIONS.forEach(VERSION => {
325327
const AWS_AUTH_TASKS = [];
326328

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

331333
const aws_funcs = [
@@ -354,10 +356,10 @@ AWS_AUTH_VERSIONS.forEach(VERSION => {
354356
{ func: 'setup aws env' },
355357
fn
356358
]
357-
}))
359+
}));
358360

359361
TASKS.push(...aws_tasks);
360-
AWS_AUTH_TASKS.push(...aws_tasks.map(t => t.name))
362+
AWS_AUTH_TASKS.push(...aws_tasks.map(t => t.name));
361363
});
362364

363365
const BUILD_VARIANTS = [];
@@ -371,31 +373,33 @@ const getTaskList = (() => {
371373
return memo[key];
372374
}
373375
const taskList = BASE_TASKS.concat(TASKS);
374-
const ret = taskList.filter(task => {
375-
if (task.name.match(/^aws/)) return false;
376+
const ret = taskList
377+
.filter(task => {
378+
if (task.name.match(/^aws/)) return false;
376379

377-
// skip unsupported tasks on windows
378-
if (os.match(/^windows/) && task.tags.filter(tag => WINDOWS_SKIP_TAGS.has(tag)).length) {
379-
return false;
380-
}
380+
// skip unsupported tasks on windows
381+
if (os.match(/^windows/) && task.tags.filter(tag => WINDOWS_SKIP_TAGS.has(tag)).length) {
382+
return false;
383+
}
381384

382-
const tasksWithVars = task.commands.filter(task => !!task.vars);
383-
if (!tasksWithVars.length) {
384-
return true;
385-
}
385+
const tasksWithVars = task.commands.filter(task => !!task.vars);
386+
if (!tasksWithVars.length) {
387+
return true;
388+
}
386389

387-
// kerberos tests don't require mongo orchestration
388-
if (task.tags.filter(tag => tag === 'kerberos').length) {
389-
return true;
390-
}
390+
// kerberos tests don't require mongo orchestration
391+
if (task.tags.filter(tag => tag === 'kerberos').length) {
392+
return true;
393+
}
391394

392-
const { VERSION } = tasksWithVars[0].vars || {};
393-
if (VERSION === 'latest') {
394-
return semver.satisfies(semver.coerce(LATEST_EFFECTIVE_VERSION), mongoVersion);
395-
}
395+
const { VERSION } = tasksWithVars[0].vars || {};
396+
if (VERSION === 'latest') {
397+
return semver.satisfies(semver.coerce(LATEST_EFFECTIVE_VERSION), mongoVersion);
398+
}
396399

397-
return semver.satisfies(semver.coerce(VERSION), mongoVersion);
398-
}).map(x => x.name);
400+
return semver.satisfies(semver.coerce(VERSION), mongoVersion);
401+
})
402+
.map(x => x.name);
399403

400404
memo[key] = ret;
401405
return ret;
@@ -448,38 +452,48 @@ SINGLETON_TASKS.push({
448452
]
449453
});
450454

451-
SINGLETON_TASKS.push({
452-
name: 'run-custom-csfle-tests',
453-
tags: ['run-custom-csfle-tests'],
455+
const oneOffFuncs = [
456+
{ func: 'run custom csfle tests', vars: { UNIFIED: 1, NODE_LTS_NAME: 'erbium' } },
457+
{ func: 'run custom snappy tests', vars: { UNIFIED: 1, NODE_LTS_NAME: 'erbium' } }
458+
];
459+
460+
const oneOffFuncAsTasks = oneOffFuncs.map(oneOffFunc => ({
461+
name: `${oneOffFunc.func.split(' ').join('-')}`,
462+
tags: ['run-custom-dependency-tests'],
454463
commands: [
455464
{
456465
func: 'install dependencies',
457466
vars: {
458-
NODE_LTS_NAME: 'erbium',
459-
},
467+
NODE_LTS_NAME: 'erbium'
468+
}
460469
},
461470
{
462471
func: 'bootstrap mongo-orchestration',
463472
vars: {
464-
VERSION: '4.4',
473+
VERSION: '5.0',
465474
TOPOLOGY: 'server'
466475
}
467476
},
468-
{ func: 'run custom csfle tests' }
477+
oneOffFunc
469478
]
470-
});
479+
}));
471480

472-
BUILD_VARIANTS.push({
473-
name: 'lint',
474-
display_name: 'lint',
475-
run_on: 'rhel70',
476-
tasks: ['run-checks']
477-
}, {
478-
name: 'ubuntu1804-custom-csfle-tests',
479-
display_name: 'Custom FLE Version Test',
480-
run_on: 'ubuntu1804-test',
481-
tasks: ['run-custom-csfle-tests']
482-
});
481+
SINGLETON_TASKS.push(...oneOffFuncAsTasks);
482+
483+
BUILD_VARIANTS.push(
484+
{
485+
name: 'lint',
486+
display_name: 'lint',
487+
run_on: 'rhel70',
488+
tasks: ['run-checks']
489+
},
490+
{
491+
name: 'ubuntu1804-custom-dependency-tests',
492+
display_name: 'Custom Dependency Version Test',
493+
run_on: 'ubuntu1804-large',
494+
tasks: oneOffFuncAsTasks.map(({ name }) => name)
495+
}
496+
);
483497

484498
// special case for MONGODB-AWS authentication
485499
BUILD_VARIANTS.push({
@@ -493,7 +507,7 @@ BUILD_VARIANTS.push({
493507
});
494508

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

499513
fs.writeFileSync(`${__dirname}/config.yml`, yaml.safeDump(fileData, { lineWidth: 120 }), 'utf8');

.evergreen/init-nvm.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#! /usr/bin/env bash
2+
3+
export PATH="/opt/mongodbtoolchain/v2/bin:$PATH"
4+
NODE_ARTIFACTS_PATH="${PROJECT_DIRECTORY}/node-artifacts"
5+
export NVM_DIR="${NODE_ARTIFACTS_PATH}/nvm"
6+
7+
if [[ "$OS" == "Windows_NT" ]]; then
8+
NVM_HOME=$(cygpath -w "$NVM_DIR")
9+
export NVM_HOME
10+
NVM_SYMLINK=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
11+
export NVM_SYMLINK
12+
NVM_ARTIFACTS_PATH=$(cygpath -w "$NODE_ARTIFACTS_PATH/bin")
13+
export NVM_ARTIFACTS_PATH
14+
PATH=$(cygpath $NVM_SYMLINK):$(cygpath $NVM_HOME):$PATH
15+
export PATH
16+
echo "updated path on windows PATH=$PATH"
17+
else
18+
[ -s "$NVM_DIR/nvm.sh" ] && source "$NVM_DIR/nvm.sh"
19+
fi

.evergreen/run-snappy-version-test.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#! /usr/bin/env bash
2+
3+
source "${PROJECT_DIRECTORY}/.evergreen/init-nvm.sh"
4+
export MONGODB_URI="${MONGODB_URI}"
5+
6+
npm i --no-save snappy@6
7+
8+
npx mocha test/unit/snappy.test.js
9+
10+
npm i --no-save snappy@7
11+
12+
npx mocha test/unit/snappy.test.js

HISTORY.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,22 @@
22

33
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.
44

5+
### [3.6.12](https://github.com/mongodb/node-mongodb-native/compare/v3.6.11...v3.6.12) (2021-08-30)
6+
7+
8+
### Bug Fixes
9+
10+
* **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))
11+
* **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))
12+
13+
### [3.6.11](https://github.com/mongodb/node-mongodb-native/compare/v3.6.10...v3.6.11) (2021-08-05)
14+
15+
16+
### Bug Fixes
17+
18+
* **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))
19+
* **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))
20+
521
### [3.6.10](https://github.com/mongodb/node-mongodb-native/compare/v3.6.9...v3.6.10) (2021-07-06)
622

723

lib/bulk/common.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,8 +1176,11 @@ class BulkOperationBase {
11761176
* @param {function} callback
11771177
*/
11781178
bulkExecute(_writeConcern, options, callback) {
1179-
if (typeof options === 'function') (callback = options), (options = {});
1180-
options = options || {};
1179+
if (typeof options === 'function') {
1180+
callback = options;
1181+
}
1182+
1183+
const finalOptions = Object.assign({}, this.s.options, options);
11811184

11821185
if (typeof _writeConcern === 'function') {
11831186
callback = _writeConcern;
@@ -1203,7 +1206,7 @@ class BulkOperationBase {
12031206
const emptyBatchError = toError('Invalid Operation, no operations specified');
12041207
return this._handleEarlyError(emptyBatchError, callback);
12051208
}
1206-
return { options, callback };
1209+
return { options: finalOptions, callback };
12071210
}
12081211

12091212
/**

lib/core/auth/mongo_credentials.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ class MongoCredentials {
5858
this.password = process.env.AWS_SECRET_ACCESS_KEY;
5959
}
6060

61-
if (!this.mechanismProperties.AWS_SESSION_TOKEN && process.env.AWS_SESSION_TOKEN) {
61+
if (
62+
this.mechanismProperties.AWS_SESSION_TOKEN == null &&
63+
process.env.AWS_SESSION_TOKEN != null
64+
) {
6265
this.mechanismProperties.AWS_SESSION_TOKEN = process.env.AWS_SESSION_TOKEN;
6366
}
6467
}

lib/core/auth/mongodb_aws.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ const url = require('url');
99

1010
let aws4;
1111
try {
12+
// Ensure you always wrap an optional require in the try block NODE-3199
1213
aws4 = require('aws4');
1314
} catch (e) {
1415
// don't do anything;
@@ -50,12 +51,21 @@ class MongoDBAWS extends AuthProvider {
5051
return;
5152
}
5253

53-
const username = credentials.username;
54-
const password = credentials.password;
5554
const db = credentials.source;
56-
const token = credentials.mechanismProperties.AWS_SESSION_TOKEN;
5755
const bson = this.bson;
5856

57+
const accessKeyId = credentials.username;
58+
const secretAccessKey = credentials.password;
59+
const sessionToken = credentials.mechanismProperties.AWS_SESSION_TOKEN;
60+
61+
// If all three defined, include sessionToken, else include username and pass, else no credentials
62+
const awsCredentials =
63+
accessKeyId && secretAccessKey && sessionToken
64+
? { accessKeyId, secretAccessKey, sessionToken }
65+
: accessKeyId && secretAccessKey
66+
? { accessKeyId, secretAccessKey }
67+
: undefined;
68+
5969
crypto.randomBytes(32, (err, nonce) => {
6070
if (err) {
6171
callback(err);
@@ -108,18 +118,14 @@ class MongoDBAWS extends AuthProvider {
108118
path: '/',
109119
body
110120
},
111-
{
112-
accessKeyId: username,
113-
secretAccessKey: password,
114-
token
115-
}
121+
awsCredentials
116122
);
117123

118124
const authorization = options.headers.Authorization;
119125
const date = options.headers['X-Amz-Date'];
120126
const payload = { a: authorization, d: date };
121-
if (token) {
122-
payload.t = token;
127+
if (sessionToken) {
128+
payload.t = sessionToken;
123129
}
124130

125131
const saslContinue = {
@@ -163,6 +169,7 @@ function makeTempCredentials(credentials, callback) {
163169
if (process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI) {
164170
request(
165171
`${AWS_RELATIVE_URI}${process.env.AWS_CONTAINER_CREDENTIALS_RELATIVE_URI}`,
172+
undefined,
166173
(err, res) => {
167174
if (err) return callback(err);
168175
done(res);
@@ -214,11 +221,6 @@ function deriveRegion(host) {
214221
}
215222

216223
function request(uri, options, callback) {
217-
if (typeof options === 'function') {
218-
callback = options;
219-
options = {};
220-
}
221-
222224
options = Object.assign(
223225
{
224226
method: 'GET',

lib/core/auth/scram.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const Binary = BSON.Binary;
1111

1212
let saslprep;
1313
try {
14+
// Ensure you always wrap an optional require in the try block NODE-3199
1415
saslprep = require('saslprep');
1516
} catch (e) {
1617
// don't do anything;

0 commit comments

Comments
 (0)