summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBlake Oler <blake.oler@mongodb.com>2018-10-22 13:01:18 -0400
committerBlake Oler <blake.oler@mongodb.com>2018-12-28 00:36:19 -0500
commit309a5706ad18c1026cdf4e8b2ae2c4c7b00a4868 (patch)
treef4dca1ed4cc02b769df64a0174ffdf47dce08d8b
parent11f1cd95a26d94bb5c5298ed34c0fd4a857c35c5 (diff)
downloadmongo-309a5706ad18c1026cdf4e8b2ae2c4c7b00a4868.tar.gz
SERVER-37511 Ensure sessions collection is created in replica set fixture
(cherry picked from commit 6c5d1761688ea0c8e13fe62afb3574b5326ae9e6)
-rw-r--r--buildscripts/resmokelib/testing/fixtures/replicaset.py25
1 files changed, 20 insertions, 5 deletions
diff --git a/buildscripts/resmokelib/testing/fixtures/replicaset.py b/buildscripts/resmokelib/testing/fixtures/replicaset.py
index 269dd468303..1aea8140478 100644
--- a/buildscripts/resmokelib/testing/fixtures/replicaset.py
+++ b/buildscripts/resmokelib/testing/fixtures/replicaset.py
@@ -122,11 +122,7 @@ class ReplicaSetFixture(interface.ReplFixture):
config = {"_id": self.replset_name}
client = self.nodes[0].mongo_client()
- 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(client, self.auth_options)
if client.local.system.replset.count():
# Skip initializing the replset if there is an existing configuration.
@@ -196,6 +192,7 @@ class ReplicaSetFixture(interface.ReplFixture):
def await_ready(self):
self._await_primary()
self._await_secondaries()
+ self._setup_sessions_collection()
def _await_primary(self):
# Wait for the primary to be elected.
@@ -230,6 +227,24 @@ class ReplicaSetFixture(interface.ReplFixture):
time.sleep(0.1) # Wait a little bit before trying again.
self.logger.info("Secondary on port %d is now available.", secondary.port)
+ @staticmethod
+ def auth(client, auth_options=None):
+ """Auth a client connection."""
+ if auth_options is not None:
+ auth_db = client[auth_options["authenticationDatabase"]]
+ auth_db.authenticate(auth_options["username"], password=auth_options["password"],
+ mechanism=auth_options["authenticationMechanism"])
+
+ return client
+
+ def _setup_sessions_collection(self):
+ """Set up the sessions collection so that it will not attempt to set up during a test."""
+ primary = self.nodes[0].mongo_client()
+ # Prior to the changes from SERVER-34653, running the refreshLogicalSessionCacheNow
+ # command with a logical session requires being authenticated.
+ self.auth(primary, self.auth_options)
+ primary.admin.command({"refreshLogicalSessionCacheNow": 1})
+
def _do_teardown(self):
running_at_start = self.is_running()
success = True # Still a success even if nothing is running.