Skip to content
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

GODRIVER-1949 add more ignored killAllSessions errors for unified tes… #658

Merged
merged 2 commits into from
May 11, 2021
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
17 changes: 12 additions & 5 deletions mongo/integration/unified/admin_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ import (
"go.mongodb.org/mongo-driver/mongo/options"
)

const (
errorInterrupted int32 = 11601
var (
ignoredKillAllSessionsErrors = []int{
11601, // Interrupted, for SERVER-38335 on server versions below 4.2
13, // Unauthorized, for SERVER-54216 on atlas
Copy link
Contributor

Choose a reason for hiding this comment

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

So, by ignoring this Unauthorized error, we don't have to verify we aren't connected to an Atlas cluster when calling killAllSessions (i.e. look for mongodb.net in the hostname)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yup, now it'll just ignore that error so the test can continue

}
)

// terminateOpenSessions executes a killAllSessions command to ensure that sesssions left open on the server by a test
Expand All @@ -34,9 +37,13 @@ func terminateOpenSessions(ctx context.Context) error {
}

err := client.Database("admin").RunCommand(ctx, cmd).Err()
if ce, ok := err.(mongo.CommandError); ok && ce.Code == errorInterrupted {
// Workaround for SERVER-38335 on server versions below 4.2.
err = nil
if se, ok := err.(mongo.ServerError); ok {
for _, code := range ignoredKillAllSessionsErrors {
if se.HasErrorCode(code) {
err = nil
break
}
}
}
return err
}
Expand Down