Skip to content

Commit 631fc54

Browse files
committed
util/retry: increase timing tolerance for cancellation tests
The TestRetryWithMaxDuration test was flaky because the timing expectations were too strict for test cases involving context cancellation and closer channel closure. When these cancellation mechanisms are triggered during a retry backoff period, the retry loop may not exit immediately, leading to timing variance that exceeded the previous 20ms limit. Increased maxExpectedTimeSpent from 20ms to 30ms for both: - "errors with context that is canceled" - "errors with opt.Closer that is closed" This provides sufficient buffer for the inherent timing variability while still validating that cancellation works promptly. Fixes #154764
1 parent e9a0b1c commit 631fc54

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/util/retry/retry_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,7 +474,7 @@ func TestRetryWithMaxDuration(t *testing.T) {
474474
preRetryFunc: func() {
475475
cancelCtxFunc()
476476
},
477-
maxExpectedTimeSpent: time.Millisecond * 20,
477+
maxExpectedTimeSpent: time.Millisecond * 30,
478478
expectedErr: true,
479479
// Under duress, closing a context will not necessarily stop the retry
480480
// loop immediately, so we skip this test under duress.
@@ -494,7 +494,7 @@ func TestRetryWithMaxDuration(t *testing.T) {
494494
preRetryFunc: func() {
495495
close(closeCh)
496496
},
497-
maxExpectedTimeSpent: time.Millisecond * 20,
497+
maxExpectedTimeSpent: time.Millisecond * 30,
498498
expectedErr: true,
499499
// Under duress, closing a channel will not necessarily stop the retry
500500
// loop immediately, so we skip this test under duress.

0 commit comments

Comments
 (0)