diff options
Diffstat (limited to 'buildscripts/resmokelib/testing/fixtures')
5 files changed, 48 insertions, 101 deletions
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()) |