diff options
author | William Schultz <william.schultz@mongodb.com> | 2018-07-06 14:54:38 -0400 |
---|---|---|
committer | William Schultz <william.schultz@mongodb.com> | 2018-07-24 16:49:31 -0400 |
commit | 8d5057bbe9e75d6c1081ed63c35e330434a12268 (patch) | |
tree | 81fa7407d8bbcb7ecd7e30780641b50f9bd39b47 | |
parent | dda0b877575c4be05dcafe8d94abd1bc2a66980c (diff) | |
download | mongo-8d5057bbe9e75d6c1081ed63c35e330434a12268.tar.gz |
SERVER-32907 Make resmoke pass TestData.setParameters to mongo shell as a JavaScript object
This patch changes the format of the TestData.setParameters variable we
pass to the mongo shell from within resmoke. We now pass this value as a
JavaScript object, where keys are parameter names and values are the
values to set for that parameter. Additionally, we also consolidate the
hard-coded 'logComponentVerbosity' default settings into resmoke, instead of
having them mixed between servers.js and resmoke's programs.py. Now, any
mongod processes started either directly by resmoke or via a mongo shell
that was started by resmoke will receive default log verbosity settings
from a value defined in resmoke.
(cherry picked from commit 5b2739dbff77811dbbfbccbc8a7ca8b973c8525f)
-rw-r--r-- | buildscripts/resmokelib/core/programs.py | 29 | ||||
-rw-r--r-- | src/mongo/shell/servers.js | 44 |
2 files changed, 36 insertions, 37 deletions
diff --git a/buildscripts/resmokelib/core/programs.py b/buildscripts/resmokelib/core/programs.py index b868aa8a1ba..a5dcccb0aea 100644 --- a/buildscripts/resmokelib/core/programs.py +++ b/buildscripts/resmokelib/core/programs.py @@ -15,6 +15,10 @@ from . import process as _process from .. import config from .. import utils +# The default 'logComponentVerbosity' object for mongod processes started either directly via +# resmoke or those that will get started by the mongo shell. +DEFAULT_MONGOD_LOG_COMPONENT_VERBOSITY = {"replication": {"heartbeats": 2, "rollback": 2}} + def mongod_program(logger, executable=None, process_kwargs=None, **kwargs): """ @@ -32,11 +36,9 @@ def mongod_program(logger, executable=None, process_kwargs=None, **kwargs): if config.MONGOD_SET_PARAMETERS is not None: suite_set_parameters.update(utils.load_yaml(config.MONGOD_SET_PARAMETERS)) - # Turn on replication heartbeat logging. - if "replSet" in kwargs and "logComponentVerbosity" not in suite_set_parameters: - suite_set_parameters["logComponentVerbosity"] = { - "replication": {"heartbeats": 2, "rollback": 2} - } + # Set default log verbosity levels if none were specified. + if "logComponentVerbosity" not in suite_set_parameters: + suite_set_parameters["logComponentVerbosity"] = DEFAULT_MONGOD_LOG_COMPONENT_VERBOSITY # orphanCleanupDelaySecs controls an artificial delay before cleaning up an orphaned chunk # that has migrated off of a shard, meant to allow most dependent queries on secondaries to @@ -181,22 +183,29 @@ def mongo_shell_program(logger, executable=None, connection_string=None, filenam global_vars["TestData"] = test_data - # Pass setParameters for mongos and mongod through TestData. The setParameter parsing in - # servers.js is very primitive (just splits on commas), so this may break for non-scalar - # setParameter values. + # Initialize setParameters for mongod and mongos, to be passed to the shell via TestData. Since + # they are dictionaries, they will be converted to JavaScript objects when passed to the shell + # by the _format_shell_vars() function. + mongod_set_parameters = {} if config.MONGOD_SET_PARAMETERS is not None: if "setParameters" in test_data: raise ValueError("setParameters passed via TestData can only be set from either the" " command line or the suite YAML, not both") mongod_set_parameters = utils.load_yaml(config.MONGOD_SET_PARAMETERS) - test_data["setParameters"] = _format_test_data_set_parameters(mongod_set_parameters) + + # If the 'logComponentVerbosity' setParameter for mongod was not already specified, we set its + # value to a default. + mongod_set_parameters.setdefault("logComponentVerbosity", + DEFAULT_MONGOD_LOG_COMPONENT_VERBOSITY) + + test_data["setParameters"] = mongod_set_parameters if config.MONGOS_SET_PARAMETERS is not None: if "setParametersMongos" in test_data: raise ValueError("setParametersMongos passed via TestData can only be set from either" " the command line or the suite YAML, not both") mongos_set_parameters = utils.load_yaml(config.MONGOS_SET_PARAMETERS) - test_data["setParametersMongos"] = _format_test_data_set_parameters(mongos_set_parameters) + test_data["setParametersMongos"] = mongos_set_parameters if "eval_prepend" in kwargs: eval_sb.append(str(kwargs.pop("eval_prepend"))) diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js index a6f76ad9c8c..a9f7cee143e 100644 --- a/src/mongo/shell/servers.js +++ b/src/mongo/shell/servers.js @@ -1003,9 +1003,6 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro // baseProgramName is the program name without any version information, e.g., mongod. let programName = argArray[0]; - // Object containing log component levels for the "logComponentVerbosity" parameter - let logComponentVerbosity = {}; - let [baseProgramName, programVersion] = programName.split("-"); let programMajorMinorVersion = 0; if (programVersion) { @@ -1016,11 +1013,6 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro if (baseProgramName === 'mongod' || baseProgramName === 'mongos') { if (jsTest.options().enableTestCommands) { argArray.push(...['--setParameter', "enableTestCommands=1"]); - if (!programVersion || programMajorMinorVersion >= 303) { - if (!argArrayContains("logComponentVerbosity")) { - logComponentVerbosity["tracking"] = 0; - } - } } if (jsTest.options().authMechanism && jsTest.options().authMechanism != "SCRAM-SHA-1") { var hasAuthMechs = false; @@ -1098,11 +1090,6 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro // Since options may not be backward compatible, mongod options are not // set on older versions, e.g., mongod-3.0. if (programName.endsWith('mongod')) { - // Enable heartbeat logging for replica set nodes. - if (!argArrayContains("logComponentVerbosity")) { - logComponentVerbosity["replication"] = {"heartbeats": 2, "rollback": 2}; - } - if (jsTest.options().storageEngine === "wiredTiger" || !jsTest.options().storageEngine) { if (jsTest.options().storageEngineCacheSizeGB && @@ -1131,25 +1118,28 @@ var MongoRunner, _startMongod, startMongoProgram, runMongoProgram, startMongoPro jsTest.options().storageEngineCacheSizeGB]); } } - // apply setParameters for mongod + // apply setParameters for mongod. The 'setParameters' field should be given as + // a plain JavaScript object, where each key is a parameter name and the value + // is the value to set for that parameter. if (jsTest.options().setParameters) { - var params = jsTest.options().setParameters.split(","); - if (params && params.length > 0) { - params.forEach(function(p) { - if (p) - argArray.push(...['--setParameter', p]); - }); + let params = jsTest.options().setParameters; + for (let paramName of Object.keys(params)) { + // Only set the 'logComponentVerbosity' parameter if it has not already + // been specified in the given argument array. This means that any + // 'logComponentVerbosity' settings passed through via TestData will + // always be overridden by settings passed directly to MongoRunner from + // within the shell. + if (paramName === "logComponentVerbosity" && + argArrayContains("logComponentVerbosity")) { + continue; + } + const paramVal = params[paramName]; + const setParamStr = paramName + "=" + JSON.stringify(paramVal); + argArray.push(...['--setParameter', setParamStr]); } } } } - - // Add any enabled log components. - if (Object.keys(logComponentVerbosity).length > 0) { - argArray.push( - ...['--setParameter', - "logComponentVerbosity=" + JSON.stringify(logComponentVerbosity)]); - } } return argArray; |