@@ -597,7 +597,10 @@ func TestSessionsProse(t *testing.T) {
597597 })
598598 */
599599
600- mt .Run ("ping test" , func (mt * mtest.T ) {
600+ pingOpts := mtest .NewOptions ().
601+ CreateCollection (false ).
602+ Topologies (mtest .ReplicaSet ) // Read preference isn't sent to standalones so we can test on replica sets.
603+ mt .RunOpts ("ping test" , pingOpts , func (mt * mtest.T ) {
601604 serverMonitor := & event.ServerMonitor {
602605 ServerHeartbeatStarted : func (e * event.ServerHeartbeatStartedEvent ) {
603606 fmt .Println ("Server heartbeat started:" , e .ConnectionID )
@@ -616,10 +619,12 @@ func TestSessionsProse(t *testing.T) {
616619 },
617620 }
618621
622+ firstServerAddr := mtest .GlobalTopology ().Description ().Servers [0 ].Addr
619623 opts := options .Client ().
620- ApplyURI (mtest .ClusterURI ()).
621- // SetHosts([]string{mtest.ClusterConnString().Hosts[0]}).
622- // SetDirect(true).
624+ ApplyURI (fmt .Sprintf ("mongodb://%s" , firstServerAddr )).
625+ SetHeartbeatInterval (500 * time .Millisecond ). // Minimum interval
626+ SetReadPreference (readpref .Primary ()).
627+ SetDirect (true ).
623628 SetHeartbeatInterval (500 * time .Millisecond ). // Minimum interval
624629 SetServerMonitor (serverMonitor ).
625630 SetMonitor (commandMonitor )
@@ -632,7 +637,8 @@ func TestSessionsProse(t *testing.T) {
632637 }()
633638
634639 err = client .Ping (context .Background (), readpref .Primary ())
635- require .NoError (mt , err , "expected no error, got: %v" , err )
640+ assert .NoError (mt , err , "expected no error, got: %v" , err )
641+ // mt.Fatal(mtest.ClusterURI(), mtest.ClusterConnString().Hosts, mtest.GlobalTopology().Description().Servers)
636642 })
637643}
638644
0 commit comments