diff options
author | Jenny Peshansky <jenny.peshansky@mongodb.com> | 2020-07-20 19:29:21 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-07-24 22:41:10 +0000 |
commit | 32b754043dd3af1e45e9931b231fb4d98f1730b5 (patch) | |
tree | e865080373834d76271ba6634896a3d801b7d7c4 /jstests/core | |
parent | 1b2f353628afab659a4d03878954daea40aeb509 (diff) | |
download | mongo-32b754043dd3af1e45e9931b231fb4d98f1730b5.tar.gz |
SERVER-49212 Verify that generated validation errors are logged when a collection validator's validationAction is set to 'warn'
Diffstat (limited to 'jstests/core')
-rw-r--r-- | jstests/core/doc_validation_options.js | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/jstests/core/doc_validation_options.js b/jstests/core/doc_validation_options.js index 50d8edfa671..1c10a1577b1 100644 --- a/jstests/core/doc_validation_options.js +++ b/jstests/core/doc_validation_options.js @@ -4,6 +4,8 @@ (function() { "use strict"; +load("jstests/aggregation/extras/utils.js"); // for documentEq +load("jstests/libs/fixture_helpers.js"); // for getPrimaryForNodeHostingDatabase function assertFailsValidation(res) { var DocumentValidationFailure = 121; @@ -29,7 +31,23 @@ assert.commandWorked(t.runCommand("collMod", {validationAction: "warn"})); t.update({}, {$set: {a: 2}}); assert.eq(1, t.find({a: 2}).itcount()); -// TODO: check log for message? +// check log for message +// use getPrimaryForNodeHostingDatabase to return a connection to the db or the primary node +// if the db is sharded, so we can specifically search logs of the node which owns the +// document that generated the warning. +const conn = FixtureHelpers.getPrimaryForNodeHostingDatabase(db); +const logId = 20294; +const errInfo = { + "operatorName": "$eq", + "specifiedAs": {a: 1}, + "reason": "comparison failed", + "consideredValue": 2 +}; +checkLog.containsJson(conn, logId, { + "errInfo": function(obj) { + return documentEq(obj, errInfo); + } +}); // make sure persisted var info = db.getCollectionInfos({name: t.getName()})[0]; |