Skip to content

Commit

Permalink
GODRIVER-1875 reduce TestPool test timeout (#582)
Browse files Browse the repository at this point in the history
  • Loading branch information
iwysiu committed Feb 19, 2021
1 parent c3587ec commit 07b0039
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions x/mongo/driver/topology/pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ func TestPool(t *testing.T) {
disconnectDone := make(chan struct{})
_, err = p.get(context.Background())
noerr(t, err)
getCtx, getCancel := context.WithCancel(context.Background())
getCtx, getCancel := context.WithTimeout(context.Background(), 30*time.Second)
defer getCancel()
go func() {
defer close(getDone)
Expand All @@ -226,20 +226,23 @@ func TestPool(t *testing.T) {
return
default:
loopCtx, loopCancel := context.WithTimeout(getCtx, 3*time.Second)
_, _ = p.get(loopCtx)
c, err := p.get(loopCtx)
loopCancel()
if err == nil {
_ = p.put(c)
}
time.Sleep(time.Microsecond)
}
}
}()
go func() {
defer close(disconnectDone)
_, err := p.get(getCtx)
noerr(t, err)
ctx, cancel := context.WithTimeout(context.Background(), 3*time.Microsecond)
defer cancel()
err = p.disconnect(ctx)
noerr(t, err)
close(disconnectDone)
}()
<-getDone
close(cleanup)
Expand Down

0 comments on commit 07b0039

Please sign in to comment.