diff --git a/buildscripts/resmokeconfig/suites/jstestfuzz.yml b/buildscripts/resmokeconfig/suites/jstestfuzz.yml index 3efd7408370..b72166abaaa 100644 --- a/buildscripts/resmokeconfig/suites/jstestfuzz.yml +++ b/buildscripts/resmokeconfig/suites/jstestfuzz.yml @@ -10,6 +10,10 @@ executor: readMode: commands hooks: - class: ValidateCollections + shell_options: + global_vars: + TestData: + skipValidationOnInvalidViewDefinitions: true fixture: class: MongoDFixture mongod_options: diff --git a/buildscripts/resmokeconfig/suites/jstestfuzz_replication.yml b/buildscripts/resmokeconfig/suites/jstestfuzz_replication.yml index 6027a2cb2bc..49d86ebe68f 100644 --- a/buildscripts/resmokeconfig/suites/jstestfuzz_replication.yml +++ b/buildscripts/resmokeconfig/suites/jstestfuzz_replication.yml @@ -10,7 +10,15 @@ executor: readMode: commands hooks: - class: ValidateCollections + shell_options: + global_vars: + TestData: + skipValidationOnInvalidViewDefinitions: true - class: CheckReplDBHash + shell_options: + global_vars: + TestData: + skipValidationOnInvalidViewDefinitions: true fixture: class: ReplicaSetFixture mongod_options: diff --git a/buildscripts/resmokeconfig/suites/jstestfuzz_sharded.yml b/buildscripts/resmokeconfig/suites/jstestfuzz_sharded.yml index e6fc2d56d4a..f8d56c68a95 100644 --- a/buildscripts/resmokeconfig/suites/jstestfuzz_sharded.yml +++ b/buildscripts/resmokeconfig/suites/jstestfuzz_sharded.yml @@ -10,6 +10,10 @@ executor: readMode: commands hooks: - class: ValidateCollections + shell_options: + global_vars: + TestData: + skipValidationOnInvalidViewDefinitions: true fixture: class: ShardedClusterFixture mongos_options: diff --git a/buildscripts/resmokelib/testing/hooks.py b/buildscripts/resmokelib/testing/hooks.py index e610a9e95c0..fb4faf99d7f 100644 --- a/buildscripts/resmokelib/testing/hooks.py +++ b/buildscripts/resmokelib/testing/hooks.py @@ -218,10 +218,15 @@ class ValidateCollections(JsCustomBehavior): Runs full validation on all collections in all databases on every stand-alone node, primary replica-set node, or primary shard node. """ - def __init__(self, logger, fixture): + def __init__(self, logger, fixture, shell_options=None): description = "Full collection validation" js_filename = os.path.join("jstests", "hooks", "run_validate_collections.js") - JsCustomBehavior.__init__(self, logger, fixture, js_filename, description) + JsCustomBehavior.__init__(self, + logger, + fixture, + js_filename, + description, + shell_options=shell_options) class CheckReplDBHash(JsCustomBehavior): @@ -229,10 +234,15 @@ class CheckReplDBHash(JsCustomBehavior): Checks that the dbhashes of all non-local databases and non-replicated system collections match on the primary and secondaries. """ - def __init__(self, logger, fixture): + def __init__(self, logger, fixture, shell_options=None): description = "Check dbhashes of all replica set or master/slave members" js_filename = os.path.join("jstests", "hooks", "run_check_repl_dbhash.js") - JsCustomBehavior.__init__(self, logger, fixture, js_filename, description) + JsCustomBehavior.__init__(self, + logger, + fixture, + js_filename, + description, + shell_options=shell_options) class TypeSensitiveSON(bson.SON): diff --git a/jstests/hooks/validate_collections.js b/jstests/hooks/validate_collections.js index 946a0663894..eac734b4d61 100644 --- a/jstests/hooks/validate_collections.js +++ b/jstests/hooks/validate_collections.js @@ -23,7 +23,13 @@ function validateCollections(db, obj) { // Don't run validate on view namespaces. let listCollectionsRes = db.runCommand({listCollections: 1, filter: {"type": "collection"}}); + if (jsTest.options().skipValidationOnInvalidViewDefinitions && listCollectionsRes.ok === 0) { + assert.commandFailedWithCode(listCollectionsRes, ErrorCodes.InvalidViewDefinition); + print('Skipping validate hook because of invalid views in system.views'); + return true; + } assert.commandWorked(listCollectionsRes); + let collInfo = new DBCommandCursor(db.getMongo(), listCollectionsRes).toArray(); for (var collDocument of collInfo) { diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index 117f2974cd0..d429b15fad8 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -974,7 +974,18 @@ var ReplSetTest = function(opts) { var primaryDBHash = dbHashes.master; assert.commandWorked(primaryDBHash); - var primaryCollInfo = primary.getDB(dbName).getCollectionInfos(); + try { + var primaryCollInfo = primary.getDB(dbName).getCollectionInfos(); + } catch (e) { + if (jsTest.options().skipValidationOnInvalidViewDefinitions) { + assert.commandFailedWithCode(e, ErrorCodes.InvalidViewDefinition); + print('Skipping dbhash check on ' + dbName + + ' because of invalid views in system.views'); + continue; + } else { + throw e; + } + } dbHashes.slaves.forEach(secondaryDBHash => { assert.commandWorked(secondaryDBHash); diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js index 1cf2cd1bef7..ae63f0fc7f3 100644 --- a/src/mongo/shell/utils.js +++ b/src/mongo/shell/utils.js @@ -195,7 +195,8 @@ jsTestOptions = function() { // Note: does not support the array version mongosBinVersion: TestData.mongosBinVersion || "", shardMixedBinVersions: TestData.shardMixedBinVersions || false, - networkMessageCompressors: TestData.networkMessageCompressors + networkMessageCompressors: TestData.networkMessageCompressors, + skipValidationOnInvalidViewDefinitions: TestData.skipValidationOnInvalidViewDefinitions }); } return _jsTestOptions;