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:
parent
4a19bd9424
commit
7486388e02
@ -10,6 +10,10 @@ executor:
|
||||
readMode: commands
|
||||
hooks:
|
||||
- class: ValidateCollections
|
||||
shell_options:
|
||||
global_vars:
|
||||
TestData:
|
||||
skipValidationOnInvalidViewDefinitions: true
|
||||
fixture:
|
||||
class: MongoDFixture
|
||||
mongod_options:
|
||||
|
@ -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:
|
||||
|
@ -10,6 +10,10 @@ executor:
|
||||
readMode: commands
|
||||
hooks:
|
||||
- class: ValidateCollections
|
||||
shell_options:
|
||||
global_vars:
|
||||
TestData:
|
||||
skipValidationOnInvalidViewDefinitions: true
|
||||
fixture:
|
||||
class: ShardedClusterFixture
|
||||
mongos_options:
|
||||
|
@ -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):
|
||||
|
@ -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) {
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user