From a50d74362e8a4afc96442da33966d87da8de3f18 Mon Sep 17 00:00:00 2001 From: emadum Date: Sat, 28 Nov 2020 20:11:04 -0500 Subject: [PATCH 1/8] chore(ci): xunit integration --- .evergreen/config.yml | 5 +++++ .evergreen/config.yml.in | 6 ++++++ .gitignore | 3 +++ package-lock.json | 6 ++++++ package.json | 1 + test/mocha.opts | 2 +- 6 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 218b0ef23ad..2745390216b 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -198,12 +198,17 @@ functions: NODE_LTS_NAME=${NODE_LTS_NAME} DRIVERS_TOOLS="${DRIVERS_TOOLS}" \ SSL_CA_FILE="${SSL_CA_FILE}" SSL_KEY_FILE="${SSL_KEY_FILE}" \ MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-tls-tests.sh + upload test results: + - command: attach.xunit_results + params: + file: src/xunit.xml pre: - func: fetch source - func: prepare resources - func: fix absolute paths - func: make files executable post: + - func: upload test results - func: cleanup tasks: - name: test-latest-server diff --git a/.evergreen/config.yml.in b/.evergreen/config.yml.in index 55c0ff5168e..7dce20bec02 100644 --- a/.evergreen/config.yml.in +++ b/.evergreen/config.yml.in @@ -240,6 +240,11 @@ functions: SSL_CA_FILE="${SSL_CA_FILE}" SSL_KEY_FILE="${SSL_KEY_FILE}" \ MONGODB_URI="${MONGODB_URI}" bash ${PROJECT_DIRECTORY}/.evergreen/run-tls-tests.sh + "upload test results": + - command: attach.xunit_results + params: + file: src/xunit.xml + pre: - func: "fetch source" - func: "prepare resources" @@ -248,4 +253,5 @@ pre: - func: "make files executable" post: + - func: "upload test results" - func: "cleanup" diff --git a/.gitignore b/.gitignore index 836bde681d4..171be28330f 100644 --- a/.gitignore +++ b/.gitignore @@ -29,6 +29,9 @@ manual_tests/ docs/build docs/Makefile +# xunit test output for CI +xunit.xml + # Directory for dbs db diff --git a/package-lock.json b/package-lock.json index ea245898e45..27589a8bf5e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3643,6 +3643,12 @@ "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", "dev": true }, + "spec-xunit-file": { + "version": "0.0.1-3", + "resolved": "https://registry.npmjs.org/spec-xunit-file/-/spec-xunit-file-0.0.1-3.tgz", + "integrity": "sha1-hVpmq4w4LrMWXfkoqB0HSQKdI4Y=", + "dev": true + }, "split": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz", diff --git a/package.json b/package.json index 7708d3edc87..8d7e20d1bb2 100644 --- a/package.json +++ b/package.json @@ -50,6 +50,7 @@ "sinon": "^4.3.0", "sinon-chai": "^3.2.0", "snappy": "^6.3.4", + "spec-xunit-file": "0.0.1-3", "standard-version": "^4.4.0", "util.promisify": "^1.0.1", "worker-farm": "^1.5.0", diff --git a/test/mocha.opts b/test/mocha.opts index 6f8c2b39090..cf335621394 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -2,4 +2,4 @@ --timeout 60000 --file test/tools/runner --ui test/tools/runner/metadata_ui.js - + --reporter spec-xunit-file From 9d75badf025337badb4d105d4493c3e8974876f7 Mon Sep 17 00:00:00 2001 From: emadum Date: Sat, 28 Nov 2020 21:25:49 -0500 Subject: [PATCH 2/8] test: restrict geoSearch tests to mongodb <= 4.4 (#2612) --- test/functional/operation_example.test.js | 2 +- test/functional/operation_generators_example.test.js | 2 +- test/functional/operation_promises_example.test.js | 2 +- test/functional/readconcern.test.js | 7 +++++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/test/functional/operation_example.test.js b/test/functional/operation_example.test.js index 86d85fa4f75..e874267a847 100644 --- a/test/functional/operation_example.test.js +++ b/test/functional/operation_example.test.js @@ -1754,7 +1754,7 @@ describe('Operation Examples', function() { * @ignore */ it('shouldCorrectlyPerformSimpleGeoHaystackSearchCommand', { - metadata: { requires: { topology: ['single', 'replicaset'] } }, + metadata: { requires: { mongodb: '<=4.4', topology: ['single', 'replicaset'] } }, // The actual test we wish to run test: function(done) { diff --git a/test/functional/operation_generators_example.test.js b/test/functional/operation_generators_example.test.js index 2b4fbf8aae5..3b3fbad5014 100644 --- a/test/functional/operation_generators_example.test.js +++ b/test/functional/operation_generators_example.test.js @@ -1093,7 +1093,7 @@ describe('Operation (Generators)', function() { * @ignore */ it('shouldCorrectlyPerformSimpleGeoHaystackSearchCommandWithGenerators', { - metadata: { requires: { generators: true, topology: ['single'] } }, + metadata: { requires: { mongodb: '<=4.4', generators: true, topology: ['single'] } }, // The actual test we wish to run test: function() { diff --git a/test/functional/operation_promises_example.test.js b/test/functional/operation_promises_example.test.js index 3b8b747d95a..25ecd8b7c0e 100644 --- a/test/functional/operation_promises_example.test.js +++ b/test/functional/operation_promises_example.test.js @@ -1120,7 +1120,7 @@ describe('Operation (Promises)', function() { * @ignore */ it('shouldCorrectlyPerformSimpleGeoHaystackSearchCommandWithPromises', { - metadata: { requires: { topology: ['single', 'replicaset'] } }, + metadata: { requires: { mongodb: '<=4.4', topology: ['single', 'replicaset'] } }, // The actual test we wish to run test: function() { diff --git a/test/functional/readconcern.test.js b/test/functional/readconcern.test.js index 75e38898447..abdcf40d439 100644 --- a/test/functional/readconcern.test.js +++ b/test/functional/readconcern.test.js @@ -59,9 +59,12 @@ describe('ReadConcern', function() { ]; tests.forEach(test => { + const metadata = { requires: { topology: 'replicaset', mongodb: '>= 3.2' } }; + if (test.commandName === 'geoSearch') { + metadata.requires.mongodb += ' <=4.4'; + } it(test.description, { - metadata: { requires: { topology: 'replicaset', mongodb: '>= 3.2' } }, - + metadata, test: function(done) { const started = []; const succeeded = []; From 7f7bfb5ed27ff2438897243804516a43f2b27720 Mon Sep 17 00:00:00 2001 From: emadum Date: Sun, 29 Nov 2020 10:32:11 -0500 Subject: [PATCH 3/8] chore(ci): add color to evergreen mocha logs --- test/mocha.opts | 1 + 1 file changed, 1 insertion(+) diff --git a/test/mocha.opts b/test/mocha.opts index cf335621394..7f44530476a 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -3,3 +3,4 @@ --file test/tools/runner --ui test/tools/runner/metadata_ui.js --reporter spec-xunit-file + --color From 3fe87aa4170a5d6a76be0374c48a923817af9a72 Mon Sep 17 00:00:00 2001 From: emadum Date: Sun, 29 Nov 2020 10:32:38 -0500 Subject: [PATCH 4/8] fix: add commandSupportsCollation check to CommandOperationV2 --- lib/operations/command_v2.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/operations/command_v2.js b/lib/operations/command_v2.js index 3c4af7f438a..76daac5ca39 100644 --- a/lib/operations/command_v2.js +++ b/lib/operations/command_v2.js @@ -64,7 +64,11 @@ class CommandOperationV2 extends OperationBase { Object.assign(cmd, { writeConcern: this.writeConcern }); } - if (options.collation && typeof options.collation === 'object') { + if ( + options.collation && + typeof options.collation === 'object' && + commandSupportsCollation(cmd) + ) { Object.assign(cmd, { collation: options.collation }); } } @@ -105,4 +109,9 @@ function resolveReadConcern(parent, options) { return ReadConcern.fromOptions(options) || (parent && parent.readConcern); } +function commandSupportsCollation(command) { + if (command.listCollections) return false; + return true; +} + module.exports = CommandOperationV2; From 8abe1e8fd3d2e0cb9309785335d845ecc179b7ff Mon Sep 17 00:00:00 2001 From: emadum Date: Sun, 29 Nov 2020 11:03:24 -0500 Subject: [PATCH 5/8] chore(ci): ignore .md files --- .evergreen/config.yml | 2 ++ .evergreen/config.yml.in | 3 +++ 2 files changed, 5 insertions(+) diff --git a/.evergreen/config.yml b/.evergreen/config.yml index 2745390216b..7b5be37305f 100644 --- a/.evergreen/config.yml +++ b/.evergreen/config.yml @@ -210,6 +210,8 @@ pre: post: - func: upload test results - func: cleanup +ignore: + - '*.md' tasks: - name: test-latest-server tags: diff --git a/.evergreen/config.yml.in b/.evergreen/config.yml.in index 7dce20bec02..b85188c01a5 100644 --- a/.evergreen/config.yml.in +++ b/.evergreen/config.yml.in @@ -255,3 +255,6 @@ pre: post: - func: "upload test results" - func: "cleanup" + +ignore: + - '*.md' From 61d1bfd5019434f5e86235cb433d66bfce524704 Mon Sep 17 00:00:00 2001 From: emadum Date: Sun, 29 Nov 2020 11:04:04 -0500 Subject: [PATCH 6/8] docs: update api docs link to 3.5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 00d31d8e642..855a2dc8321 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ The official [MongoDB](https://www.mongodb.com/) driver for Node.js. Provides a | what | where | |---------------|------------------------------------------------| | documentation | http://mongodb.github.io/node-mongodb-native | -| api-doc | http://mongodb.github.io/node-mongodb-native/3.1/api | +| api-doc | http://mongodb.github.io/node-mongodb-native/3.5/api | | source | https://github.com/mongodb/node-mongodb-native | | mongodb | http://www.mongodb.org | From 8165fd78da08b111af3cd519dcd60957233c812b Mon Sep 17 00:00:00 2001 From: emadum Date: Mon, 30 Nov 2020 10:53:00 -0500 Subject: [PATCH 7/8] review feedback --- lib/operations/command_v2.js | 11 +---------- lib/operations/list_collections.js | 4 ++++ test/functional/readconcern.test.js | 10 +++++----- 3 files changed, 10 insertions(+), 15 deletions(-) diff --git a/lib/operations/command_v2.js b/lib/operations/command_v2.js index 76daac5ca39..3c4af7f438a 100644 --- a/lib/operations/command_v2.js +++ b/lib/operations/command_v2.js @@ -64,11 +64,7 @@ class CommandOperationV2 extends OperationBase { Object.assign(cmd, { writeConcern: this.writeConcern }); } - if ( - options.collation && - typeof options.collation === 'object' && - commandSupportsCollation(cmd) - ) { + if (options.collation && typeof options.collation === 'object') { Object.assign(cmd, { collation: options.collation }); } } @@ -109,9 +105,4 @@ function resolveReadConcern(parent, options) { return ReadConcern.fromOptions(options) || (parent && parent.readConcern); } -function commandSupportsCollation(command) { - if (command.listCollections) return false; - return true; -} - module.exports = CommandOperationV2; diff --git a/lib/operations/list_collections.js b/lib/operations/list_collections.js index ee01d31e85c..b389e692dd6 100644 --- a/lib/operations/list_collections.js +++ b/lib/operations/list_collections.js @@ -35,6 +35,10 @@ class ListCollectionsOperation extends CommandOperationV2 { if (typeof this.options.batchSize === 'number') { this.batchSize = this.options.batchSize; } + + if (this.options.collation) { + delete this.options.collation; + } } execute(server, callback) { diff --git a/test/functional/readconcern.test.js b/test/functional/readconcern.test.js index abdcf40d439..de745d57394 100644 --- a/test/functional/readconcern.test.js +++ b/test/functional/readconcern.test.js @@ -44,7 +44,8 @@ describe('ReadConcern', function() { { description: 'Should set majority readConcern geoSearch command', commandName: 'geoSearch', - readConcern: { level: 'majority' } + readConcern: { level: 'majority' }, + serverVersion: '>=3.2 <=4.4' }, { description: 'Should set local readConcern at collection level', @@ -59,10 +60,9 @@ describe('ReadConcern', function() { ]; tests.forEach(test => { - const metadata = { requires: { topology: 'replicaset', mongodb: '>= 3.2' } }; - if (test.commandName === 'geoSearch') { - metadata.requires.mongodb += ' <=4.4'; - } + const metadata = { + requires: { topology: 'replicaset', mongodb: test.serverVersion || '>= 3.2' } + }; it(test.description, { metadata, test: function(done) { From da2c90f12e62a82e5037dba18862052268e218f1 Mon Sep 17 00:00:00 2001 From: emadum Date: Mon, 30 Nov 2020 12:30:46 -0500 Subject: [PATCH 8/8] move collation check into command construction --- lib/operations/list_collections.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/operations/list_collections.js b/lib/operations/list_collections.js index b389e692dd6..43a8bc17f8c 100644 --- a/lib/operations/list_collections.js +++ b/lib/operations/list_collections.js @@ -35,10 +35,6 @@ class ListCollectionsOperation extends CommandOperationV2 { if (typeof this.options.batchSize === 'number') { this.batchSize = this.options.batchSize; } - - if (this.options.collation) { - delete this.options.collation; - } } execute(server, callback) { @@ -97,6 +93,10 @@ class ListCollectionsOperation extends CommandOperationV2 { nameOnly: this.nameOnly }; + if (this.options.collation) { + delete this.options.collation; + } + return super.executeCommand(server, command, callback); } }