mirror of
https://github.com/safing/portbase
synced 2025-09-01 18:19:57 +00:00
Improve call limiter test
This commit is contained in:
parent
3232f2d644
commit
918841e7ea
1 changed files with 22 additions and 2 deletions
|
@ -62,10 +62,30 @@ func TestCallLimiter(t *testing.T) {
|
|||
}
|
||||
|
||||
testWg.Wait()
|
||||
if execs <= 8 {
|
||||
if execs <= 5 {
|
||||
t.Errorf("unexpected low exec count: %d", execs)
|
||||
}
|
||||
if execs >= 12 {
|
||||
if execs >= 15 {
|
||||
t.Errorf("unexpected high exec count: %d", execs)
|
||||
}
|
||||
|
||||
// Wait for pause to reset.
|
||||
time.Sleep(pause)
|
||||
|
||||
// Check if the limiter correctly handles panics.
|
||||
testWg.Add(100)
|
||||
for i := 0; i < 100; i++ {
|
||||
go func() {
|
||||
defer func() {
|
||||
_ = recover()
|
||||
testWg.Done()
|
||||
}()
|
||||
oa.Do(func() {
|
||||
time.Sleep(1 * time.Millisecond)
|
||||
panic("test")
|
||||
})
|
||||
}()
|
||||
time.Sleep(100 * time.Microsecond)
|
||||
}
|
||||
testWg.Wait()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue