summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorAdam Midvidy <amidvidy@gmail.com>2015-07-15 15:38:13 -0400
committerAdam Midvidy <amidvidy@gmail.com>2015-07-21 18:14:13 -0400
commitcf1a2f6d701ba4799224e247f9f00303c32f765f (patch)
treef90a6d84e043685d97148c40e3a4d40a2ac81d02 /buildscripts
parent0b3f5b96d95938daacce46d32036b31024bdbbe2 (diff)
downloadmongo-cf1a2f6d701ba4799224e247f9f00303c32f765f.tar.gz
SERVER-19299 add the ability to pass --setParameter arguments on the command line to resmoke.py
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/resmokelib/config.py8
-rw-r--r--buildscripts/resmokelib/core/programs.py22
-rw-r--r--buildscripts/resmokelib/parser.py16
-rw-r--r--buildscripts/resmokelib/utils/__init__.py9
4 files changed, 49 insertions, 6 deletions
diff --git a/buildscripts/resmokelib/config.py b/buildscripts/resmokelib/config.py
index 15e83e5e7bf..7fac26e7bc3 100644
--- a/buildscripts/resmokelib/config.py
+++ b/buildscripts/resmokelib/config.py
@@ -41,7 +41,9 @@ DEFAULTS = {
"jobs": 1,
"mongo": None,
"mongod": None,
+ "mongodSetParameters": None,
"mongos": None,
+ "mongosSetParameters": None,
"nojournal": None,
"nopreallocj": None,
"repeat": 1,
@@ -86,9 +88,15 @@ MONGO_EXECUTABLE = None
# The path to the mongod executable used by resmoke.py.
MONGOD_EXECUTABLE = None
+# The --setParameter options passed to mongod.
+MONGOD_SET_PARAMETERS = None
+
# The path to the mongos executable used by resmoke.py.
MONGOS_EXECUTABLE = None
+# The --setParameter options passed to mongos.
+MONGOS_SET_PARAMETERS = None
+
# If true, then all mongod's started by resmoke.py and by the mongo shell will not have journaling
# enabled.
NO_JOURNAL = None
diff --git a/buildscripts/resmokelib/core/programs.py b/buildscripts/resmokelib/core/programs.py
index 8d7f0aa1922..51c4b92f202 100644
--- a/buildscripts/resmokelib/core/programs.py
+++ b/buildscripts/resmokelib/core/programs.py
@@ -25,9 +25,14 @@ def mongod_program(logger, executable=None, process_kwargs=None, **kwargs):
executable = utils.default_if_none(executable, config.DEFAULT_MONGOD_EXECUTABLE)
args = [executable]
- # Apply the --setParameter command line argument.
- set_parameter = kwargs.pop("set_parameters", {})
- _apply_set_parameters(args, set_parameter)
+ # Apply the --setParameter command line argument. Command line options to resmoke.py override
+ # the YAML configuration.
+ suite_set_parameters = kwargs.pop("set_parameters", {})
+
+ if config.MONGOD_SET_PARAMETERS is not None:
+ suite_set_parameters.update(utils.load_yaml(config.MONGOD_SET_PARAMETERS))
+
+ _apply_set_parameters(args, suite_set_parameters)
shortcut_opts = {
"nojournal": config.NO_JOURNAL,
@@ -72,9 +77,14 @@ def mongos_program(logger, executable=None, process_kwargs=None, **kwargs):
executable = utils.default_if_none(executable, config.DEFAULT_MONGOS_EXECUTABLE)
args = [executable]
- # Apply the --setParameter command line argument.
- set_parameter = kwargs.pop("set_parameters", {})
- _apply_set_parameters(args, set_parameter)
+ # Apply the --setParameter command line argument. Command line options to resmoke.py override
+ # the YAML configuration.
+ suite_set_parameters = kwargs.pop("set_parameters", {})
+
+ if config.MONGOS_SET_PARAMETERS is not None:
+ suite_set_parameters.update(utils.load_yaml(config.MONGOS_SET_PARAMETERS))
+
+ _apply_set_parameters(args, suite_set_parameters)
# Apply the rest of the command line arguments.
_apply_kwargs(args, kwargs)
diff --git a/buildscripts/resmokelib/parser.py b/buildscripts/resmokelib/parser.py
index 7b07ec95450..5a9eccd1448 100644
--- a/buildscripts/resmokelib/parser.py
+++ b/buildscripts/resmokelib/parser.py
@@ -25,7 +25,9 @@ DEST_TO_CONFIG = {
"jobs": "jobs",
"mongo_executable": "mongo",
"mongod_executable": "mongod",
+ "mongod_parameters": "mongodSetParameters",
"mongos_executable": "mongos",
+ "mongos_parameters": "mongosSetParameters",
"no_journal": "nojournal",
"no_prealloc_journal": "nopreallocj",
"repeat": "repeat",
@@ -103,9 +105,21 @@ def parse_command_line():
parser.add_option("--mongod", dest="mongod_executable", metavar="PATH",
help="The path to the mongod executable for resmoke.py to use.")
+ parser.add_option("--mongodSetParameters", dest="mongod_parameters",
+ metavar="{key1: value1, key2: value2, ..., keyN: valueN}",
+ help=("Pass one or more --setParameter options to all mongod processes"
+ " started by resmoke.py. The argument is specified as bracketed YAML -"
+ " i.e. JSON with support for single quoted and unquoted keys."))
+
parser.add_option("--mongos", dest="mongos_executable", metavar="PATH",
help="The path to the mongos executable for resmoke.py to use.")
+ parser.add_option("--mongosSetParameters", dest="mongos_parameters",
+ metavar="{key1: value1, key2: value2, ..., keyN: valueN}",
+ help=("Pass one or more --setParameter options to all mongos processes"
+ " started by resmoke.py. The argument is specified as bracketed YAML -"
+ " i.e. JSON with support for single quoted and unquoted keys."))
+
parser.add_option("--nojournal", action="store_true", dest="no_journal",
help="Disable journaling for all mongod's.")
@@ -175,7 +189,9 @@ def update_config_vars(values):
_config.JOBS = config.pop("jobs")
_config.MONGO_EXECUTABLE = _expand_user(config.pop("mongo"))
_config.MONGOD_EXECUTABLE = _expand_user(config.pop("mongod"))
+ _config.MONGOD_SET_PARAMETERS = config.pop("mongodSetParameters")
_config.MONGOS_EXECUTABLE = _expand_user(config.pop("mongos"))
+ _config.MONGOS_SET_PARAMETERS = config.pop("mongosSetParameters")
_config.NO_JOURNAL = config.pop("nojournal")
_config.NO_PREALLOC_JOURNAL = config.pop("nopreallocj")
_config.RANDOM_SEED = config.pop("seed")
diff --git a/buildscripts/resmokelib/utils/__init__.py b/buildscripts/resmokelib/utils/__init__.py
index 14d4eed771b..df387cc3323 100644
--- a/buildscripts/resmokelib/utils/__init__.py
+++ b/buildscripts/resmokelib/utils/__init__.py
@@ -61,6 +61,15 @@ def dump_yaml(value):
# Use block (indented) style for formatting YAML.
return yaml.safe_dump(value, default_flow_style=False).rstrip()
+def load_yaml(value):
+ """
+ Attempts to parse 'value' as YAML.
+ """
+ try:
+ return yaml.safe_load(value)
+ except yaml.YAMLError as err:
+ raise ValueError("Attempted to parse invalid YAML value '%s': %s" % (value, err))
+
def new_mongo_client(port, read_preference=pymongo.ReadPreference.PRIMARY, timeout_millis=30000):
"""