Skip to content

Commit e28f49c

Browse files
authored
PYTHON-5164 Fix mockupdb TestClusterTime (#2163)
1 parent 080c1c6 commit e28f49c

File tree

1 file changed

+5
-44
lines changed

1 file changed

+5
-44
lines changed

test/mockupdb/test_cluster_time.py

+5-44
Original file line numberDiff line numberDiff line change
@@ -123,50 +123,11 @@ def test_monitor(self):
123123

124124
client = self.simple_client(server.uri, heartbeatFrequencyMS=500)
125125

126-
request = server.receives("ismaster")
127-
# No $clusterTime in first ismaster, only in subsequent ones
128-
self.assertNotIn("$clusterTime", request)
129-
request.ok(reply)
130-
131-
# Next exchange: client returns first clusterTime, we send the second.
132-
request = server.receives("ismaster")
133-
self.assertIn("$clusterTime", request)
134-
self.assertEqual(request["$clusterTime"]["clusterTime"], cluster_time)
135-
cluster_time = Timestamp(cluster_time.time, cluster_time.inc + 1)
136-
reply["$clusterTime"] = {"clusterTime": cluster_time}
137-
request.reply(reply)
138-
139-
# Third exchange: client returns second clusterTime.
140-
request = server.receives("ismaster")
141-
self.assertEqual(request["$clusterTime"]["clusterTime"], cluster_time)
142-
143-
# Return command error with a new clusterTime.
144-
cluster_time = Timestamp(cluster_time.time, cluster_time.inc + 1)
145-
error = {
146-
"ok": 0,
147-
"code": 211,
148-
"errmsg": "Cache Reader No keys found for HMAC ...",
149-
"$clusterTime": {"clusterTime": cluster_time},
150-
}
151-
request.reply(error)
152-
153-
# PyMongo 3.11+ closes the monitoring connection on command errors.
154-
155-
# Fourth exchange: the Monitor closes the connection and runs the
156-
# handshake on a new connection.
157-
request = server.receives("ismaster")
158-
# No $clusterTime in first ismaster, only in subsequent ones
159-
self.assertNotIn("$clusterTime", request)
160-
161-
# Reply without $clusterTime.
162-
reply.pop("$clusterTime")
163-
request.reply(reply)
164-
165-
# Fifth exchange: the Monitor attempt uses the clusterTime from
166-
# the previous isMaster error.
167-
request = server.receives("ismaster")
168-
self.assertEqual(request["$clusterTime"]["clusterTime"], cluster_time)
169-
request.reply(reply)
126+
for _ in range(3):
127+
request = server.receives("ismaster")
128+
# No $clusterTime in heartbeats or handshakes.
129+
self.assertNotIn("$clusterTime", request)
130+
request.ok(reply)
170131
client.close()
171132

172133
def test_collection_bulk_error(self):

0 commit comments

Comments
 (0)