@@ -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