diff options
Diffstat (limited to 'buildscripts/resmokelib/testing/fixtures')
3 files changed, 43 insertions, 15 deletions
diff --git a/buildscripts/resmokelib/testing/fixtures/interface.py b/buildscripts/resmokelib/testing/fixtures/interface.py index b5838f61a4e..ad75ed17114 100644 --- a/buildscripts/resmokelib/testing/fixtures/interface.py +++ b/buildscripts/resmokelib/testing/fixtures/interface.py @@ -30,6 +30,10 @@ class Fixture(object, metaclass=registry.make_registry_metaclass(_FIXTURES)): # is defined for all subclasses of Fixture. REGISTERED_NAME = "Fixture" + _LAST_STABLE_FCV = "4.2" + _LATEST_FCV = "4.4" + _LAST_STABLE_BIN_VERSION = "4.2" + def __init__(self, logger, job_num, dbpath_prefix=None): """Initialize the fixture with a logger instance.""" diff --git a/buildscripts/resmokelib/testing/fixtures/replicaset.py b/buildscripts/resmokelib/testing/fixtures/replicaset.py index 36619eeac26..3a7a9e26bf8 100644 --- a/buildscripts/resmokelib/testing/fixtures/replicaset.py +++ b/buildscripts/resmokelib/testing/fixtures/replicaset.py @@ -22,11 +22,6 @@ class ReplicaSetFixture(interface.ReplFixture): # pylint: disable=too-many-inst # Error response codes copied from mongo/base/error_codes.err. _NODE_NOT_FOUND = 74 - _LAST_STABLE_FCV = "4.2" - _LATEST_FCV = "4.4" - - _LAST_STABLE_BIN_VERSION = "4.2" - def __init__( # pylint: disable=too-many-arguments, too-many-locals self, logger, job_num, mongod_options=None, dbpath_prefix=None, preserve_dbpath=False, num_nodes=2, start_initial_sync_node=False, write_concern_majority_journal_default=None, @@ -56,13 +51,21 @@ class ReplicaSetFixture(interface.ReplFixture): # pylint: disable=too-many-inst latest_mongod = mongod_executable last_stable_mongod = mongod_executable + "-" \ + ReplicaSetFixture._LAST_STABLE_BIN_VERSION - self.mixed_bin_versions = [ - latest_mongod if x == "new" else last_stable_mongod for x in self.mixed_bin_versions - ] + is_config_svr = "configsvr" in self.replset_config_options and self.replset_config_options[ + "configsvr"] + if not is_config_svr: + self.mixed_bin_versions = [ + latest_mongod if (x == "new") else last_stable_mongod + for x in self.mixed_bin_versions + ] + else: + # Our documented recommended path for upgrading shards lets us assume that config + # server secondaries will always be upgraded before the primary. + self.mixed_bin_versions = [last_stable_mongod, latest_mongod] num_versions = len(self.mixed_bin_versions) - if num_versions != num_nodes: - msg = (("The number of binary versions: {} do not match the number of nodes: "\ - "{}.")).format(num_versions, num_nodes) + if num_versions != num_nodes and not is_config_svr: + msg = (("The number of binary versions specified: {} do not match the number of"\ + " nodes in the replica set: {}.")).format(num_versions, num_nodes) raise errors.ServerFailure(msg) # If voting_secondaries has not been set, set a default. By default, secondaries have zero diff --git a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py index 67991f0cb22..29325870284 100644 --- a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py +++ b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py @@ -26,7 +26,7 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst self, logger, job_num, mongos_executable=None, mongos_options=None, mongod_options=None, dbpath_prefix=None, preserve_dbpath=False, num_shards=1, num_rs_nodes_per_shard=None, num_mongos=1, enable_sharding=None, enable_balancer=True, enable_autosplit=True, - auth_options=None, configsvr_options=None, shard_options=None): + auth_options=None, configsvr_options=None, shard_options=None, mixed_bin_versions=None): """Initialize ShardedClusterFixture with different options for the cluster processes.""" interface.Fixture.__init__(self, logger, job_num, dbpath_prefix=dbpath_prefix) @@ -50,6 +50,14 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst self.auth_options = auth_options self.configsvr_options = utils.default_if_none(configsvr_options, {}) self.shard_options = utils.default_if_none(shard_options, {}) + self.mixed_bin_versions = utils.default_if_none(mixed_bin_versions, + config.MIXED_BIN_VERSIONS) + if self.mixed_bin_versions is not None and num_rs_nodes_per_shard is not None: + num_mongods = self.num_shards * self.num_rs_nodes_per_shard + if len(self.mixed_bin_versions) != num_mongods: + msg = (("The number of binary versions specified: {} do not match the number of"\ + " nodes in the sharded cluster: {}.")).format(len(self.mixed_bin_versions), num_mongods) + raise errors.ServerFailure(msg) self._dbpath_prefix = os.path.join(self._dbpath_prefix, config.FIXTURE_SUBDIR) @@ -250,7 +258,8 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst return replicaset.ReplicaSetFixture( mongod_logger, self.job_num, mongod_options=mongod_options, preserve_dbpath=preserve_dbpath, num_nodes=num_nodes, auth_options=auth_options, - replset_config_options=replset_config_options, **configsvr_options) + mixed_bin_versions=None, replset_config_options=replset_config_options, + **configsvr_options) def _new_rs_shard(self, index, num_rs_nodes_per_shard): """Return a replicaset.ReplicaSetFixture configured as a shard in a sharded cluster.""" @@ -265,6 +274,12 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst replset_config_options = shard_options.pop("replset_config_options", {}) replset_config_options["configsvr"] = False + mixed_bin_versions = self.mixed_bin_versions + if mixed_bin_versions is not None: + start_index = index * num_rs_nodes_per_shard + mixed_bin_versions = mixed_bin_versions[start_index:start_index + + num_rs_nodes_per_shard] + mongod_options = self.mongod_options.copy() mongod_options.update(shard_options.pop("mongod_options", {})) mongod_options["shardsvr"] = "" @@ -275,7 +290,7 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst mongod_logger, self.job_num, 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) + mixed_bin_versions=mixed_bin_versions, **shard_options) def _new_standalone_shard(self, index): """Return a standalone.MongoDFixture configured as a shard in a sharded cluster.""" @@ -313,7 +328,13 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst mongos_options = self.mongos_options.copy() mongos_options["configdb"] = self.configsvr.get_internal_connection_string() - return _MongoSFixture(mongos_logger, self.job_num, mongos_executable=self.mongos_executable, + mongos_executable = utils.default_if_none(config.MONGOS_EXECUTABLE, + config.DEFAULT_MONGOS_EXECUTABLE) + last_stable_executable = mongos_executable + "-" \ + + ShardedClusterFixture._LAST_STABLE_BIN_VERSION + mongos_executable = self.mongos_executable if self.mixed_bin_versions is None else last_stable_executable + + return _MongoSFixture(mongos_logger, self.job_num, mongos_executable=mongos_executable, mongos_options=mongos_options) def _add_shard(self, client, shard): |