Skip to content

Commit 07b0039

Browse files
committed
GODRIVER-1875 reduce TestPool test timeout (#582)
1 parent c3587ec commit 07b0039

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

x/mongo/driver/topology/pool_test.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ func TestPool(t *testing.T) {
216216
disconnectDone := make(chan struct{})
217217
_, err = p.get(context.Background())
218218
noerr(t, err)
219-
getCtx, getCancel := context.WithCancel(context.Background())
219+
getCtx, getCancel := context.WithTimeout(context.Background(), 30*time.Second)
220220
defer getCancel()
221221
go func() {
222222
defer close(getDone)
@@ -226,20 +226,23 @@ func TestPool(t *testing.T) {
226226
return
227227
default:
228228
loopCtx, loopCancel := context.WithTimeout(getCtx, 3*time.Second)
229-
_, _ = p.get(loopCtx)
229+
c, err := p.get(loopCtx)
230230
loopCancel()
231+
if err == nil {
232+
_ = p.put(c)
233+
}
231234
time.Sleep(time.Microsecond)
232235
}
233236
}
234237
}()
235238
go func() {
239+
defer close(disconnectDone)
236240
_, err := p.get(getCtx)
237241
noerr(t, err)
238242
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Microsecond)
239243
defer cancel()
240244
err = p.disconnect(ctx)
241245
noerr(t, err)
242-
close(disconnectDone)
243246
}()
244247
<-getDone
245248
close(cleanup)

0 commit comments

Comments
 (0)