@@ -17,7 +17,6 @@ import (
1717 "time"
1818
1919 "go.mongodb.org/mongo-driver/v2/bson"
20- "go.mongodb.org/mongo-driver/v2/event"
2120 "go.mongodb.org/mongo-driver/v2/internal/assert"
2221 "go.mongodb.org/mongo-driver/v2/internal/integration/mtest"
2322 "go.mongodb.org/mongo-driver/v2/internal/mongoutil"
@@ -599,42 +598,13 @@ func TestSessionsProse(t *testing.T) {
599598
600599 pingOpts := mtest .NewOptions ().
601600 CreateCollection (false ).
602- Topologies (mtest .ReplicaSet , mtest .LoadBalanced )
603- mt .RunOpts ("ping test" , pingOpts , func (mt * mtest.T ) {
604- serverMonitor := & event.ServerMonitor {
605- ServerHeartbeatStarted : func (e * event.ServerHeartbeatStartedEvent ) {
606- fmt .Println ("Server heartbeat started:" , e .ConnectionID )
607- },
608- ServerHeartbeatSucceeded : func (e * event.ServerHeartbeatSucceededEvent ) {
609- fmt .Println ("Server heartbeat succeeded:" , e .ConnectionID , e .Duration , e .Reply )
610- },
611- }
612-
613- commandMonitor := & event.CommandMonitor {
614- Started : func (_ context.Context , cse * event.CommandStartedEvent ) {
615- fmt .Println ("Command started:" , cse .CommandName , cse .Command )
616- },
617- Succeeded : func (_ context.Context , cse * event.CommandSucceededEvent ) {
618- fmt .Println ("Command succeeded:" , cse .CommandName , cse .Reply )
619- },
620- }
621-
622- opts := options .Client ().
601+ ClientOptions (options .Client ().
623602 ApplyURI (mtest .ClusterURI ()).
624- SetHosts ([]string {mtest .ClusterConnString ().Hosts [0 ]}).
625- SetDirect (true ).
626603 SetHeartbeatInterval (500 * time .Millisecond ). // Minimum interval
627- SetServerMonitor (serverMonitor ).
628- SetMonitor (commandMonitor )
629-
630- client , err := mongo .Connect (opts )
631- require .NoError (mt , err , "expected no error connecting to client, got: %v" , err )
632- defer func () {
633- err = client .Disconnect (context .Background ())
634- require .NoError (mt , err , "expected no error disconnecting client, got: %v" , err )
635- }()
636-
637- err = client .Ping (context .Background (), readpref .Primary ())
604+ SetHosts ([]string {mtest .ClusterConnString ().Hosts [0 ]}).
605+ SetDirect (true ))
606+ mt .RunOpts ("ping test" , pingOpts , func (mt * mtest.T ) {
607+ err := mt .Client .Ping (context .Background (), readpref .Primary ())
638608 assert .NoError (mt , err , "expected no error, got: %v" , err )
639609 // mt.Fatal(mtest.ClusterURI(), mtest.ClusterConnString().Hosts, mtest.GlobalTopology().Description().Servers)
640610 })
0 commit comments