summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/hooks/validate_collections.js15
-rw-r--r--src/mongo/shell/utils.js1
2 files changed, 16 insertions, 0 deletions
diff --git a/jstests/hooks/validate_collections.js b/jstests/hooks/validate_collections.js
index ac2382ae838..31e5d26affe 100644
--- a/jstests/hooks/validate_collections.js
+++ b/jstests/hooks/validate_collections.js
@@ -34,6 +34,21 @@ function validateCollections(db, obj) {
filter = {$or: [filter, {type: {$exists: false}}]};
}
+ // Optionally skip collections.
+ if (Array.isArray(jsTest.options().skipValidationNamespaces) &&
+ jsTest.options().skipValidationNamespaces.length > 0) {
+ let skippedCollections = [];
+ for (let ns of jsTest.options().skipValidationNamespaces) {
+ // Strip off the database name from 'ns' to extract the collName.
+ const collName = ns.replace(new RegExp('^' + db.getName() + '\.'), '');
+ // Skip the collection 'collName' if the db name was removed from 'ns'.
+ if (collName !== ns) {
+ skippedCollections.push({name: {$ne: collName}});
+ }
+ }
+ filter = {$and: [filter, ...skippedCollections]};
+ }
+
let collInfo = db.getCollectionInfos(filter);
for (var collDocument of collInfo) {
var coll = db.getCollection(collDocument["name"]);
diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js
index f7ec71ed8b6..c7bd0552599 100644
--- a/src/mongo/shell/utils.js
+++ b/src/mongo/shell/utils.js
@@ -254,6 +254,7 @@ jsTestOptions = function() {
TestData.hasOwnProperty("skipValidationOnNamespaceNotFound")
? TestData.skipValidationOnNamespaceNotFound
: true,
+ skipValidationNamespaces: TestData.skipValidationNamespaces || [],
skipCheckingUUIDsConsistentAcrossCluster:
TestData.skipCheckingUUIDsConsistentAcrossCluster || false,
jsonSchemaTestFile: TestData.jsonSchemaTestFile,