@@ -237,18 +237,30 @@ func TestDatabase(t *testing.T) {
237
237
assert .Nil (mt , err , "expected command %s to contain key 'batchSize'" , evt .Command )
238
238
})
239
239
240
- // The BatchSize option is not honored for ListCollections operations on server version 2.6 due to an
241
- // inconsistency in the legacy OP_QUERY code path (GODRIVER-1937).
242
- cmdMonitoringMtOpts := mtest .NewOptions ().MinServerVersion ("3.0" )
240
+ cmdMonitoringMtOpts := mtest .NewOptions ().MinServerVersion ("2.6" )
243
241
mt .RunOpts ("getMore commands are monitored" , cmdMonitoringMtOpts , func (mt * mtest.T ) {
244
242
createCollections (mt , 2 )
245
- assertGetMoreCommandsAreMonitored (mt , "listCollections" , func () (* mongo.Cursor , error ) {
243
+
244
+ // For server versions below 3.0, we internally execute ListCollections() as a legacy OP_QUERY against the system.namespaces
245
+ // collection. Command monitoring upconversions translate this to a "find" command rather than "listCollections".
246
+ cmdName := "listCollections"
247
+ if mtest .CompareServerVersions (mtest .ServerVersion (), "3.0" ) < 0 {
248
+ cmdName = "find"
249
+ }
250
+ assertGetMoreCommandsAreMonitored (mt , cmdName , func () (* mongo.Cursor , error ) {
246
251
return mt .DB .ListCollections (mtest .Background , bson.D {}, options .ListCollections ().SetBatchSize (2 ))
247
252
})
248
253
})
249
254
mt .RunOpts ("killCursors commands are monitored" , cmdMonitoringMtOpts , func (mt * mtest.T ) {
250
255
createCollections (mt , 2 )
251
- assertKillCursorsCommandsAreMonitored (mt , "listCollections" , func () (* mongo.Cursor , error ) {
256
+
257
+ // For server versions below 3.0, we internally execute ListCollections() as a legacy OP_QUERY against the system.namespaces
258
+ // collection. Command monitoring upconversions translate this to a "find" command rather than "listCollections".
259
+ cmdName := "listCollections"
260
+ if mtest .CompareServerVersions (mtest .ServerVersion (), "3.0" ) < 0 {
261
+ cmdName = "find"
262
+ }
263
+ assertKillCursorsCommandsAreMonitored (mt , cmdName , func () (* mongo.Cursor , error ) {
252
264
return mt .DB .ListCollections (mtest .Background , bson.D {}, options .ListCollections ().SetBatchSize (2 ))
253
265
})
254
266
})
0 commit comments