summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Abrahams <jonathan@mongodb.com>2018-05-29 15:42:01 -0400
committerJonathan Abrahams <jonathan@mongodb.com>2018-05-29 16:50:32 -0400
commitaf3bf993cb481cf6ad6c573e77f6d01e8954fc0d (patch)
tree303d4836db035b31175362b9eb4135f108a2f5da
parent171d883581229adad5eca68e7c14da83f5505ec8 (diff)
downloadmongo-af3bf993cb481cf6ad6c573e77f6d01e8954fc0d.tar.gz
SERVER-35051 Resmoke should stop the balancer before shutting down sharded clusters
-rw-r--r--buildscripts/resmokelib/testing/fixtures/shardedcluster.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
index c0c3624b69a..9a90c5b31e1 100644
--- a/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
+++ b/buildscripts/resmokelib/testing/fixtures/shardedcluster.py
@@ -103,11 +103,7 @@ class ShardedClusterFixture(interface.Fixture):
self.port = self.mongos.port
client = utils.new_mongo_client(port=self.port)
- if self.auth_options is not None:
- auth_db = client[self.auth_options["authenticationDatabase"]]
- auth_db.authenticate(self.auth_options["username"],
- password=self.auth_options["password"],
- mechanism=self.auth_options["authenticationMechanism"])
+ self._auth_to_db(client)
# Inform mongos about each of the shards
for shard in self.shards:
@@ -118,6 +114,20 @@ class ShardedClusterFixture(interface.Fixture):
self.logger.info("Enabling sharding for '%s' database...", db_name)
client.admin.command({"enablesharding": db_name})
+ def _auth_to_db(self, client):
+ """Authenticate client for the 'authenticationDatabase'."""
+ if self.auth_options is not None:
+ auth_db = client[self.auth_options["authenticationDatabase"]]
+ auth_db.authenticate(self.auth_options["username"],
+ password=self.auth_options["password"],
+ mechanism=self.auth_options["authenticationMechanism"])
+
+ def _stop_balancer(self, timeout_ms=60000):
+ """Stop the balancer."""
+ client = utils.new_mongo_client(port=self.port)
+ self._auth_to_db(client)
+ client.admin.command({"balancerStop": 1}, maxTimeMS=timeout_ms)
+
def _do_teardown(self):
"""
Shuts down the sharded cluster.
@@ -129,6 +139,8 @@ class ShardedClusterFixture(interface.Fixture):
self.logger.info(
"Sharded cluster was expected to be running in _do_teardown(), but wasn't.")
+ self._stop_balancer()
+
if self.configsvr is not None:
if running_at_start:
self.logger.info("Stopping config server...")
@@ -149,6 +161,8 @@ class ShardedClusterFixture(interface.Fixture):
if running_at_start:
self.logger.info("Stopping shards...")
+
+
for shard in self.shards:
success = shard.teardown() and success
if running_at_start: