@@ -49,17 +49,15 @@ This test applies to drivers with session pools.
49
49
50
50
### 3. ` $clusterTime ` in commands
51
51
52
- - Turn ` heartbeatFrequencyMS ` up to a very large number.
53
52
- Register a command-started and a command-succeeded APM listener. If the driver has no APM support, inspect
54
- commands/replies in another idiomatic way, such as monkey-patching or a mock server.
53
+ commands/replies in another idiomatic way, such as monkey-patching or a mock server.
55
54
- Send a ` ping ` command to the server with the generic ` runCommand ` method.
56
55
- Assert that the command passed to the command-started listener includes ` $clusterTime ` if and only if ` maxWireVersion `
57
- > = 6.
56
+ > = 6.
58
57
- Record the ` $clusterTime ` , if any, in the reply passed to the command-succeeded APM listener.
59
58
- Send another ` ping ` command.
60
59
- Assert that ` $clusterTime ` in the command passed to the command-started listener, if any, equals the ` $clusterTime ` in
61
- the previous server reply. (Turning ` heartbeatFrequencyMS ` up prevents an intervening heartbeat from advancing the
62
- ` $clusterTime ` between these final two steps.)
60
+ the previous server reply.
63
61
64
62
Repeat the above for:
65
63
@@ -70,7 +68,7 @@ Repeat the above for:
70
68
### 4. Explicit and implicit session arguments
71
69
72
70
- Register a command-started APM listener. If the driver has no APM support, inspect commands in another idiomatic way,
73
- such as monkey-patching or a mock server.
71
+ such as monkey-patching or a mock server.
74
72
- Create ` client1 `
75
73
- Get ` database ` from ` client1 `
76
74
- Get ` collection ` from ` database `
@@ -120,9 +118,9 @@ Skip this test if your driver does not allow simultaneous authentication with mu
120
118
- Insert two documents into a collection
121
119
- Execute a find operation on the collection and iterate past the first document
122
120
- Assert that the implicit session is returned to the pool. This can be done in several ways:
123
- - Track in-use count in the server session pool and assert that the count has dropped to zero
124
- - Track the lsid used for the find operation (e.g. with APM) and then do another operation and assert that the same
125
- lsid is used as for the find operation.
121
+ - Track in-use count in the server session pool and assert that the count has dropped to zero
122
+ - Track the lsid used for the find operation (e.g. with APM) and then do another operation and assert that the same
123
+ lsid is used as for the find operation.
126
124
127
125
### 9. Client-side cursor that exhausts the results after a ` getMore ` immediately returns the implicit session to the pool
128
126
@@ -169,32 +167,32 @@ Skip this test if your driver does not allow forking.
169
167
### 14. Implicit sessions only allocate their server session after a successful connection checkout
170
168
171
169
- Create a MongoClient with the following options: ` maxPoolSize=1 ` and ` retryWrites=true ` . If testing against a sharded
172
- deployment, the test runner MUST ensure that the MongoClient connects to only a single mongos host.
170
+ deployment, the test runner MUST ensure that the MongoClient connects to only a single mongos host.
173
171
- Attach a command started listener that collects each command's lsid
174
172
- Initiate the following concurrent operations
175
- - ` insertOne({ }), `
176
- - ` deleteOne({ }), `
177
- - ` updateOne({ }, { $set: { a: 1 } }), `
178
- - ` bulkWrite([{ updateOne: { filter: { }, update: { $set: { a: 1 } } } }]), `
179
- - ` findOneAndDelete({ }), `
180
- - ` findOneAndUpdate({ }, { $set: { a: 1 } }), `
181
- - ` findOneAndReplace({ }, { a: 1 }), `
182
- - ` find().toArray() `
173
+ - ` insertOne({ }), `
174
+ - ` deleteOne({ }), `
175
+ - ` updateOne({ }, { $set: { a: 1 } }), `
176
+ - ` bulkWrite([{ updateOne: { filter: { }, update: { $set: { a: 1 } } } }]), `
177
+ - ` findOneAndDelete({ }), `
178
+ - ` findOneAndUpdate({ }, { $set: { a: 1 } }), `
179
+ - ` findOneAndReplace({ }, { a: 1 }), `
180
+ - ` find().toArray() `
183
181
- Wait for all operations to complete successfully
184
182
- Assert the following across at least 5 retries of the above test:
185
- - Drivers MUST assert that exactly one session is used for all operations at least once across the retries of this
186
- test.
187
- - Note that it's possible, although rare, for >1 server session to be used because the session is not released until
188
- after the connection is checked in.
189
- - Drivers MUST assert that the number of allocated sessions is strictly less than the number of concurrent operations
190
- in every retry of this test. In this instance it would be less than (but NOT equal to) 8.
183
+ - Drivers MUST assert that exactly one session is used for all operations at least once across the retries of this
184
+ test.
185
+ - Note that it's possible, although rare, for >1 server session to be used because the session is not released until
186
+ after the connection is checked in.
187
+ - Drivers MUST assert that the number of allocated sessions is strictly less than the number of concurrent operations
188
+ in every retry of this test. In this instance it would be less than (but NOT equal to) 8.
191
189
192
190
### 15. ` lsid ` is added inside ` $query ` when using OP_QUERY
193
191
194
192
This test only applies to drivers that have not implemented OP_MSG and still use OP_QUERY.
195
193
196
194
- For a command to a mongos that includes a readPreference, verify that the ` lsid ` on query commands is added inside the
197
- ` $query ` field, and NOT as a top-level field.
195
+ ` $query ` field, and NOT as a top-level field.
198
196
199
197
### 16. Authenticating as a second user after starting a session results in a server error
200
198
@@ -238,8 +236,23 @@ and configure a `MongoClient` with default options.
238
236
- Attempt to send a write command to the server (e.g., ` insertOne ` ) with the explicit session passed in
239
237
- Assert that a client-side error is generated indicating that sessions are not supported
240
238
239
+ ### 20. Drivers do not gossip ` $clusterTime ` on SDAM commands.
240
+
241
+ - Skip this test when connected to a deployment that does not support cluster times
242
+ - Create a client, C1, directly connected to a writable server and a small heartbeatFrequencyMS
243
+ - ` c1 = MongoClient(directConnection=True, heartbeatFrequencyMS=10) `
244
+ - Run a ping command using C1 and record the ` $clusterTime ` in the response, as ` clusterTime ` .
245
+ - ` clusterTime = c1.admin.command({"ping": 1})["$clusterTime"] `
246
+ - Using a separate client, C2, run an insert to advance the cluster time
247
+ - ` c2.test.test.insert_one({"advance": "$clusterTime"}) `
248
+ - Next, wait until the client C1 processes the next pair of SDAM heartbeat started + succeeded events.
249
+ - If possible, assert the SDAM heartbeats do not send ` $clusterTime `
250
+ - Run a ping command using C1 and assert that ` $clusterTime ` sent is the same as the ` clusterTime ` recorded earlier.
251
+ This assertion proves that C1's ` $clusterTime ` was not advanced by gossiping through SDAM.
252
+
241
253
## Changelog
242
254
255
+ - 2025-02-24: Test drivers do not gossip $clusterTime on SDAM.
243
256
- 2024-05-08: Migrated from reStructuredText to Markdown.
244
257
- 2019-05-15: Initial version.
245
258
- 2021-06-15: Added snapshot-session tests. Introduced legacy and unified folders.
0 commit comments