Skip to content

GODRIVER-1824 Test that Client waits 500ms between failed Hellos #838

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 19, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions mongo/integration/sdam_prose_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,34 @@ func TestSDAMProse(t *testing.T) {
assert.Soon(t, callback, defaultCallbackTimeout)
})
})

mt.RunOpts("client waits between failed Hellos", mtest.NewOptions().MinServerVersion("4.9").Topologies(mtest.Single), func(mt *mtest.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only running this test against standalones since it's using DirectConnection: true which will error against replica sets and sharded clusters.

// Force hello requests to fail 5 times.
mt.SetFailPoint(mtest.FailPoint{
ConfigureFailPoint: "failCommand",
Mode: mtest.FailPointMode{
Times: 5,
},
Data: mtest.FailPointData{
FailCommands: []string{internal.LegacyHello, "hello"},
ErrorCode: 1234,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this error code important, or can it be any value?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could be any value I think. 1234 was just a placeholder from the spec tests. I could remove it since we don't assert anything about the error code, but I'll probably just leave it in for consistency with other drivers.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I didn't realize that value came directly from the prose test. Should we consider adding links to the relevant prose test or the GODRIVER ticket to keep a record of what tests cover what prose tests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GODRIVER ticket already links to a DRIVERS ticket with the specified prose test. However, I do think our prose tests could be better labeled/numbered, so I filed GODRIVER-2274. Probably out of scope for this PR, though.

AppName: "SDAMMinHeartbeatFrequencyTest",
},
})

// Reset client options to use direct connection, app name, and 5s SS timeout.
clientOpts := options.Client().SetDirect(true).
SetAppName("SDAMMinHeartbeatFrequencyTest").
SetServerSelectionTimeout(5 * time.Second)
mt.ResetClient(clientOpts)

// Assert that Ping completes successfully within 2 to 3.5 seconds.
start := time.Now()
err := mt.Client.Ping(mtest.Background, nil)
assert.Nil(mt, err, "Ping error: %v", err)
pingTime := time.Since(start)
assert.True(mt, pingTime > 2000*time.Millisecond && pingTime < 3500*time.Millisecond,
"expected Ping to take between 2 and 3.5 seconds, took %v seconds", pingTime.Seconds())

})
}