diff options
author | Jonathan Abrahams <jonathan@mongodb.com> | 2018-03-26 11:25:04 -0400 |
---|---|---|
committer | Jonathan Abrahams <jonathan@mongodb.com> | 2018-03-26 13:04:25 -0400 |
commit | 36148ad8bbdb94162b2926f4700d935ee4dc5994 (patch) | |
tree | 1d893c4ca0b0afa407f7724c7942dfbf643560af /buildscripts/resmokelib/testing | |
parent | d62d631f0ca40c5199fdfae2980080ca0cc982b5 (diff) | |
download | mongo-36148ad8bbdb94162b2926f4700d935ee4dc5994.tar.gz |
SERVER-23312 Format Python files with yapf
Diffstat (limited to 'buildscripts/resmokelib/testing')
34 files changed, 196 insertions, 365 deletions
diff --git a/buildscripts/resmokelib/testing/executor.py b/buildscripts/resmokelib/testing/executor.py index 63ff606d2f1..f66515ac8b0 100644 --- a/buildscripts/resmokelib/testing/executor.py +++ b/buildscripts/resmokelib/testing/executor.py @@ -30,14 +30,8 @@ class TestSuiteExecutor(object): _TIMEOUT = 24 * 60 * 60 # =1 day (a long time to have tests run) - def __init__(self, - exec_logger, - suite, - config=None, - fixture=None, - hooks=None, - archive_instance=None, - archive=None): + def __init__(self, exec_logger, suite, config=None, fixture=None, hooks=None, + archive_instance=None, archive=None): """ Initializes the TestSuiteExecutor with the test suite to run. """ @@ -55,8 +49,8 @@ class TestSuiteExecutor(object): self.archival = None if archive_instance: - self.archival = archival.HookTestArchival( - suite, self.hooks_config, archive_instance, archive) + self.archival = archival.HookTestArchival(suite, self.hooks_config, archive_instance, + archive) self._suite = suite @@ -147,8 +141,7 @@ class TestSuiteExecutor(object): try: job.fixture.setup() except: - self.logger.exception( - "Encountered an error while setting up %s.", job.fixture) + self.logger.exception("Encountered an error while setting up %s.", job.fixture) return False # Once they have all been started, wait for them to become available. @@ -156,8 +149,8 @@ class TestSuiteExecutor(object): try: job.fixture.await_ready() except: - self.logger.exception( - "Encountered an error while waiting for %s to be ready", job.fixture) + self.logger.exception("Encountered an error while waiting for %s to be ready", + job.fixture) return False return True @@ -177,8 +170,7 @@ class TestSuiteExecutor(object): try: # Run each Job instance in its own thread. for job in self._jobs: - t = threading.Thread(target=job, - args=(test_queue, interrupt_flag), + t = threading.Thread(target=job, args=(test_queue, interrupt_flag), kwargs=dict(teardown_flag=teardown_flag)) # Do not wait for tests to finish executing if interrupted by the user. t.daemon = True @@ -258,10 +250,7 @@ class TestSuiteExecutor(object): hook_class = hook_config.pop("class") hook_logger = self.logger.new_hook_logger(hook_class, fixture.logger) - hook = _hooks.make_hook(hook_class, - hook_logger, - fixture, - **hook_config) + hook = _hooks.make_hook(hook_class, hook_logger, fixture, **hook_config) hooks.append(hook) return hooks @@ -278,12 +267,7 @@ class TestSuiteExecutor(object): report = _report.TestReport(job_logger, self._suite.options) - return _job.Job(job_logger, - fixture, - hooks, - report, - self.archival, - self._suite.options) + return _job.Job(job_logger, fixture, hooks, report, self.archival, self._suite.options) def _make_test_queue(self): """ @@ -297,10 +281,8 @@ class TestSuiteExecutor(object): # Put all the test cases in a queue. queue = _queue.Queue() for test_name in self._suite.tests: - test_case = testcases.make_test_case(self._suite.test_kind, - test_queue_logger, - test_name, - **self.test_config) + test_case = testcases.make_test_case(self._suite.test_kind, test_queue_logger, + test_name, **self.test_config) queue.put(test_case) # Add sentinel value for each job to indicate when there are no more items to process. diff --git a/buildscripts/resmokelib/testing/fixtures/__init__.py b/buildscripts/resmokelib/testing/fixtures/__init__.py index d8c3d8a2b53..e59a05c9754 100644 --- a/buildscripts/resmokelib/testing/fixtures/__init__.py +++ b/buildscripts/resmokelib/testing/fixtures/__init__.py @@ -8,10 +8,8 @@ from .interface import NoOpFixture as _NoOpFixture from .interface import make_fixture from ...utils import autoloader as _autoloader - NOOP_FIXTURE_CLASS = _NoOpFixture.REGISTERED_NAME - # We dynamically load all modules in the fixtures/ package so that any Fixture classes declared # within them are automatically registered. _autoloader.load_all_modules(name=__name__, path=__path__) diff --git a/buildscripts/resmokelib/testing/fixtures/interface.py b/buildscripts/resmokelib/testing/fixtures/interface.py index 64d24be1eb6..0d80907e680 100644 --- a/buildscripts/resmokelib/testing/fixtures/interface.py +++ b/buildscripts/resmokelib/testing/fixtures/interface.py @@ -16,7 +16,6 @@ from ... import logging from ... import utils from ...utils import registry - _FIXTURES = {} @@ -145,8 +144,7 @@ class Fixture(object): kwargs["connect"] = True return pymongo.MongoClient(host=self.get_driver_connection_url(), - read_preference=read_preference, - **kwargs) + read_preference=read_preference, **kwargs) def __str__(self): return "%s (Job #%d)" % (self.__class__.__name__, self.job_num) diff --git a/buildscripts/resmokelib/testing/fixtures/replicaset.py b/buildscripts/resmokelib/testing/fixtures/replicaset.py index 5f89cd5fb5d..a554c6a7044 100644 --- a/buildscripts/resmokelib/testing/fixtures/replicaset.py +++ b/buildscripts/resmokelib/testing/fixtures/replicaset.py @@ -25,21 +25,11 @@ class ReplicaSetFixture(interface.ReplFixture): # Error response codes copied from mongo/base/error_codes.err. _NODE_NOT_FOUND = 74 - def __init__(self, - logger, - job_num, - mongod_executable=None, - mongod_options=None, - dbpath_prefix=None, - preserve_dbpath=False, - num_nodes=2, - start_initial_sync_node=False, - write_concern_majority_journal_default=None, - auth_options=None, - replset_config_options=None, - voting_secondaries=None, - all_nodes_electable=False, - use_replica_set_connection_string=None): + def __init__(self, logger, job_num, mongod_executable=None, mongod_options=None, + dbpath_prefix=None, preserve_dbpath=False, num_nodes=2, + start_initial_sync_node=False, write_concern_majority_journal_default=None, + auth_options=None, replset_config_options=None, voting_secondaries=None, + all_nodes_electable=False, use_replica_set_connection_string=None): interface.ReplFixture.__init__(self, logger, job_num, dbpath_prefix=dbpath_prefix) @@ -117,11 +107,11 @@ class ReplicaSetFixture(interface.ReplFixture): member_info["votes"] = 0 members.append(member_info) if self.initial_sync_node: - members.append({"_id": self.initial_sync_node_idx, - "host": self.initial_sync_node.get_internal_connection_string(), - "priority": 0, - "hidden": 1, - "votes": 0}) + members.append({ + "_id": self.initial_sync_node_idx, + "host": self.initial_sync_node.get_internal_connection_string(), "priority": 0, + "hidden": 1, "votes": 0 + }) config = {"_id": self.replset_name} client = self.nodes[0].mongo_client() @@ -137,13 +127,13 @@ class ReplicaSetFixture(interface.ReplFixture): return if self.write_concern_majority_journal_default is not None: - config["writeConcernMajorityJournalDefault"] = self.write_concern_majority_journal_default + config[ + "writeConcernMajorityJournalDefault"] = self.write_concern_majority_journal_default else: server_status = client.admin.command({"serverStatus": 1}) cmd_line_opts = client.admin.command({"getCmdLineOpts": 1}) - if not (server_status["storageEngine"]["persistent"] and - cmd_line_opts["parsed"].get("storage", {}).get( - "journal", {}).get("enabled", True)): + if not (server_status["storageEngine"]["persistent"] and cmd_line_opts["parsed"].get( + "storage", {}).get("journal", {}).get("enabled", True)): config["writeConcernMajorityJournalDefault"] = False if self.replset_config_options.get("configsvr", False): @@ -326,11 +316,9 @@ class ReplicaSetFixture(interface.ReplFixture): mongod_options["replSet"] = replset_name mongod_options["dbpath"] = os.path.join(self._dbpath_prefix, "node{}".format(index)) - return standalone.MongoDFixture(mongod_logger, - self.job_num, - mongod_executable=self.mongod_executable, - mongod_options=mongod_options, - preserve_dbpath=self.preserve_dbpath) + return standalone.MongoDFixture( + mongod_logger, self.job_num, mongod_executable=self.mongod_executable, + mongod_options=mongod_options, preserve_dbpath=self.preserve_dbpath) def _get_logger_for_mongod(self, index): """ diff --git a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py index 94c8346371b..5e94b133708 100644 --- a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py +++ b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py @@ -29,23 +29,11 @@ class ShardedClusterFixture(interface.Fixture): _CONFIGSVR_REPLSET_NAME = "config-rs" _SHARD_REPLSET_NAME_PREFIX = "shard-rs" - def __init__(self, - logger, - job_num, - mongos_executable=None, - mongos_options=None, - mongod_executable=None, - mongod_options=None, - dbpath_prefix=None, - preserve_dbpath=False, - num_shards=1, - num_rs_nodes_per_shard=None, - separate_configsvr=True, - enable_sharding=None, - enable_balancer=True, - auth_options=None, - configsvr_options=None, - shard_options=None): + def __init__(self, logger, job_num, mongos_executable=None, mongos_options=None, + mongod_executable=None, mongod_options=None, dbpath_prefix=None, + preserve_dbpath=False, num_shards=1, num_rs_nodes_per_shard=None, + separate_configsvr=True, enable_sharding=None, enable_balancer=True, + auth_options=None, configsvr_options=None, shard_options=None): """ Initializes ShardedClusterFixture with the different options to the mongod and mongos processes. @@ -174,9 +162,9 @@ class ShardedClusterFixture(interface.Fixture): Returns true if the config server, all shards, and the mongos are all still operating, and false otherwise. """ - return (self.configsvr is not None and self.configsvr.is_running() and - all(shard.is_running() for shard in self.shards) and - self.mongos is not None and self.mongos.is_running()) + return (self.configsvr is not None and self.configsvr.is_running() + and all(shard.is_running() for shard in self.shards) and self.mongos is not None + and self.mongos.is_running()) def get_internal_connection_string(self): if self.mongos is None: @@ -212,15 +200,11 @@ class ShardedClusterFixture(interface.Fixture): mongod_options["replSet"] = ShardedClusterFixture._CONFIGSVR_REPLSET_NAME mongod_options["storageEngine"] = "wiredTiger" - return replicaset.ReplicaSetFixture(mongod_logger, - self.job_num, - mongod_executable=mongod_executable, - mongod_options=mongod_options, - preserve_dbpath=preserve_dbpath, - num_nodes=num_nodes, - auth_options=auth_options, - replset_config_options=replset_config_options, - **configsvr_options) + return replicaset.ReplicaSetFixture( + mongod_logger, self.job_num, mongod_executable=mongod_executable, + mongod_options=mongod_options, preserve_dbpath=preserve_dbpath, num_nodes=num_nodes, + auth_options=auth_options, replset_config_options=replset_config_options, + **configsvr_options) def _new_rs_shard(self, index, num_rs_nodes_per_shard): """ @@ -245,15 +229,11 @@ class ShardedClusterFixture(interface.Fixture): mongod_options["dbpath"] = os.path.join(self._dbpath_prefix, "shard{}".format(index)) mongod_options["replSet"] = ShardedClusterFixture._SHARD_REPLSET_NAME_PREFIX + str(index) - return replicaset.ReplicaSetFixture(mongod_logger, - self.job_num, - mongod_executable=mongod_executable, - mongod_options=mongod_options, - preserve_dbpath=preserve_dbpath, - num_nodes=num_rs_nodes_per_shard, - auth_options=auth_options, - replset_config_options=replset_config_options, - **shard_options) + return replicaset.ReplicaSetFixture( + mongod_logger, self.job_num, mongod_executable=mongod_executable, + mongod_options=mongod_options, preserve_dbpath=preserve_dbpath, + num_nodes=num_rs_nodes_per_shard, auth_options=auth_options, + replset_config_options=replset_config_options, **shard_options) def _new_standalone_shard(self, index): """ @@ -273,12 +253,9 @@ class ShardedClusterFixture(interface.Fixture): mongod_options["shardsvr"] = "" mongod_options["dbpath"] = os.path.join(self._dbpath_prefix, "shard{}".format(index)) - return standalone.MongoDFixture(mongod_logger, - self.job_num, - mongod_executable=mongod_executable, - mongod_options=mongod_options, - preserve_dbpath=preserve_dbpath, - **shard_options) + return standalone.MongoDFixture( + mongod_logger, self.job_num, mongod_executable=mongod_executable, + mongod_options=mongod_options, preserve_dbpath=preserve_dbpath, **shard_options) def _new_mongos(self): """ @@ -295,9 +272,7 @@ class ShardedClusterFixture(interface.Fixture): else: mongos_options["configdb"] = "localhost:{}".format(self.shards[0].port) - return _MongoSFixture(mongos_logger, - self.job_num, - mongos_executable=self.mongos_executable, + return _MongoSFixture(mongos_logger, self.job_num, mongos_executable=self.mongos_executable, mongos_options=mongos_options) def _add_shard(self, client, shard): @@ -321,11 +296,7 @@ class _MongoSFixture(interface.Fixture): REGISTERED_NAME = registry.LEAVE_UNREGISTERED - def __init__(self, - logger, - job_num, - mongos_executable=None, - mongos_options=None): + def __init__(self, logger, job_num, mongos_executable=None, mongos_options=None): interface.Fixture.__init__(self, logger, job_num) @@ -342,8 +313,7 @@ class _MongoSFixture(interface.Fixture): self.mongos_options["port"] = core.network.PortAllocator.next_fixture_port(self.job_num) self.port = self.mongos_options["port"] - mongos = core.programs.mongos_program(self.logger, - executable=self.mongos_executable, + mongos = core.programs.mongos_program(self.logger, executable=self.mongos_executable, **self.mongos_options) try: self.logger.info("Starting mongos on port %d...\n%s", self.port, mongos.as_command()) @@ -367,8 +337,8 @@ class _MongoSFixture(interface.Fixture): exit_code = self.mongos.poll() if exit_code is not None: raise errors.ServerFailure("Could not connect to mongos on port {}, process ended" - " unexpectedly with code {}.".format(self.port, - exit_code)) + " unexpectedly with code {}.".format( + self.port, exit_code)) try: # Use a shorter connection timeout to more closely satisfy the requested deadline. diff --git a/buildscripts/resmokelib/testing/fixtures/standalone.py b/buildscripts/resmokelib/testing/fixtures/standalone.py index 9b6a5b09e5d..0d761478cd8 100644 --- a/buildscripts/resmokelib/testing/fixtures/standalone.py +++ b/buildscripts/resmokelib/testing/fixtures/standalone.py @@ -27,13 +27,8 @@ class MongoDFixture(interface.Fixture): AWAIT_READY_TIMEOUT_SECS = 300 - def __init__(self, - logger, - job_num, - mongod_executable=None, - mongod_options=None, - dbpath_prefix=None, - preserve_dbpath=False): + def __init__(self, logger, job_num, mongod_executable=None, mongod_options=None, + dbpath_prefix=None, preserve_dbpath=False): interface.Fixture.__init__(self, logger, job_num, dbpath_prefix=dbpath_prefix) @@ -49,8 +44,7 @@ class MongoDFixture(interface.Fixture): # The dbpath in mongod_options takes precedence over other settings to make it easier for # users to specify a dbpath containing data to test against. if "dbpath" not in self.mongod_options: - self.mongod_options["dbpath"] = os.path.join( - self._dbpath_prefix, config.FIXTURE_SUBDIR) + self.mongod_options["dbpath"] = os.path.join(self._dbpath_prefix, config.FIXTURE_SUBDIR) self._dbpath = self.mongod_options["dbpath"] self.mongod = None @@ -70,8 +64,7 @@ class MongoDFixture(interface.Fixture): self.mongod_options["port"] = core.network.PortAllocator.next_fixture_port(self.job_num) self.port = self.mongod_options["port"] - mongod = core.programs.mongod_program(self.logger, - executable=self.mongod_executable, + mongod = core.programs.mongod_program(self.logger, executable=self.mongod_executable, **self.mongod_options) try: self.logger.info("Starting mongod on port %d...\n%s", self.port, mongod.as_command()) diff --git a/buildscripts/resmokelib/testing/hook_test_archival.py b/buildscripts/resmokelib/testing/hook_test_archival.py index 05445208673..315247261d6 100644 --- a/buildscripts/resmokelib/testing/hook_test_archival.py +++ b/buildscripts/resmokelib/testing/hook_test_archival.py @@ -92,25 +92,19 @@ class HookTestArchival(object): # Normalize test path from a test or hook name. test_path = \ test_name.replace("/", "_").replace("\\", "_").replace(".", "_").replace(":", "_") - file_name = "mongo-data-{}-{}-{}-{}.tgz".format( - config.EVERGREEN_TASK_ID, - test_path, - config.EVERGREEN_EXECUTION, - self._tests_repeat[test_name]) + file_name = "mongo-data-{}-{}-{}-{}.tgz".format(config.EVERGREEN_TASK_ID, test_path, + config.EVERGREEN_EXECUTION, + self._tests_repeat[test_name]) # Retrieve root directory for all dbPaths from fixture. input_files = test.fixture.get_dbpath_prefix() s3_bucket = config.ARCHIVE_BUCKET - s3_path = "{}/{}/{}/datafiles/{}".format( - config.EVERGREEN_PROJECT_NAME, - config.EVERGREEN_VARIANT_NAME, - config.EVERGREEN_REVISION, - file_name) + s3_path = "{}/{}/{}/datafiles/{}".format(config.EVERGREEN_PROJECT_NAME, + config.EVERGREEN_VARIANT_NAME, + config.EVERGREEN_REVISION, file_name) display_name = "Data files {} - Execution {} Repetition {}".format( - test_name, - config.EVERGREEN_EXECUTION, - self._tests_repeat[test_name]) + test_name, config.EVERGREEN_EXECUTION, self._tests_repeat[test_name]) logger.info("Archiving data files for test %s from %s", test_name, input_files) - status, message = self.archive_instance.archive_files_to_s3( - display_name, input_files, s3_bucket, s3_path) + status, message = self.archive_instance.archive_files_to_s3(display_name, input_files, + s3_bucket, s3_path) if status: logger.warning("Archive failed for %s: %s", test_name, message) diff --git a/buildscripts/resmokelib/testing/hooks/__init__.py b/buildscripts/resmokelib/testing/hooks/__init__.py index 40cc09c78cc..87efcd1c964 100644 --- a/buildscripts/resmokelib/testing/hooks/__init__.py +++ b/buildscripts/resmokelib/testing/hooks/__init__.py @@ -1,4 +1,5 @@ -""" +"""Testing hooks package. + Package containing classes to customize the behavior of a test fixture by allowing special code to be executed before or after each test, and before or after each suite. @@ -9,7 +10,6 @@ from __future__ import absolute_import from .interface import make_hook from ...utils import autoloader as _autoloader - # We dynamically load all modules in the hooks/ package so that any Hook classes declared # within them are automatically registered. _autoloader.load_all_modules(name=__name__, path=__path__) diff --git a/buildscripts/resmokelib/testing/hooks/cleanup.py b/buildscripts/resmokelib/testing/hooks/cleanup.py index 6442f035114..39011ec90fd 100644 --- a/buildscripts/resmokelib/testing/hooks/cleanup.py +++ b/buildscripts/resmokelib/testing/hooks/cleanup.py @@ -35,8 +35,8 @@ class CleanEveryN(interface.Hook): if self.tests_run < self.n: return - hook_test_case = CleanEveryNTestCase.create_after_test( - self.logger.test_case_logger, test, self) + hook_test_case = CleanEveryNTestCase.create_after_test(self.logger.test_case_logger, test, + self) hook_test_case.configure(self.fixture) hook_test_case.run_dynamic_test(test_report) diff --git a/buildscripts/resmokelib/testing/hooks/combine_benchmark_results.py b/buildscripts/resmokelib/testing/hooks/combine_benchmark_results.py index 2df4296dad5..7f1bea31cf3 100644 --- a/buildscripts/resmokelib/testing/hooks/combine_benchmark_results.py +++ b/buildscripts/resmokelib/testing/hooks/combine_benchmark_results.py @@ -68,8 +68,7 @@ class CombineBenchmarkResults(interface.Hook): for name, report in self.benchmark_reports.items(): test_report = { - "name": name, - "results": report.generate_perf_plugin_dict(), + "name": name, "results": report.generate_perf_plugin_dict(), "context": report.context._asdict() } @@ -124,11 +123,7 @@ class _BenchmarkThreadsReport(object): } """ CONTEXT_FIELDS = [ - "date", - "cpu_scaling_enabled", - "num_cpus", - "mhz_per_cpu", - "library_build_type" + "date", "cpu_scaling_enabled", "num_cpus", "mhz_per_cpu", "library_build_type" ] Context = collections.namedtuple("Context", CONTEXT_FIELDS) @@ -163,8 +158,8 @@ class _BenchmarkThreadsReport(object): res = {} for thread_count, reports in self.thread_benchmark_map.items(): - if (thread_count.endswith("median") or thread_count.endswith("mean") or - thread_count.endswith("stddev")): + if (thread_count.endswith("median") or thread_count.endswith("mean") + or thread_count.endswith("stddev")): # We don't use Benchmark's included statistics for now because they clutter up the # graph. continue diff --git a/buildscripts/resmokelib/testing/hooks/dbhash.py b/buildscripts/resmokelib/testing/hooks/dbhash.py index f5081fd5e7d..70516b500db 100644 --- a/buildscripts/resmokelib/testing/hooks/dbhash.py +++ b/buildscripts/resmokelib/testing/hooks/dbhash.py @@ -14,12 +14,9 @@ class CheckReplDBHash(jsfile.JSHook): Checks that the dbhashes of all non-local databases and non-replicated system collections match on the primary and secondaries. """ + def __init__(self, hook_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") - jsfile.JSHook.__init__(self, - hook_logger, - fixture, - js_filename, - description, + jsfile.JSHook.__init__(self, hook_logger, fixture, js_filename, description, shell_options=shell_options) diff --git a/buildscripts/resmokelib/testing/hooks/initialsync.py b/buildscripts/resmokelib/testing/hooks/initialsync.py index 328c4ac182e..905d0a1e913 100644 --- a/buildscripts/resmokelib/testing/hooks/initialsync.py +++ b/buildscripts/resmokelib/testing/hooks/initialsync.py @@ -68,15 +68,12 @@ class BackgroundInitialSyncTestCase(jsfile.DynamicJSTestCase): # If it's been 'n' tests so far, wait for the initial sync node to finish syncing. if self._hook.tests_run >= self._hook.n: - self.logger.info( - "%d tests have been run against the fixture, waiting for initial sync" - " node to go into SECONDARY state", - self._hook.tests_run) + self.logger.info("%d tests have been run against the fixture, waiting for initial sync" + " node to go into SECONDARY state", self._hook.tests_run) self._hook.tests_run = 0 - cmd = bson.SON([("replSetTest", 1), - ("waitForMemberState", 2), - ("timeoutMillis", 20 * 60 * 1000)]) + cmd = bson.SON([("replSetTest", 1), ("waitForMemberState", 2), ("timeoutMillis", + 20 * 60 * 1000)]) sync_node_conn.admin.command(cmd) # Check if the initial sync node is in SECONDARY state. If it's been 'n' tests, then it @@ -90,11 +87,9 @@ class BackgroundInitialSyncTestCase(jsfile.DynamicJSTestCase): self.logger.exception("{0} failed: {1}".format(self._hook.description, msg)) raise errors.TestFailure(msg) - self.logger.info( - "Initial sync node is in state %d, not state SECONDARY (2)." - " Skipping BackgroundInitialSync hook for %s", - state, - self._base_test_name) + self.logger.info("Initial sync node is in state %d, not state SECONDARY (2)." + " Skipping BackgroundInitialSync hook for %s", state, + self._base_test_name) # If we have not restarted initial sync since the last time we ran the data # validation, restart initial sync with a 20% probability. @@ -175,8 +170,8 @@ class IntermediateInitialSyncTestCase(jsfile.DynamicJSTestCase): JS_FILENAME = os.path.join("jstests", "hooks", "run_initial_sync_node_validation.js") def __init__(self, logger, test_name, description, base_test_name, hook): - jsfile.DynamicJSTestCase.__init__(self, logger, test_name, description, - base_test_name, hook, self.JS_FILENAME) + jsfile.DynamicJSTestCase.__init__(self, logger, test_name, description, base_test_name, + hook, self.JS_FILENAME) def run_test(self): sync_node = self.fixture.get_initial_sync_node() @@ -190,9 +185,8 @@ class IntermediateInitialSyncTestCase(jsfile.DynamicJSTestCase): # Do initial sync round. self.logger.info("Waiting for initial sync node to go into SECONDARY state") - cmd = bson.SON([("replSetTest", 1), - ("waitForMemberState", 2), - ("timeoutMillis", 20 * 60 * 1000)]) + cmd = bson.SON([("replSetTest", 1), ("waitForMemberState", 2), ("timeoutMillis", + 20 * 60 * 1000)]) sync_node_conn.admin.command(cmd) # Run data validation and dbhash checking. diff --git a/buildscripts/resmokelib/testing/hooks/interface.py b/buildscripts/resmokelib/testing/hooks/interface.py index cc854f75c42..877b2cc565f 100644 --- a/buildscripts/resmokelib/testing/hooks/interface.py +++ b/buildscripts/resmokelib/testing/hooks/interface.py @@ -11,7 +11,6 @@ from ... import errors from ...logging import loggers from ...utils import registry - _HOOKS = {} diff --git a/buildscripts/resmokelib/testing/hooks/jsfile.py b/buildscripts/resmokelib/testing/hooks/jsfile.py index 98c89e60534..65398efd0bf 100644 --- a/buildscripts/resmokelib/testing/hooks/jsfile.py +++ b/buildscripts/resmokelib/testing/hooks/jsfile.py @@ -5,7 +5,6 @@ JavaScript file. from __future__ import absolute_import - from . import interface from ..testcases import jstest from ...utils import registry @@ -38,10 +37,11 @@ class JSHook(interface.Hook): class DynamicJSTestCase(interface.DynamicTestCase): """A dynamic TestCase that runs a JavaScript file.""" - def __init__(self, logger, test_name, description, base_test_name, hook, - js_filename, shell_options=None): - interface.DynamicTestCase.__init__(self, logger, test_name, description, - base_test_name, hook) + + def __init__(self, logger, test_name, description, base_test_name, hook, js_filename, + shell_options=None): + interface.DynamicTestCase.__init__(self, logger, test_name, description, base_test_name, + hook) self._js_test = jstest.JSTestCase(logger, js_filename, shell_options=shell_options) def override_logger(self, new_logger): diff --git a/buildscripts/resmokelib/testing/hooks/oplog.py b/buildscripts/resmokelib/testing/hooks/oplog.py index bb75b1bf501..225634ce084 100644 --- a/buildscripts/resmokelib/testing/hooks/oplog.py +++ b/buildscripts/resmokelib/testing/hooks/oplog.py @@ -14,12 +14,9 @@ class CheckReplOplogs(jsfile.JSHook): """ Checks that local.oplog.rs matches on the primary and secondaries. """ + def __init__(self, hook_logger, fixture, shell_options=None): description = "Check oplogs of all replica set members" js_filename = os.path.join("jstests", "hooks", "run_check_repl_oplogs.js") - jsfile.JSHook.__init__(self, - hook_logger, - fixture, - js_filename, - description, + jsfile.JSHook.__init__(self, hook_logger, fixture, js_filename, description, shell_options=shell_options) diff --git a/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py b/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py index 09e8d00514f..a6924fe52b6 100644 --- a/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py +++ b/buildscripts/resmokelib/testing/hooks/periodic_kill_secondaries.py @@ -91,12 +91,11 @@ class PeriodicKillSecondaries(interface.Hook): # applying any oplog entries while the test is running. client = secondary.mongo_client() try: - client.admin.command(bson.SON([ - ("configureFailPoint", "rsSyncApplyStop"), - ("mode", "alwaysOn")])) + client.admin.command( + bson.SON([("configureFailPoint", "rsSyncApplyStop"), ("mode", "alwaysOn")])) except pymongo.errors.OperationFailure as err: - self.logger.exception( - "Unable to disable oplog application on the mongod on port %d", secondary.port) + self.logger.exception("Unable to disable oplog application on the mongod on port %d", + secondary.port) raise errors.ServerFailure( "Unable to disable oplog application on the mongod on port {}: {}".format( secondary.port, err.args[0])) @@ -106,13 +105,11 @@ class PeriodicKillSecondaries(interface.Hook): # oplog entries. client = secondary.mongo_client() try: - client.admin.command(bson.SON([ - ("configureFailPoint", "rsSyncApplyStop"), - ("mode", "off")])) + client.admin.command( + bson.SON([("configureFailPoint", "rsSyncApplyStop"), ("mode", "off")])) except pymongo.errors.OperationFailure as err: - self.logger.exception( - "Unable to re-enable oplog application on the mongod on port %d", - secondary.port) + self.logger.exception("Unable to re-enable oplog application on the mongod on port %d", + secondary.port) raise errors.ServerFailure( "Unable to re-enable oplog application on the mongod on port {}: {}".format( secondary.port, err.args[0])) @@ -120,8 +117,8 @@ class PeriodicKillSecondaries(interface.Hook): class PeriodicKillSecondariesTestCase(interface.DynamicTestCase): def __init__(self, logger, test_name, description, base_test_name, hook, test_report): - interface.DynamicTestCase.__init__(self, logger, test_name, description, - base_test_name, hook) + interface.DynamicTestCase.__init__(self, logger, test_name, description, base_test_name, + hook) self._test_report = test_report def run_test(self): @@ -243,10 +240,11 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase): client = secondary.mongo_client() minvalid_doc = client.local["replset.minvalid"].find_one() oplog_truncate_after_doc = client.local["replset.oplogTruncateAfterPoint"].find_one() - self.logger.info("minValid: {}, oTAP: {}".format(minvalid_doc, oplog_truncate_after_doc)) + self.logger.info("minValid: {}, oTAP: {}".format(minvalid_doc, + oplog_truncate_after_doc)) - latest_oplog_doc = client.local["oplog.rs"].find_one( - sort=[("$natural", pymongo.DESCENDING)]) + latest_oplog_doc = client.local["oplog.rs"].find_one(sort=[("$natural", + pymongo.DESCENDING)]) null_ts = bson.Timestamp(0, 0) @@ -255,8 +253,8 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase): if latest_oplog_doc is not None: latest_oplog_entry_ts = latest_oplog_doc.get("ts") if latest_oplog_entry_ts is None: - raise errors.ServerFailure("Latest oplog entry had no 'ts' field: {}".format( - latest_oplog_doc)) + raise errors.ServerFailure( + "Latest oplog entry had no 'ts' field: {}".format(latest_oplog_doc)) # The "oplogTruncateAfterPoint" document may not exist at startup. If so, we default # it to null. @@ -310,9 +308,9 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase): raise errors.ServerFailure( "The condition minValid <= oplogTruncateAfterPoint ({} <= {}) doesn't" " hold: minValid document={}, oplogTruncateAfterPoint document={}," - " latest oplog entry={}".format( - minvalid_ts, oplog_truncate_after_ts, minvalid_doc, - oplog_truncate_after_doc, latest_oplog_doc)) + " latest oplog entry={}".format(minvalid_ts, oplog_truncate_after_ts, + minvalid_doc, oplog_truncate_after_doc, + latest_oplog_doc)) # minvalid <= latest oplog entry # "minValid" is set to the end of a batch after the batch is written to the oplog. @@ -321,8 +319,7 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase): raise errors.ServerFailure( "The condition minValid <= top of oplog ({} <= {}) doesn't" " hold: minValid document={}, latest oplog entry={}".format( - minvalid_ts, latest_oplog_entry_ts, minvalid_doc, - latest_oplog_doc)) + minvalid_ts, latest_oplog_entry_ts, minvalid_doc, latest_oplog_doc)) try: secondary.teardown() @@ -346,15 +343,16 @@ class PeriodicKillSecondariesTestCase(interface.DynamicTestCase): def _await_secondary_state(self, secondary): client = secondary.mongo_client() try: - client.admin.command(bson.SON([ - ("replSetTest", 1), - ("waitForMemberState", 2), # 2 = SECONDARY - ("timeoutMillis", fixture.ReplFixture.AWAIT_REPL_TIMEOUT_MINS * 60 * 1000)])) + client.admin.command( + bson.SON([ + ("replSetTest", 1), + ("waitForMemberState", 2), # 2 = SECONDARY + ("timeoutMillis", fixture.ReplFixture.AWAIT_REPL_TIMEOUT_MINS * 60 * 1000) + ])) except pymongo.errors.OperationFailure as err: self.logger.exception( "mongod on port %d failed to reach state SECONDARY after %d seconds", - secondary.port, - fixture.ReplFixture.AWAIT_REPL_TIMEOUT_MINS * 60) + secondary.port, fixture.ReplFixture.AWAIT_REPL_TIMEOUT_MINS * 60) raise errors.ServerFailure( "mongod on port {} failed to reach state SECONDARY after {} seconds: {}".format( secondary.port, fixture.ReplFixture.AWAIT_REPL_TIMEOUT_MINS * 60, err.args[0])) diff --git a/buildscripts/resmokelib/testing/hooks/stepdown.py b/buildscripts/resmokelib/testing/hooks/stepdown.py index 04db8ae6adc..9e6e99d6663 100644 --- a/buildscripts/resmokelib/testing/hooks/stepdown.py +++ b/buildscripts/resmokelib/testing/hooks/stepdown.py @@ -24,11 +24,8 @@ class ContinuousStepdown(interface.Hook): DESCRIPTION = ("Continuous stepdown (steps down the primary of replica sets at regular" " intervals)") - def __init__(self, hook_logger, fixture, - config_stepdown=True, - shard_stepdown=True, - stepdown_duration_secs=10, - stepdown_interval_ms=8000): + def __init__(self, hook_logger, fixture, config_stepdown=True, shard_stepdown=True, + stepdown_duration_secs=10, stepdown_interval_ms=8000): """Initializes the ContinuousStepdown. Args: @@ -39,8 +36,7 @@ class ContinuousStepdown(interface.Hook): stepdown_duration_secs: the number of seconds to step down the primary. stepdown_interval_ms: the number of milliseconds between stepdowns. """ - interface.Hook.__init__(self, hook_logger, fixture, - ContinuousStepdown.DESCRIPTION) + interface.Hook.__init__(self, hook_logger, fixture, ContinuousStepdown.DESCRIPTION) self._fixture = fixture self._config_stepdown = config_stepdown @@ -190,17 +186,18 @@ class _StepdownThread(threading.Thread): # We'll try again after self._stepdown_interval_secs seconds. return - self.logger.info("Stepping down the primary on port %d of replica set '%s'.", - primary.port, rs_fixture.replset_name) + self.logger.info("Stepping down the primary on port %d of replica set '%s'.", primary.port, + rs_fixture.replset_name) secondaries = rs_fixture.get_secondaries() try: client = primary.mongo_client() - client.admin.command(bson.SON([ - ("replSetStepDown", self._stepdown_duration_secs), - ("force", True), - ])) + client.admin.command( + bson.SON([ + ("replSetStepDown", self._stepdown_duration_secs), + ("force", True), + ])) except pymongo.errors.AutoReconnect: # AutoReconnect exceptions are expected as connections are closed during stepdown. pass diff --git a/buildscripts/resmokelib/testing/hooks/validate.py b/buildscripts/resmokelib/testing/hooks/validate.py index 66a5d6ec6db..24c9323342f 100644 --- a/buildscripts/resmokelib/testing/hooks/validate.py +++ b/buildscripts/resmokelib/testing/hooks/validate.py @@ -15,12 +15,9 @@ class ValidateCollections(jsfile.JSHook): 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, hook_logger, fixture, shell_options=None): description = "Full collection validation" js_filename = os.path.join("jstests", "hooks", "run_validate_collections.js") - jsfile.JSHook.__init__(self, - hook_logger, - fixture, - js_filename, - description, + jsfile.JSHook.__init__(self, hook_logger, fixture, js_filename, description, shell_options=shell_options) diff --git a/buildscripts/resmokelib/testing/job.py b/buildscripts/resmokelib/testing/job.py index 6a8b98e3e36..33831f4e84c 100644 --- a/buildscripts/resmokelib/testing/job.py +++ b/buildscripts/resmokelib/testing/job.py @@ -110,8 +110,8 @@ class Job(object): test.shortDescription()) self.report.setFailure(test, return_code=2) # Always fail fast if the fixture fails. - raise errors.StopExecution("%s not running after %s" % - (self.fixture, test.shortDescription())) + raise errors.StopExecution("%s not running after %s" % (self.fixture, + test.shortDescription())) finally: success = self.report._find_test_info(test).status == "pass" if self.archival: diff --git a/buildscripts/resmokelib/testing/report.py b/buildscripts/resmokelib/testing/report.py index 197db9328c5..f13cfdc9a84 100644 --- a/buildscripts/resmokelib/testing/report.py +++ b/buildscripts/resmokelib/testing/report.py @@ -113,8 +113,8 @@ class TestReport(unittest.TestResult): self.num_dynamic += 1 # Set up the test-specific logger. - test_logger = self.job_logger.new_test_logger(test.short_name(), test.basename(), - command, test.logger) + test_logger = self.job_logger.new_test_logger(test.short_name(), test.basename(), command, + test.logger) test_info.url_endpoint = test_logger.url_endpoint test.override_logger(test_logger) diff --git a/buildscripts/resmokelib/testing/suite.py b/buildscripts/resmokelib/testing/suite.py index 59a88f33d72..07d72cb65b4 100644 --- a/buildscripts/resmokelib/testing/suite.py +++ b/buildscripts/resmokelib/testing/suite.py @@ -105,15 +105,19 @@ class Suite(object): if self.options.include_tags is not None: if "include_tags" in selector: - selector["include_tags"] = {"$allOf": [ - selector["include_tags"], - self.options.include_tags, - ]} + selector["include_tags"] = { + "$allOf": [ + selector["include_tags"], + self.options.include_tags, + ] + } elif "exclude_tags" in selector: - selector["exclude_tags"] = {"$anyOf": [ - selector["exclude_tags"], - {"$not": self.options.include_tags}, - ]} + selector["exclude_tags"] = { + "$anyOf": [ + selector["exclude_tags"], + {"$not": self.options.include_tags}, + ] + } else: selector["include_tags"] = self.options.include_tags @@ -267,11 +271,8 @@ class Suite(object): for iteration in xrange(num_iterations): # Summarize each execution as a bulleted list of results. bulleter_sb = [] - summary = self._summarize_report( - reports[iteration], - start_times[iteration], - end_times[iteration], - bulleter_sb) + summary = self._summarize_report(reports[iteration], start_times[iteration], + end_times[iteration], bulleter_sb) combined_summary = _summary.combine(combined_summary, summary) for (i, line) in enumerate(bulleter_sb): @@ -288,10 +289,8 @@ class Suite(object): string builder 'sb'. """ - return self._summarize_report(self._reports[iteration], - self._test_start_times[iteration], - self._test_end_times[iteration], - sb) + return self._summarize_report(self._reports[iteration], self._test_start_times[iteration], + self._test_end_times[iteration], sb) def _summarize_report(self, report, start_time, end_time, sb): """ @@ -335,8 +334,8 @@ class Suite(object): @staticmethod def log_summaries(logger, suites, time_taken): sb = [] - sb.append("Summary of all suites: %d suites ran in %0.2f seconds" - % (len(suites), time_taken)) + sb.append("Summary of all suites: %d suites ran in %0.2f seconds" % (len(suites), + time_taken)) for suite in suites: suite_sb = [] suite.summarize(suite_sb) diff --git a/buildscripts/resmokelib/testing/summary.py b/buildscripts/resmokelib/testing/summary.py index bb44472caa4..cf3649c3e16 100644 --- a/buildscripts/resmokelib/testing/summary.py +++ b/buildscripts/resmokelib/testing/summary.py @@ -6,10 +6,9 @@ from __future__ import absolute_import import collections - - -Summary = collections.namedtuple("Summary", ["num_run", "time_taken", "num_succeeded", - "num_skipped", "num_failed", "num_errored"]) +Summary = collections.namedtuple( + "Summary", + ["num_run", "time_taken", "num_succeeded", "num_skipped", "num_failed", "num_errored"]) def combine(summary1, summary2): diff --git a/buildscripts/resmokelib/testing/testcases/__init__.py b/buildscripts/resmokelib/testing/testcases/__init__.py index 047b5c1f3f0..a397c04fda6 100644 --- a/buildscripts/resmokelib/testing/testcases/__init__.py +++ b/buildscripts/resmokelib/testing/testcases/__init__.py @@ -7,7 +7,6 @@ from __future__ import absolute_import from .interface import make_test_case from ...utils import autoloader as _autoloader - # We dynamically load all modules in the testcases/ package so that any TestCase classes declared # within them are automatically registered. _autoloader.load_all_modules(name=__name__, path=__path__) diff --git a/buildscripts/resmokelib/testing/testcases/benchmark_test.py b/buildscripts/resmokelib/testing/testcases/benchmark_test.py index ac769adf3a8..5002ea37eb7 100644 --- a/buildscripts/resmokelib/testing/testcases/benchmark_test.py +++ b/buildscripts/resmokelib/testing/testcases/benchmark_test.py @@ -18,10 +18,7 @@ class BenchmarkTestCase(interface.ProcessTestCase): REGISTERED_NAME = "benchmark_test" - def __init__(self, - logger, - program_executable, - program_options=None): + def __init__(self, logger, program_executable, program_options=None): """ Initializes the BenchmarkTestCase with the executable to run. """ @@ -49,9 +46,8 @@ class BenchmarkTestCase(interface.ProcessTestCase): # 3. Override Benchmark options with options set through resmoke's command line. resmoke_bm_options = { - "benchmark_filter": _config.BENCHMARK_FILTER, - "benchmark_list_tests": _config.BENCHMARK_LIST_TESTS, - "benchmark_min_time": _config.BENCHMARK_MIN_TIME, + "benchmark_filter": _config.BENCHMARK_FILTER, "benchmark_list_tests": + _config.BENCHMARK_LIST_TESTS, "benchmark_min_time": _config.BENCHMARK_MIN_TIME, "benchmark_out_format": _config.BENCHMARK_OUT_FORMAT, "benchmark_repetitions": _config.BENCHMARK_REPETITIONS } @@ -69,6 +65,4 @@ class BenchmarkTestCase(interface.ProcessTestCase): return self.bm_executable + ".json" def _make_process(self): - return core.programs.generic_program(self.logger, - [self.bm_executable], - **self.bm_options) + return core.programs.generic_program(self.logger, [self.bm_executable], **self.bm_options) diff --git a/buildscripts/resmokelib/testing/testcases/cpp_integration_test.py b/buildscripts/resmokelib/testing/testcases/cpp_integration_test.py index 82dcd0cb275..b4170581821 100644 --- a/buildscripts/resmokelib/testing/testcases/cpp_integration_test.py +++ b/buildscripts/resmokelib/testing/testcases/cpp_integration_test.py @@ -16,10 +16,7 @@ class CPPIntegrationTestCase(interface.ProcessTestCase): REGISTERED_NAME = "cpp_integration_test" - def __init__(self, - logger, - program_executable, - program_options=None): + def __init__(self, logger, program_executable, program_options=None): """ Initializes the CPPIntegrationTestCase with the executable to run. """ @@ -35,6 +32,5 @@ class CPPIntegrationTestCase(interface.ProcessTestCase): self.program_options["connectionString"] = self.fixture.get_internal_connection_string() def _make_process(self): - return core.programs.generic_program(self.logger, - [self.program_executable], + return core.programs.generic_program(self.logger, [self.program_executable], **self.program_options) diff --git a/buildscripts/resmokelib/testing/testcases/cpp_unittest.py b/buildscripts/resmokelib/testing/testcases/cpp_unittest.py index b287db64057..96f20796911 100644 --- a/buildscripts/resmokelib/testing/testcases/cpp_unittest.py +++ b/buildscripts/resmokelib/testing/testcases/cpp_unittest.py @@ -16,10 +16,7 @@ class CPPUnitTestCase(interface.ProcessTestCase): REGISTERED_NAME = "cpp_unit_test" - def __init__(self, - logger, - program_executable, - program_options=None): + def __init__(self, logger, program_executable, program_options=None): """ Initializes the CPPUnitTestCase with the executable to run. """ @@ -30,6 +27,4 @@ class CPPUnitTestCase(interface.ProcessTestCase): self.program_options = utils.default_if_none(program_options, {}).copy() def _make_process(self): - return core.process.Process(self.logger, - [self.program_executable], - **self.program_options) + return core.process.Process(self.logger, [self.program_executable], **self.program_options) diff --git a/buildscripts/resmokelib/testing/testcases/dbtest.py b/buildscripts/resmokelib/testing/testcases/dbtest.py index 8e7861782ea..15316a0f197 100644 --- a/buildscripts/resmokelib/testing/testcases/dbtest.py +++ b/buildscripts/resmokelib/testing/testcases/dbtest.py @@ -21,11 +21,7 @@ class DBTestCase(interface.ProcessTestCase): REGISTERED_NAME = "db_test" - def __init__(self, - logger, - dbtest_suite, - dbtest_executable=None, - dbtest_options=None): + def __init__(self, logger, dbtest_suite, dbtest_executable=None, dbtest_options=None): """ Initializes the DBTestCase with the dbtest suite to run. """ @@ -62,10 +58,8 @@ class DBTestCase(interface.ProcessTestCase): shutil.rmtree(self.dbtest_options["dbpath"], ignore_errors=True) def _make_process(self): - return core.programs.dbtest_program(self.logger, - executable=self.dbtest_executable, - suites=[self.dbtest_suite], - **self.dbtest_options) + return core.programs.dbtest_program(self.logger, executable=self.dbtest_executable, + suites=[self.dbtest_suite], **self.dbtest_options) @staticmethod def _get_dbpath_prefix(): diff --git a/buildscripts/resmokelib/testing/testcases/fsm_workload_test.py b/buildscripts/resmokelib/testing/testcases/fsm_workload_test.py index a1127136b3c..0d397200cfc 100644 --- a/buildscripts/resmokelib/testing/testcases/fsm_workload_test.py +++ b/buildscripts/resmokelib/testing/testcases/fsm_workload_test.py @@ -15,21 +15,13 @@ class FSMWorkloadTestCase(jsrunnerfile.JSRunnerFileTestCase): REGISTERED_NAME = "fsm_workload_test" - def __init__(self, - logger, - fsm_workload, - shell_executable=None, - shell_options=None): + def __init__(self, logger, fsm_workload, shell_executable=None, shell_options=None): """Initializes the FSMWorkloadTestCase with the FSM workload file.""" jsrunnerfile.JSRunnerFileTestCase.__init__( - self, - logger, - "FSM workload", - fsm_workload, + self, logger, "FSM workload", fsm_workload, test_runner_file="jstests/concurrency/fsm_libs/resmoke_runner.js", - shell_executable=shell_executable, - shell_options=shell_options) + shell_executable=shell_executable, shell_options=shell_options) @property def fsm_workload(self): diff --git a/buildscripts/resmokelib/testing/testcases/interface.py b/buildscripts/resmokelib/testing/testcases/interface.py index c7ed470f252..f66abef0f3b 100644 --- a/buildscripts/resmokelib/testing/testcases/interface.py +++ b/buildscripts/resmokelib/testing/testcases/interface.py @@ -12,7 +12,6 @@ import unittest from ... import logging from ...utils import registry - _TEST_CASES = {} @@ -139,8 +138,8 @@ class ProcessTestCase(TestCase): # pylint: disable=abstract-method except self.failureException: raise except: - self.logger.exception("Encountered an error running %s %s", - self.test_kind, self.basename()) + self.logger.exception("Encountered an error running %s %s", self.test_kind, + self.basename()) raise def as_command(self): diff --git a/buildscripts/resmokelib/testing/testcases/json_schema_test.py b/buildscripts/resmokelib/testing/testcases/json_schema_test.py index 24ad11e9b5a..8380b246bf6 100644 --- a/buildscripts/resmokelib/testing/testcases/json_schema_test.py +++ b/buildscripts/resmokelib/testing/testcases/json_schema_test.py @@ -15,21 +15,13 @@ class JSONSchemaTestCase(jsrunnerfile.JSRunnerFileTestCase): REGISTERED_NAME = "json_schema_test" - def __init__(self, - logger, - json_filename, - shell_executable=None, - shell_options=None): + def __init__(self, logger, json_filename, shell_executable=None, shell_options=None): """Initializes the JSONSchemaTestCase with the JSON test file.""" jsrunnerfile.JSRunnerFileTestCase.__init__( - self, - logger, - "JSON Schema test", - json_filename, + self, logger, "JSON Schema test", json_filename, test_runner_file="jstests/libs/json_schema_test_runner.js", - shell_executable=shell_executable, - shell_options=shell_options) + shell_executable=shell_executable, shell_options=shell_options) @property def json_filename(self): diff --git a/buildscripts/resmokelib/testing/testcases/jsrunnerfile.py b/buildscripts/resmokelib/testing/testcases/jsrunnerfile.py index 070784a1c6e..45a9e5d4944 100644 --- a/buildscripts/resmokelib/testing/testcases/jsrunnerfile.py +++ b/buildscripts/resmokelib/testing/testcases/jsrunnerfile.py @@ -16,12 +16,7 @@ class JSRunnerFileTestCase(interface.ProcessTestCase): REGISTERED_NAME = registry.LEAVE_UNREGISTERED - def __init__(self, - logger, - test_kind, - test_name, - test_runner_file, - shell_executable=None, + def __init__(self, logger, test_kind, test_name, test_runner_file, shell_executable=None, shell_options=None): """Initializes the JSRunnerFileTestCase with the 'test_name' file.""" @@ -53,8 +48,6 @@ class JSRunnerFileTestCase(interface.ProcessTestCase): def _make_process(self): return core.programs.mongo_shell_program( - self.logger, - executable=self.shell_executable, + self.logger, executable=self.shell_executable, connection_string=self.fixture.get_driver_connection_url(), - filename=self.test_runner_file, - **self.shell_options) + filename=self.test_runner_file, **self.shell_options) diff --git a/buildscripts/resmokelib/testing/testcases/jstest.py b/buildscripts/resmokelib/testing/testcases/jstest.py index b8320dcaba0..747e43fe01f 100644 --- a/buildscripts/resmokelib/testing/testcases/jstest.py +++ b/buildscripts/resmokelib/testing/testcases/jstest.py @@ -24,11 +24,7 @@ class _SingleJSTestCase(interface.ProcessTestCase): REGISTERED_NAME = registry.LEAVE_UNREGISTERED - def __init__(self, - logger, - js_filename, - shell_executable=None, - shell_options=None): + def __init__(self, logger, js_filename, shell_executable=None, shell_options=None): """ Initializes the _SingleJSTestCase with the JS file to run. """ @@ -114,17 +110,13 @@ class _SingleJSTestCase(interface.ProcessTestCase): data_dir_prefix = utils.default_if_none(config.DBPATH_PREFIX, global_vars.get("MongoRunner.dataDir")) data_dir_prefix = utils.default_if_none(data_dir_prefix, config.DEFAULT_DBPATH_PREFIX) - return os.path.join(data_dir_prefix, - "job%d" % self.fixture.job_num, + return os.path.join(data_dir_prefix, "job%d" % self.fixture.job_num, config.MONGO_RUNNER_SUBDIR) def _make_process(self): return core.programs.mongo_shell_program( - self.logger, - executable=self.shell_executable, - filename=self.js_filename, - connection_string=self.fixture.get_driver_connection_url(), - **self.shell_options) + self.logger, executable=self.shell_executable, filename=self.js_filename, + connection_string=self.fixture.get_driver_connection_url(), **self.shell_options) class JSTestCase(interface.ProcessTestCase): @@ -151,11 +143,7 @@ class JSTestCase(interface.ProcessTestCase): DEFAULT_CLIENT_NUM = 1 - def __init__(self, - logger, - js_filename, - shell_executable=None, - shell_options=None): + def __init__(self, logger, js_filename, shell_executable=None, shell_options=None): """ Initializes the JSTestCase with the JS file to run. """ @@ -204,10 +192,8 @@ class JSTestCase(interface.ProcessTestCase): """ shell_options = self._get_shell_options_for_thread(thread_id) - test_case = _SingleJSTestCase(logger, - self.test_case_template.js_filename, - self.test_case_template.shell_executable, - shell_options) + test_case = _SingleJSTestCase(logger, self.test_case_template.js_filename, + self.test_case_template.shell_executable, shell_options) test_case.configure(self.fixture) return test_case @@ -253,9 +239,8 @@ class JSTestCase(interface.ProcessTestCase): if thread.exc_info is not None: if not isinstance(thread.exc_info[1], self.failureException): self.logger.error( - "Encountered an error inside thread %d running jstest %s.", - thread_id, self.basename(), - exc_info=thread.exc_info) + "Encountered an error inside thread %d running jstest %s.", thread_id, + self.basename(), exc_info=thread.exc_info) raise thread.exc_info def run_test(self): diff --git a/buildscripts/resmokelib/testing/testcases/mongos_test.py b/buildscripts/resmokelib/testing/testcases/mongos_test.py index ef29069a7eb..64b39a32cd9 100644 --- a/buildscripts/resmokelib/testing/testcases/mongos_test.py +++ b/buildscripts/resmokelib/testing/testcases/mongos_test.py @@ -17,9 +17,7 @@ class MongosTestCase(interface.ProcessTestCase): REGISTERED_NAME = "mongos_test" - def __init__(self, - logger, - mongos_options): + def __init__(self, logger, mongos_options): """ Initializes the mongos test and saves the options. """ @@ -41,6 +39,5 @@ class MongosTestCase(interface.ProcessTestCase): self.options["test"] = "" def _make_process(self): - return core.programs.mongos_program(self.logger, - executable=self.mongos_executable, + return core.programs.mongos_program(self.logger, executable=self.mongos_executable, **self.options) diff --git a/buildscripts/resmokelib/testing/testcases/sleeptest.py b/buildscripts/resmokelib/testing/testcases/sleeptest.py index 4f5f695937f..f521ecea870 100644 --- a/buildscripts/resmokelib/testing/testcases/sleeptest.py +++ b/buildscripts/resmokelib/testing/testcases/sleeptest.py @@ -20,8 +20,8 @@ class SleepTestCase(interface.TestCase): sleep_duration_secs = int(sleep_duration_secs) - interface.TestCase.__init__( - self, logger, "Sleep", "{:d} seconds".format(sleep_duration_secs)) + interface.TestCase.__init__(self, logger, "Sleep", + "{:d} seconds".format(sleep_duration_secs)) self.__sleep_duration_secs = sleep_duration_secs |