diff --git a/mongo/integration/mtest/mongotest.go b/mongo/integration/mtest/mongotest.go index 518959bdbe..70c0f0333d 100644 --- a/mongo/integration/mtest/mongotest.go +++ b/mongo/integration/mtest/mongotest.go @@ -744,13 +744,9 @@ func (t *T) createTestClient() { if err != nil { t.Fatalf("error creating client: %v", err) } - ctx := context.Background() - if err := t.Client.Connect(ctx); err != nil { + if err := t.Client.Connect(context.Background()); err != nil { t.Fatalf("error connecting client: %v", err) } - if err := t.Client.Ping(ctx, nil); err != nil { - t.Fatalf("error pinging client: %v", err) - } } func (t *T) createTestCollection() { diff --git a/mongo/integration/unified_spec_test.go b/mongo/integration/unified_spec_test.go index df2d705132..d26a98c162 100644 --- a/mongo/integration/unified_spec_test.go +++ b/mongo/integration/unified_spec_test.go @@ -312,6 +312,9 @@ func runSpecTestCase(mt *mtest.T, test *testCase, testFile testFile) { testClientOpts.SetHeartbeatInterval(defaultHeartbeatInterval) } mt.ResetClient(testClientOpts) + if err := mt.Client.Ping(context.Background(), nil); err != nil { + assert.Nil(mt, err, "error pinging client") + } // Record the underlying topology for the test's Client. test.testTopology = getTopologyFromClient(mt.Client)