commit 11c509f9d7279e02d24126c7d15d8cafe0d183d5 Author: A. Jesse Jiryu Davis Date: Sat Jan 4 10:04:33 2020 -0500 --alwaysUseLogFiles diff --git a/buildscripts/resmokelib/config.py b/buildscripts/resmokelib/config.py index be04f1baad..4fba0b60e5 100644 --- a/buildscripts/resmokelib/config.py +++ b/buildscripts/resmokelib/config.py @@ -52,6 +52,7 @@ DEFAULTS = { "buildlogger_url": "https://logkeeper.mongodb.org", "continue_on_failure": False, "dbpath_prefix": None, + "always_use_log_files": False, "dbtest_executable": None, "dry_run": None, "exclude_with_any_tags": None, @@ -237,6 +238,10 @@ BUILDLOGGER_URL = None # as well as those started by individual tests. DBPATH_PREFIX = None +# JSTests configure servers to log to stdout by default. If set, always log to files and don't clean +# dbpaths after tests. +ALWAYS_USE_LOG_FILES = None + # The path to the dbtest executable used by resmoke.py. DBTEST_EXECUTABLE = None diff --git a/buildscripts/resmokelib/parser.py b/buildscripts/resmokelib/parser.py index dd9139dd56..175e402f86 100644 --- a/buildscripts/resmokelib/parser.py +++ b/buildscripts/resmokelib/parser.py @@ -15,7 +15,8 @@ from . import utils ResmokeConfig = collections.namedtuple( "ResmokeConfig", - ["list_suites", "find_suites", "dry_run", "suite_files", "test_files", "logging_config"]) + ["list_suites", "find_suites", "dry_run", "suite_files", "test_files", "logging_config", + "always_use_log_files"]) _EVERGREEN_OPTIONS_TITLE = "Evergreen options" @@ -78,6 +79,11 @@ def _make_parser(): # pylint: disable=too-many-statements help=("The directory which will contain the dbpaths of any mongod's started" " by resmoke.py or the tests themselves.")) + parser.add_option( + "--alwaysUseLogFiles", dest="always_use_log_files", action="store_true", + help=("JSTests configure servers to log to stdout by default. If set, always log to " + "files, and don't clean dbpaths after tests.")) + parser.add_option("--dbtest", dest="dbtest_executable", metavar="PATH", help="The path to the dbtest executable for resmoke to use.") @@ -500,7 +506,8 @@ def parse_command_line(): return ResmokeConfig(list_suites=options.list_suites, find_suites=options.find_suites, dry_run=options.dry_run, suite_files=options.suite_files.split(","), - test_files=args, logging_config=_get_logging_config(options.logger_file)) + test_files=args, logging_config=_get_logging_config(options.logger_file), + always_use_log_files=options.always_use_log_files) def _validate_options(parser, options, args): @@ -577,6 +584,7 @@ def _update_config_vars(values): # pylint: disable=too-many-statements,too-many _config.BASE_PORT = int(config.pop("base_port")) _config.BUILDLOGGER_URL = config.pop("buildlogger_url") _config.DBPATH_PREFIX = _expand_user(config.pop("dbpath_prefix")) + _config.ALWAYS_USE_LOG_FILES = config.pop("always_use_log_files") _config.DBTEST_EXECUTABLE = _expand_user(config.pop("dbtest_executable")) _config.DRY_RUN = config.pop("dry_run") # EXCLUDE_WITH_ANY_TAGS will always contain the implicitly defined EXCLUDED_TAG. diff --git a/buildscripts/resmokelib/testing/testcases/jstest.py b/buildscripts/resmokelib/testing/testcases/jstest.py index 4a441209d3..12947ef867 100644 --- a/buildscripts/resmokelib/testing/testcases/jstest.py +++ b/buildscripts/resmokelib/testing/testcases/jstest.py @@ -68,6 +68,7 @@ class _SingleJSTestCase(interface.ProcessTestCase): test_data["minPort"] = core.network.PortAllocator.min_test_port(self.fixture.job_num) test_data["maxPort"] = core.network.PortAllocator.max_test_port(self.fixture.job_num) test_data["peerPids"] = self.fixture.pids() + test_data["alwaysUseLogFiles"] = config.ALWAYS_USE_LOG_FILES test_data["failIfUnterminatedProcesses"] = True global_vars["TestData"] = test_data diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index 373987931a..f29a6b35a6 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -2960,7 +2960,7 @@ var ReplSetTest = function(opts) { return; } - if ((!opts || !opts.noCleanData) && _alldbpaths) { + if ((!opts || !opts.noCleanData) && !jsTestOptions().alwaysUseLogFiles && _alldbpaths) { print("ReplSetTest stopSet deleting all dbpaths"); for (var i = 0; i < _alldbpaths.length; i++) { print("ReplSetTest stopSet deleting dbpath: " + _alldbpaths[i]); diff --git a/src/mongo/shell/servers.js b/src/mongo/shell/servers.js index ff16b2a8b0..d366200bc7 100644 --- a/src/mongo/shell/servers.js +++ b/src/mongo/shell/servers.js @@ -636,7 +636,7 @@ MongoRunner.mongodOptions = function(opts) { _removeSetParameterIfBeforeVersion(opts, "numInitialSyncConnectAttempts", "3.3.12"); _removeSetParameterIfBeforeVersion(opts, "migrationLockAcquisitionMaxWaitMS", "4.1.7"); - if (!opts.logFile && opts.useLogFiles) { + if (!opts.logFile && opts.useLogFiles || jsTestOptions().alwaysUseLogFiles) { opts.logFile = opts.dbpath + "/mongod.log"; } else if (opts.logFile) { opts.logFile = MongoRunner.toRealFile(opts.logFile, opts.pathOpts); diff --git a/src/mongo/shell/shardingtest.js b/src/mongo/shell/shardingtest.js index bc73c48927..e6aa97f95c 100644 --- a/src/mongo/shell/shardingtest.js +++ b/src/mongo/shell/shardingtest.js @@ -411,7 +411,7 @@ var ShardingTest = function(params) { } } - if (!opts || !opts.noCleanData) { + if (!opts || !opts.noCleanData || !jsTestOptions().alwaysUseLogFiles) { print("ShardingTest stop deleting all dbpaths"); for (var i = 0; i < _alldbpaths.length; i++) { resetDbpath(MongoRunner.dataPath + _alldbpaths[i]); diff --git a/src/mongo/shell/utils.js b/src/mongo/shell/utils.js index 909b82ffd5..69e8ccde3f 100644 --- a/src/mongo/shell/utils.js +++ b/src/mongo/shell/utils.js @@ -346,6 +346,9 @@ jsTestOptions = function() { // Set a specific random seed to be used when useRandomBinVersionsWithinReplicaSet is // true. seed: TestData.seed || undefined, + // JSTests configure servers to log to stdout by default. If set, always log to files + // and don't clean dbpaths after tests. + alwaysUseLogFiles: TestData.alwaysUseLogFiles || false, }); } return _jsTestOptions;