Flakey test - increase retry tolerance (#41434)

This commit is contained in:
Tim Lee 2026-03-11 06:19:35 -06:00 committed by GitHub
parent e41a9871ac
commit f12a73eeaa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -42,17 +42,18 @@ func TestRetryDo(t *testing.T) {
t.Run("with backoff", func(t *testing.T) {
count := 0
maxAttempts := 4
tolerance := 50 * time.Millisecond // Use a generous tolerance for CI environments where scheduling jitter can occur
start := time.Now()
err := Do(func() error {
switch count {
case 0:
require.WithinDuration(t, start, time.Now(), 1*time.Millisecond)
require.WithinDuration(t, start, time.Now(), tolerance)
case 1:
require.WithinDuration(t, start.Add(50*time.Millisecond), time.Now(), 10*time.Millisecond)
require.WithinDuration(t, start.Add(50*time.Millisecond), time.Now(), tolerance)
case 2:
require.WithinDuration(t, start.Add((50+100)*time.Millisecond), time.Now(), 10*time.Millisecond)
require.WithinDuration(t, start.Add((50+100)*time.Millisecond), time.Now(), tolerance)
case 3:
require.WithinDuration(t, start.Add((50+100+200)*time.Millisecond), time.Now(), 10*time.Millisecond)
require.WithinDuration(t, start.Add((50+100+200)*time.Millisecond), time.Now(), tolerance)
}
count++
if count != maxAttempts {