Repository navigation
test: run Redis-backed tests on a fake clock - #1162
Merged
Merged
Conversation
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
leggetter
reviewed
Oct 29, 2026
leggetter
left a comment
Collaborator
There was a problem hiding this comment.
🤖 Claude review notes (from Phil's Claude Code session, non-blocking)
These are agent-generated notes, not Phil's own review.
Dialer(internal/redis/config.go,internal/redis/redis.go): when it's set, go-redis uses it in place of its default dialer, and go-redis only appliesTLSConfiginside that default dialer (v9.22.0options.go:494and:617-626). So with a customDialer,TLSEnabledis silently ignored. Only tests set it today, so there's no user impact. Worth adding "bypasses TLS" to the field comment so nobody wires it up in production later?Monitorshutdown (internal/scheduler/scheduler.goon main, not changed here):Monitorreturns as soon asctxis cancelled, without waiting for the handler goroutines it started, and those handlers run on the same cancelledctx. The newstartMonitorhelper works around this in tests by letting handlers finish before cancelling. Is that intended for production shutdown, or worth a follow-up? I haven't traced what the service does afterMonitorreturns, so the impact is unverified.
leggetter
approved these changes
Oct 29, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Thanks! Updated the On |
Collaborator
Author
|
Opened #1185 for the Monitor drain. |
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 scheduler, idempotence and infra tests on a fake clock, with an in-memory Redis, so they stop waiting on real timers.
These tests waited out real visibility timeouts, lock delays and TTLs and asserted on wall-clock windows, which made them slow and sensitive to CPU load.
testing/synctestruns a test in a bubble with a fake clock:time.Sleepadvances the fake clock instead of waiting, andsynctest.Wait()returns once every goroutine in the bubble is blocked. Redis kept these tests out of a bubble: miniredis needed a TCP listener, and a bubble can't do network I/O. miniredis v2.40.0 addsDial()over an in-memory pipe andClockTTL()(TTLs follow the fake clock).RedisConfig.Dialerininternal/redis: optional. When set, the regular client dials through it and maintenance notifications are off (they look up the address themselves, bypassing the dialer). Nil by default; yaml/env go throughconfig.RedisConfig, which doesn't carry it. The cluster client ignores it.testutil.NewSynctestRedis(t): a miniredis, a config whoseDialerreaches it, and a client fromredis.New, usable inside a bubble.contributing/test.md: a short "Timing in tests" section, with a guideline to keep each package under 2 s ingo test -short -p 1 ./....Each of these packages now runs in under 1 s. Integration tests (
TESTINFRA) stay on real time.Notes:
TestScheduler_VisibilityTimeout: context 4 s → 3.5 s. The 4th receive lands at exactly 4 s, so the old deadline raced it, in real time too.TestInfra_LockExpirynow also asserts the lock key expired andDeclaredidn't hit its 5 s retry; on a fake clock the retry alone would let it pass.synctest.Wait()beforecancel():Monitorreturns before in-flight handlers finish, and a handler still running when the test ends fails the bubble.Each converted package was stress-tested with repeated runs, plain and with
-race.Not in this PR:
Monitorwaiting for in-flight handlers on shutdown.🤖 Generated with Claude Code