Skip to content

Commit cec2f72

Browse files
authored
GODRIVER-1824 Test that Client waits 500ms between failed Hellos (#838)
1 parent fd76f1c commit cec2f72

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

mongo/integration/sdam_prose_test.go

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,4 +125,34 @@ func TestSDAMProse(t *testing.T) {
125125
assert.Soon(t, callback, defaultCallbackTimeout)
126126
})
127127
})
128+
129+
mt.RunOpts("client waits between failed Hellos", mtest.NewOptions().MinServerVersion("4.9").Topologies(mtest.Single), func(mt *mtest.T) {
130+
// Force hello requests to fail 5 times.
131+
mt.SetFailPoint(mtest.FailPoint{
132+
ConfigureFailPoint: "failCommand",
133+
Mode: mtest.FailPointMode{
134+
Times: 5,
135+
},
136+
Data: mtest.FailPointData{
137+
FailCommands: []string{internal.LegacyHello, "hello"},
138+
ErrorCode: 1234,
139+
AppName: "SDAMMinHeartbeatFrequencyTest",
140+
},
141+
})
142+
143+
// Reset client options to use direct connection, app name, and 5s SS timeout.
144+
clientOpts := options.Client().SetDirect(true).
145+
SetAppName("SDAMMinHeartbeatFrequencyTest").
146+
SetServerSelectionTimeout(5 * time.Second)
147+
mt.ResetClient(clientOpts)
148+
149+
// Assert that Ping completes successfully within 2 to 3.5 seconds.
150+
start := time.Now()
151+
err := mt.Client.Ping(mtest.Background, nil)
152+
assert.Nil(mt, err, "Ping error: %v", err)
153+
pingTime := time.Since(start)
154+
assert.True(mt, pingTime > 2000*time.Millisecond && pingTime < 3500*time.Millisecond,
155+
"expected Ping to take between 2 and 3.5 seconds, took %v seconds", pingTime.Seconds())
156+
157+
})
128158
}

0 commit comments

Comments
 (0)