Repository navigation
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Run the deliverymq retry tests on a fake clock. Based on #1162.
deliverymq was the slowest package in the short suite: its tests ran one after another, each waiting out rsmq visibility timeouts and context deadlines. Everything now runs inside a
synctestbubble (in-memory deliverymq, the retry scheduler ontestutil.NewSynctestRedis,Monitor, mempubsub), with one shared teardown,stopRetryStack. The tests also run in parallel (t.Parallel); none of them touch package-level state.The package now runs in under 1 s.
The conversion surfaced three test bugs:
TestRetryScheduler_EventFetchSuccesswas flaky: it could assert after the 2nd publish but before the 2nd log entry was written (also a data race on the entries).TestDeliveryMQRetry_RetryMaxCountpublished a task withoutAttempt(0); real tasks start at 1, so it made 4 attempts. The old check asserted as soon as it saw 3 and never waited for the 4th. NowAttempt: 1; setting it back to 0 fails with 4 vs 3.mockEventGetter.recordswas written and read without its mutex.Timing choices:
WithRetryNotReadyDelay(time.Second): the 10 s default outlasted the test windows. It only shortens the wait; the tested behavior is the same.RetryMaxCountandEligibleForRetryTrueuse a 2 s backoff instead of 50 ms. Under ~1 s a retry is due at once and can run before the current attempt is logged. The lookup accepts attempts up to 1 s older than the retry's attempt time (retryLookupSkew), so it finds the previous attempt and publishes the current attempt number a second time. That's a race in the retry path, left for a follow-up; 2 s keeps these tests off it and costs nothing on the fake clock.EventNotFoundandEventFetchErroralso assert the lookup ran.context.Background()and stops throughShutdown: stopping it through its context leaks gocloud's receive goroutine, which fails the bubble.The package was stress-tested with repeated runs, plain and with
-race.Not in this PR: the sub-second backoff race above.
🤖 Generated with Claude Code