summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2018-01-30 12:40:42 -0500
committerJonathan Abrahams <jonathan@mongodb.com>2018-01-30 12:40:42 -0500
commite6783ca2cac1e5d16b822e1508a1c025cdbded81 (patch)
treed89c6e45923d36e1c57a606f17e5cf5c939af93e
parent4ba65b234fa3a4027f8615468e632adbab52edf0 (diff)
downloadmongo-e6783ca2cac1e5d16b822e1508a1c025cdbded81.tar.gz
SERVER-32243 Add an option to have the validate hook skip some collections
-rw-r--r--jstests/hooks/validate_collections.js15
-rw-r--r--src/mongo/shell/utils.js3
2 files changed, 17 insertions, 1 deletions
diff --git a/jstests/hooks/validate_collections.js b/jstests/hooks/validate_collections.js
index aeb38a98bf5..e64bb39d305 100644
--- a/jstests/hooks/validate_collections.js
+++ b/jstests/hooks/validate_collections.js
@@ -71,6 +71,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 ccafe13418f..148eacc1c89 100644
--- a/src/mongo/shell/utils.js
+++ b/src/mongo/shell/utils.js
@@ -242,7 +242,8 @@ jsTestOptions = function() {
networkMessageCompressors: TestData.networkMessageCompressors,
skipValidationOnInvalidViewDefinitions: TestData.skipValidationOnInvalidViewDefinitions,
forceValidationWithFeatureCompatibilityVersion:
- TestData.forceValidationWithFeatureCompatibilityVersion
+ TestData.forceValidationWithFeatureCompatibilityVersion,
+ skipValidationNamespaces: TestData.skipValidationNamespaces || [],
});
}
return _jsTestOptions;