forked from mtusi2026/mtusi2026lab7
Лабораторная 7
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
package pipeline
|
||||
|
||||
import (
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRetryDelayBounds(t *testing.T) {
|
||||
for attempt := 1; attempt <= 20; attempt++ {
|
||||
bounded := attempt
|
||||
if bounded > 6 {
|
||||
bounded = 6
|
||||
}
|
||||
base := time.Second * time.Duration(1<<uint(bounded-1))
|
||||
for i := 0; i < 100; i++ {
|
||||
got := RetryDelay(attempt)
|
||||
if got < base || got > base+base/2 {
|
||||
t.Fatalf("attempt %d: delay %s outside [%s,%s]", attempt, got, base, base+base/2)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user