Skip to content

Commit b05f4ba

Browse files
committed
test: extend timeout to avoid flaky test
1 parent 024189d commit b05f4ba

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

internal/deliverymq/retry_test.go

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ func TestDeliveryMQRetry_EligibleForRetryTrue(t *testing.T) {
154154
// - Third attempt succeeds
155155
// - Should attempt exactly 3 times
156156

157-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
157+
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
158158
defer cancel()
159159

160160
// Setup test data
@@ -284,7 +284,7 @@ func TestDeliveryMQRetry_RetryMaxCount(t *testing.T) {
284284
// - RetryMaxCount is 2 (allowing 1 initial + 2 retries = 3 total attempts)
285285
// - Should stop after max retries even though errors continue
286286

287-
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
287+
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
288288
defer cancel()
289289

290290
// Setup test data
@@ -341,6 +341,11 @@ func TestDeliveryMQRetry_RetryMaxCount(t *testing.T) {
341341
}
342342
require.NoError(t, suite.deliveryMQ.Publish(ctx, deliveryEvent))
343343

344-
<-ctx.Done()
344+
// Poll until we get 3 attempts or timeout
345+
// Need to wait for: initial attempt + 1s backoff + retry + 1s backoff + retry = ~2.5s minimum
346+
require.Eventually(t, func() bool {
347+
return publisher.Current() >= 3
348+
}, 10*time.Second, 100*time.Millisecond, "should complete 3 attempts (1 initial + 2 retries)")
349+
345350
assert.Equal(t, 3, publisher.Current(), "should stop after max retries (1 initial + 2 retries = 3 total attempts)")
346351
}

0 commit comments

Comments
 (0)