summaryrefslogtreecommitdiff
path: root/jstests/disk/validate_bson_inconsistency.js
diff options
context:
space:
mode:
authorDamian Wasilewicz <damian.wasilewicz@mongodb.com>2022-08-16 19:48:10 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-08-16 21:41:00 +0000
commit5e77e5fbd3871c65ee20ade0a0cf1410c6b47a9c (patch)
treee9561e2242e58b7d590615aa49dabedc3ee610b2 /jstests/disk/validate_bson_inconsistency.js
parent0c0f80372c2adee56c16c106ec2711d39ea6b45f (diff)
downloadmongo-5e77e5fbd3871c65ee20ade0a0cf1410c6b47a9c.tar.gz
SERVER-67604 Check BSON array field indexes when running the validate command
Diffstat (limited to 'jstests/disk/validate_bson_inconsistency.js')
-rw-r--r--jstests/disk/validate_bson_inconsistency.js30
1 files changed, 30 insertions, 0 deletions
diff --git a/jstests/disk/validate_bson_inconsistency.js b/jstests/disk/validate_bson_inconsistency.js
index e16faf3527f..ac68977d13a 100644
--- a/jstests/disk/validate_bson_inconsistency.js
+++ b/jstests/disk/validate_bson_inconsistency.js
@@ -178,4 +178,34 @@ resetDbpath(dbpath);
MongoRunner.stopMongod(mongod, null, {skipValidation: true});
})();
+
+(function validateDocumentsNonSequentialArrayIndexes() {
+ jsTestLog("Validate documents with array indices that are not sequential");
+
+ let mongod = startMongodOnExistingPath(dbpath);
+ let db = mongod.getDB(baseName);
+ const collName = collNamePrefix + count++;
+ db.createCollection(collName);
+ let testColl = db[collName];
+
+ let uri = getUriForColl(testColl);
+ const numDocs = 10;
+ insertNonSequentialArrayIndexes(testColl, uri, mongod, numDocs);
+
+ mongod = startMongodOnExistingPath(dbpath);
+ db = mongod.getDB(baseName);
+ testColl = db[collName];
+
+ res = assert.commandWorked(testColl.validate());
+ assert(res.valid, tojson(res));
+ assert.eq(res.nNonCompliantDocuments, 10);
+ assert.eq(res.warnings.length, 1);
+
+ res = assert.commandWorked(testColl.validate({checkBSONConsistency: true}));
+ assert(res.valid, tojson(res));
+ assert.eq(res.nNonCompliantDocuments, 10);
+ assert.eq(res.warnings.length, 1);
+
+ MongoRunner.stopMongod(mongod, null, {skipValidation: true});
+})();
})();