This commit is contained in:
2026-11-12 17:28:28 +03:00
parent 276dbdad8a
commit 4fae7d7e87
103 changed files with 10742 additions and 54 deletions
+29
View File
@@ -0,0 +1,29 @@
package jobs
import (
"testing"
"time"
)
func TestRetryBackoffJitterAndCap(t *testing.T) {
for attempt := 1; attempt <= 12; attempt++ {
base := time.Second
for i := 1; i < attempt && base < 60*time.Second; i++ {
base *= 2
}
if base > 60*time.Second {
base = 60 * time.Second
}
values := map[time.Duration]bool{}
for i := 0; i < 50; i++ {
d := RetryDelay(attempt)
if d < base/2 || d > base {
t.Fatalf("attempt=%d delay=%s", attempt, d)
}
values[d] = true
}
if len(values) < 2 {
t.Fatal("jitter absent")
}
}
}