diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2018-01-08 10:46:13 -0500 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2018-01-30 10:57:41 -0500 |
commit | 2856b480004af9f5987654420caeda209f85a2a8 (patch) | |
tree | d5d29ff7fe8a3a730942af8bbfaa5a80fd5bce10 /jstests/hooks | |
parent | 43cadf40956ddc791e7a332dc1405bb001bb05eb (diff) | |
download | mongo-2856b480004af9f5987654420caeda209f85a2a8.tar.gz |
SERVER-32243 Add an option to have the validate hook skip some collections
(cherry picked from commit 56ba266ca7eb46bfca0dc15ba0ca2290237db713)
Diffstat (limited to 'jstests/hooks')
-rw-r--r-- | jstests/hooks/validate_collections.js | 15 |
1 files changed, 15 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"]); |