0
0
mirror of https://github.com/mongodb/mongo.git synced 2024-11-24 08:30:56 +01:00

SERVER-25768 skip hooks in fuzzer suites when invalid views present

Skips the validate and dbhash hooks for jstestfuzz* suites when listCollections
fails with an InvalidViewDefinition error.
This commit is contained in:
Kyle Suarez 2016-08-24 14:48:20 -04:00
parent 4a19bd9424
commit 7486388e02
7 changed files with 50 additions and 6 deletions

View File

@ -10,6 +10,10 @@ executor:
readMode: commands
hooks:
- class: ValidateCollections
shell_options:
global_vars:
TestData:
skipValidationOnInvalidViewDefinitions: true
fixture:
class: MongoDFixture
mongod_options:

View File

@ -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:

View File

@ -10,6 +10,10 @@ executor:
readMode: commands
hooks:
- class: ValidateCollections
shell_options:
global_vars:
TestData:
skipValidationOnInvalidViewDefinitions: true
fixture:
class: ShardedClusterFixture
mongos_options:

View File

@ -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):

View File

@ -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) {

View File

@ -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);

View File

@ -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;