@@ -9,6 +9,7 @@ package integration
99import (
1010 "context"
1111 "errors"
12+ "log"
1213 "os"
1314 "testing"
1415 "time"
@@ -319,18 +320,18 @@ func parseMaxAwaitTime(mt *mtest.T, evt *event.CommandStartedEvent) int64 {
319320 return got
320321}
321322
322- func tadcFindFactory (ctx context.Context , mt * mtest.T ) ( * mongo.Cursor , func () error ) {
323+ func tadcFindFactory (ctx context.Context , mt * mtest.T ) * mongo.Cursor {
323324 mt .Helper ()
324325
325326 initCollection (mt , mt .Coll )
326327 cur , err := mt .Coll .Find (ctx , bson.D {{"x" , 1 }},
327328 options .Find ().SetBatchSize (1 ).SetCursorType (options .TailableAwait ))
328329 require .NoError (mt , err , "Find error: %v" , err )
329330
330- return cur , func () error { return cur . Close ( context . Background ()) }
331+ return cur
331332}
332333
333- func tadcAggregateFactory (ctx context.Context , mt * mtest.T ) ( * mongo.Cursor , func () error ) {
334+ func tadcAggregateFactory (ctx context.Context , mt * mtest.T ) * mongo.Cursor {
334335 mt .Helper ()
335336
336337 initCollection (mt , mt .Coll )
@@ -341,10 +342,10 @@ func tadcAggregateFactory(ctx context.Context, mt *mtest.T) (*mongo.Cursor, func
341342 cursor , err := mt .Coll .Aggregate (ctx , pipe , opts )
342343 require .NoError (mt , err , "Aggregate error: %v" , err )
343344
344- return cursor , func () error { return cursor . Close ( context . Background ()) }
345+ return cursor
345346}
346347
347- func tadcRunCommandCursorFactory (ctx context.Context , mt * mtest.T ) ( * mongo.Cursor , func () error ) {
348+ func tadcRunCommandCursorFactory (ctx context.Context , mt * mtest.T ) * mongo.Cursor {
348349 mt .Helper ()
349350
350351 initCollection (mt , mt .Coll )
@@ -358,7 +359,7 @@ func tadcRunCommandCursorFactory(ctx context.Context, mt *mtest.T) (*mongo.Curso
358359 })
359360 require .NoError (mt , err , "RunCommandCursor error: %v" , err )
360361
361- return cur , func () error { return cur . Close ( context . Background ()) }
362+ return cur
362363}
363364
364365// For tailable awaitData cursors, the maxTimeMS for a getMore should be
@@ -369,17 +370,17 @@ func TestCursor_tailableAwaitData_applyRemainingTimeout(t *testing.T) {
369370 const timeout = 2000 * time .Millisecond
370371
371372 // Setup mtest instance.
372- mt := mtest .New (t , mtest .NewOptions ().CreateClient (false ))
373+ mt := mtest .New (t , mtest .NewOptions ().CreateClient (false ). MinServerVersion ( "4.2" ) )
373374
374375 cappedOpts := options .CreateCollection ().SetCapped (true ).
375376 SetSizeInBytes (1024 * 64 )
376377
377- // TODO(SERVER-96344 ): mongos doesn't honor a failpoint's full blockTimeMS.
378+ // TODO(GODRIVER-3328 ): mongos doesn't honor a failpoint's full blockTimeMS.
378379 baseTopologies := []mtest.TopologyKind {mtest .Single , mtest .LoadBalanced , mtest .ReplicaSet }
379380
380381 type testCase struct {
381382 name string
382- factory func (ctx context.Context , mt * mtest.T ) ( * mongo.Cursor , func () error )
383+ factory func (ctx context.Context , mt * mtest.T ) * mongo.Cursor
383384 opTimeout bool
384385 topologies []mtest.TopologyKind
385386
@@ -463,8 +464,8 @@ func TestCursor_tailableAwaitData_applyRemainingTimeout(t *testing.T) {
463464 defer cancel ()
464465 }
465466
466- cur , cleanup := tc .factory (ctx , mt )
467- defer func () { assert .NoError (mt , cleanup ( )) }()
467+ cur := tc .factory (ctx , mt )
468+ defer func () { assert .NoError (mt , cur . Close ( context . Background () )) }()
468469
469470 require .NoError (mt , cur .Err ())
470471
@@ -475,7 +476,9 @@ func TestCursor_tailableAwaitData_applyRemainingTimeout(t *testing.T) {
475476 }
476477
477478 mt .ClearEvents ()
479+
478480 assert .False (mt , cur .Next (ctx ))
481+ log .Printf ("cursor error: %v" , cur .Err ())
479482
480483 require .Error (mt , cur .Err (), "expected error from cursor.Next" )
481484 assert .ErrorIs (mt , cur .Err (), context .DeadlineExceeded , "expected context deadline exceeded error" )
0 commit comments