Skip to content

Commit dabf9b6

Browse files
authored
GODRIVER-1949 add more ignored killAllSessions errors for unified tes… (#658)
1 parent f41a6ed commit dabf9b6

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

mongo/integration/unified/admin_helpers.go

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,11 @@ import (
1717
"go.mongodb.org/mongo-driver/mongo/options"
1818
)
1919

20-
const (
21-
errorInterrupted int32 = 11601
20+
var (
21+
ignoredKillAllSessionsErrors = []int{
22+
11601, // Interrupted, for SERVER-38335 on server versions below 4.2
23+
13, // Unauthorized, for SERVER-54216 on atlas
24+
}
2225
)
2326

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

3639
err := client.Database("admin").RunCommand(ctx, cmd).Err()
37-
if ce, ok := err.(mongo.CommandError); ok && ce.Code == errorInterrupted {
38-
// Workaround for SERVER-38335 on server versions below 4.2.
39-
err = nil
40+
if se, ok := err.(mongo.ServerError); ok {
41+
for _, code := range ignoredKillAllSessionsErrors {
42+
if se.HasErrorCode(code) {
43+
err = nil
44+
break
45+
}
46+
}
4047
}
4148
return err
4249
}

0 commit comments

Comments
 (0)