diff options
author | James Wahlin <james@mongodb.com> | 2019-05-01 08:50:27 -0400 |
---|---|---|
committer | James Wahlin <james@mongodb.com> | 2019-05-02 12:42:15 -0400 |
commit | d812878c2da9138b31743aab2e5ca813fc6e3f19 (patch) | |
tree | 8de16412b4e04e6e17cd3381f0dd0395d0fb9c52 /jstests | |
parent | 73403440366f6b9efb1c262edf319c7c97a67059 (diff) | |
download | mongo-d812878c2da9138b31743aab2e5ca813fc6e3f19.tar.gz |
SERVER-40400 Test support for 'bypassDocumentValidation' option in combination with a pipeline-style update
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/core/bypass_doc_validation.js | 22 | ||||
-rw-r--r-- | jstests/core/update_with_pipeline.js | 9 |
2 files changed, 21 insertions, 10 deletions
diff --git a/jstests/core/bypass_doc_validation.js b/jstests/core/bypass_doc_validation.js index b3290ef4e04..7017f9541cb 100644 --- a/jstests/core/bypass_doc_validation.js +++ b/jstests/core/bypass_doc_validation.js @@ -1,4 +1,6 @@ -// @tags: [does_not_support_stepdowns, requires_non_retryable_commands, requires_fastcount] +// TODO SERVER-40402: Remove 'assumes_write_concern_unchanged' tag. +// @tags: [does_not_support_stepdowns, requires_non_retryable_commands, requires_fastcount, +// assumes_write_concern_unchanged] /** * Tests that various database commands respect the 'bypassDocumentValidation' flag: @@ -144,6 +146,24 @@ }); assert.writeOK(res); assert.eq(1, coll.count({update: 1})); + + // We restrict testing pipeline-style update to commands as they are not supported for + // OP_UPDATE which cannot differentiate between an update object and an array. + if (myDb.getMongo().writeMode() === "commands") { + res = myDb.runCommand({ + update: collName, + updates: [{q: {}, u: [{$addFields: {pipeline: 1}}]}], + bypassDocumentValidation: false + }); + assertFailsValidation(BulkWriteResult(res)); + assert.eq(0, coll.count({pipeline: 1})); + res = assert.commandWorked(myDb.runCommand({ + update: collName, + updates: [{q: {}, u: [{$addFields: {pipeline: 1}}]}], + bypassDocumentValidation: true + })); + assert.eq(1, coll.count({pipeline: 1})); + } } // Run the test using a normal validator. diff --git a/jstests/core/update_with_pipeline.js b/jstests/core/update_with_pipeline.js index caac0ff9994..9bacb8de4f5 100644 --- a/jstests/core/update_with_pipeline.js +++ b/jstests/core/update_with_pipeline.js @@ -132,15 +132,6 @@ coll.update({_id: 1}, [{$addFields: {x: 1}}], {arrayFilters: [{x: {$eq: 1}}]}), ErrorCodes.FailedToParse); - // The 'bypassDocumentValidation' option is not yet supported for pipeline updates. - // TODO SERVER-40400: Remove once bypassDocumentValidation is supported and tested. - assert.commandFailedWithCode(db.runCommand({ - update: collName, - updates: [{q: {_id: 1}, u: [{$addFields: {x: 1}}]}], - bypassDocumentValidation: true - }), - ErrorCodes.NotImplemented); - // The 'writeConcern' option is not yet supported for pipeline updates. // TODO SERVER-40402: Remove once writeConcern is supported and tested. assert.commandFailedWithCode(db.runCommand({ |