diff options
author | Damian Wasilewicz <damian.wasilewicz@mongodb.com> | 2022-08-16 19:48:10 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-08-16 21:41:00 +0000 |
commit | 5e77e5fbd3871c65ee20ade0a0cf1410c6b47a9c (patch) | |
tree | e9561e2242e58b7d590615aa49dabedc3ee610b2 /jstests/disk/validate_bson_inconsistency.js | |
parent | 0c0f80372c2adee56c16c106ec2711d39ea6b45f (diff) | |
download | mongo-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.js | 30 |
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}); +})(); })(); |