summaryrefslogtreecommitdiff
path: root/buildscripts
diff options
context:
space:
mode:
authorRobert Guo <robert.guo@10gen.com>2018-03-25 22:15:26 -0400
committerRobert Guo <robert.guo@10gen.com>2018-04-12 09:19:28 -0400
commitf15c9b53211757c2aa007d7bb60852bd36bf08be (patch)
treedf2d0d5155ead41e68aab40829b701986b3c6fa0 /buildscripts
parent2896a5c5f79702e22205e2c46020b23fc1d0421f (diff)
downloadmongo-f15c9b53211757c2aa007d7bb60852bd36bf08be.tar.gz
SERVER-34289 add new sharded cluster wrapper for connecting to an existing cluster
Diffstat (limited to 'buildscripts')
-rw-r--r--buildscripts/resmokelib/core/network.py2
-rw-r--r--buildscripts/resmokelib/testing/fixtures/shardedcluster.py50
-rw-r--r--buildscripts/resmokelib/testing/testcases/fsm_workload_test.py3
3 files changed, 34 insertions, 21 deletions
diff --git a/buildscripts/resmokelib/core/network.py b/buildscripts/resmokelib/core/network.py
index f42e6a86d85..b48a2221f01 100644
--- a/buildscripts/resmokelib/core/network.py
+++ b/buildscripts/resmokelib/core/network.py
@@ -51,7 +51,7 @@ class PortAllocator(object):
# The first _PORTS_PER_FIXTURE ports of each range are reserved for the fixtures, the remainder
# of the port range is used by tests.
- _PORTS_PER_FIXTURE = 10
+ _PORTS_PER_FIXTURE = 20
_NUM_USED_PORTS_LOCK = threading.Lock()
diff --git a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
index 5e5662fbd7f..6381bdda58c 100644
--- a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
+++ b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
@@ -27,7 +27,7 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
def __init__( # pylint: disable=too-many-arguments,too-many-locals
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,
+ num_shards=1, num_rs_nodes_per_shard=None, num_mongos=1, separate_configsvr=True,
enable_sharding=None, enable_balancer=True, auth_options=None, configsvr_options=None,
shard_options=None):
"""Initialize ShardedClusterFixture with different options for the cluster processes."""
@@ -44,6 +44,7 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
self.preserve_dbpath = preserve_dbpath
self.num_shards = num_shards
self.num_rs_nodes_per_shard = num_rs_nodes_per_shard
+ self.num_mongos = num_mongos
self.separate_configsvr = separate_configsvr
self.enable_sharding = utils.default_if_none(enable_sharding, [])
self.enable_balancer = enable_balancer
@@ -54,7 +55,7 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
self._dbpath_prefix = os.path.join(self._dbpath_prefix, config.FIXTURE_SUBDIR)
self.configsvr = None
- self.mongos = None
+ self.mongos = []
self.shards = []
def setup(self):
@@ -90,14 +91,17 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
for shard in self.shards:
shard.await_ready()
- if self.mongos is None:
- self.mongos = self._new_mongos()
+ if not self.mongos:
+ for i in range(self.num_mongos):
+ mongos = self._new_mongos(i, self.num_mongos)
- # Start up the mongos
- self.mongos.setup()
+ # Start up the mongos.
+ mongos.setup()
- # Wait for the mongos
- self.mongos.await_ready()
+ # Wait for the mongos.
+ mongos.await_ready()
+
+ self.mongos.append(mongos)
client = self.mongo_client()
if self.auth_options is not None:
@@ -138,8 +142,9 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
if self.configsvr is not None:
teardown_handler.teardown(self.configsvr, "config server")
- if self.mongos is not None:
- teardown_handler.teardown(self.mongos, "mongos")
+ for mongos in self.mongos:
+ teardown_handler.teardown(mongos, "mongos")
+ self.mongos = []
for shard in self.shards:
teardown_handler.teardown(shard, "shard")
@@ -152,16 +157,16 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
def is_running(self):
"""Return true if the all nodes in the cluster are all still operating."""
- 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
+ all(mongos.is_running() for mongos in self.mongos))
def get_internal_connection_string(self):
"""Return the internal connection string."""
if self.mongos is None:
raise ValueError("Must call setup() before calling get_internal_connection_string()")
- return self.mongos.get_internal_connection_string()
+ return ",".join([mongos.get_internal_connection_string() for mongos in self.mongos])
def get_driver_connection_url(self):
"""Return the driver connection URL."""
@@ -240,10 +245,21 @@ class ShardedClusterFixture(interface.Fixture): # pylint: disable=too-many-inst
mongod_logger, self.job_num, mongod_executable=mongod_executable,
mongod_options=mongod_options, preserve_dbpath=preserve_dbpath, **shard_options)
- def _new_mongos(self):
- """Return a _MongoSFixture configured to be used as the mongos for a sharded cluster."""
+ def _new_mongos(self, index, total):
+ """
+ Returns a _MongoSFixture configured to be used as the mongos for a sharded cluster.
+
+ :param index: The index of the current mongos.
+ :param total: The total number of mongos routers
+ :return: _MongoSFixture
+ """
+
+ if total == 1:
+ logger_name = "mongos"
+ else:
+ logger_name = "mongos{}".format(index)
- mongos_logger = self.logger.new_fixture_node_logger("mongos")
+ mongos_logger = self.logger.new_fixture_node_logger(logger_name)
mongos_options = self.mongos_options.copy()
diff --git a/buildscripts/resmokelib/testing/testcases/fsm_workload_test.py b/buildscripts/resmokelib/testing/testcases/fsm_workload_test.py
index 62efc0a5959..91ecd4de13c 100644
--- a/buildscripts/resmokelib/testing/testcases/fsm_workload_test.py
+++ b/buildscripts/resmokelib/testing/testcases/fsm_workload_test.py
@@ -2,9 +2,6 @@
from __future__ import absolute_import
-from buildscripts.resmokelib import config
-from buildscripts.resmokelib import core
-from buildscripts.resmokelib import utils
from buildscripts.resmokelib.testing.testcases import jsrunnerfile