@@ -19,6 +19,7 @@ import (
19
19
"go.mongodb.org/mongo-driver/internal/eventtest"
20
20
"go.mongodb.org/mongo-driver/internal/require"
21
21
"go.mongodb.org/mongo-driver/mongo/address"
22
+ "go.mongodb.org/mongo-driver/x/mongo/driver"
22
23
"go.mongodb.org/mongo-driver/x/mongo/driver/operation"
23
24
)
24
25
@@ -1178,10 +1179,22 @@ func TestPool_PoolMonitor(t *testing.T) {
1178
1179
})
1179
1180
1180
1181
tpm := eventtest .NewTestPoolMonitor ()
1181
- p := newPool (poolConfig {
1182
- Address : address .Address (addr .String ()),
1183
- PoolMonitor : tpm .PoolMonitor ,
1184
- })
1182
+ p := newPool (
1183
+ poolConfig {
1184
+ Address : address .Address (addr .String ()),
1185
+ PoolMonitor : tpm .PoolMonitor ,
1186
+ },
1187
+ // Add a 10ms delay in the handshake so the test is reliable on
1188
+ // operating systems that can't measure very short durations (e.g.
1189
+ // Windows).
1190
+ WithHandshaker (func (Handshaker ) Handshaker {
1191
+ return & testHandshaker {
1192
+ getHandshakeInformation : func (context.Context , address.Address , driver.Connection ) (driver.HandshakeInformation , error ) {
1193
+ time .Sleep (10 * time .Millisecond )
1194
+ return driver.HandshakeInformation {}, nil
1195
+ },
1196
+ }
1197
+ }))
1185
1198
1186
1199
err := p .ready ()
1187
1200
require .NoError (t , err , "ready error" )
0 commit comments