2
0

Add TryAcquire to stress test

This commit is contained in:
Jack Christensen
2021-11-27 10:24:10 -06:00
committed by Jack Christensen
parent 69f945a21a
commit 8f8e2d8cfa
+13
View File
@@ -761,6 +761,19 @@ func TestStress(t *testing.T) {
time.Sleep(time.Duration(rand.Int63n(2000)) * time.Nanosecond)
releaseOrDestroyOrHijack(res)
},
// TryAcquire
func() {
res, err := pool.TryAcquire(context.Background())
if err != nil {
if err != puddle.ErrClosedPool && err != puddle.ErrNotAvailable {
assert.Failf(t, "stress TryAcquire", "pool.TryAcquire returned unexpected err: %v", err)
}
return
}
time.Sleep(time.Duration(rand.Int63n(100)) * time.Millisecond)
releaseOrDestroyOrHijack(res)
},
// AcquireAllIdle (though under heavy load this will almost certainly always get an empty slice)
func() {
resources := pool.AcquireAllIdle()