summaryrefslogtreecommitdiff
path: root/jstests/disk
diff options
context:
space:
mode:
authorRichard Hausman <richard.hausman@mongodb.com>2022-08-20 01:10:31 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-20 01:45:22 +0000
commit3f777924c271f91fdc9a878a2e70cc4f068d9014 (patch)
treed59fa770192347fb01073b057780bda7b1b4390d /jstests/disk
parenta96f1436e02feea955565ac0ea39f8b56f087639 (diff)
downloadmongo-3f777924c271f91fdc9a878a2e70cc4f068d9014.tar.gz
SERVER-67521 Check for duplicate field names in BSON documents during validation
Diffstat (limited to 'jstests/disk')
-rw-r--r--jstests/disk/validate_bson_inconsistency.js11
1 files changed, 11 insertions, 0 deletions
diff --git a/jstests/disk/validate_bson_inconsistency.js b/jstests/disk/validate_bson_inconsistency.js
index e2d7675da90..91e406f6f25 100644
--- a/jstests/disk/validate_bson_inconsistency.js
+++ b/jstests/disk/validate_bson_inconsistency.js
@@ -31,9 +31,20 @@ resetDbpath(dbpath);
mongod = startMongodOnExistingPath(dbpath);
db = mongod.getDB(baseName);
testColl = db[collName];
+ testColl.insert({a: 1, b: 2, c: {b: 3}, d: {a: [2, 3, 4], b: {a: 2}}});
+ testColl.insert({a: 1, b: 1});
+ // Warnings should be triggered iff checkBSONConsistency is set to true.
let res = assert.commandWorked(testColl.validate());
assert(res.valid, tojson(res));
+ assert.eq(res.nNonCompliantDocuments, 0);
+ assert.eq(res.warnings.length, 0);
+
+ res = assert.commandWorked(testColl.validate({checkBSONConsistency: true}));
+ assert(res.valid, tojson(res));
+ assert.eq(res.nNonCompliantDocuments, numDocs);
+ assert.eq(res.warnings.length, 1);
+
MongoRunner.stopMongod(mongod, null, {skipValidation: true});
})();