Repository navigation
Conversation
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
|
Note Claude Opus 5.5 with high responding on behalf of Yota Both notes are addressed in 245c976:
|
245c976 to
b001a2d
Compare
Confidence Score: 5/5
[Low impact] The PR appears safe to merge; the revised tests keep the intended timing and takeover checks. SummaryMakes directory-lock timing tests independent of pauses on busy runners.
Reviews (1) · Last reviewed commit: "Reuse the test clock and pin the cold st..." · Reviewed by Greptile |
dc3138c to
bbc8997
Compare
TestStaleTakeover_SlowSweep failed on a loaded Windows runner: it expected a contender to find a just-created lock fresh, but judged that against real time with a 200 ms threshold, so a pause between the takeover and the check made the lock look stale. The observer tests had the same exposure, renewing and checking in real time against the same threshold. These tests now read a clock they control through the dirLock clock hook. The slow sweep is simulated by aging the lock directory that exists while it runs, which still fails if the sweep ever runs after the new lock is created. The observer tests move their clock a step between looks instead of sleeping.
TestHeartbeatAfterLapse kept its own atomic clock, which the shared testClock now covers. TestObserverColdStart now checks for a conflict at exactly the stale threshold, as TestObserverLegacyHolder does, so it fails if a contender takes the lock one step early.
bbc8997 to
49daf42
Compare
Summary
internal/cmn/dirlockTestStaleTakeover_SlowSweepfailed on a Windows runner (#4453, Windows 2/2) with "Expected error with "directory is locked by another process" … but got nil" atdirlock_test.go:1014. The test checks that a lock created just after a takeover looks fresh to the next contender. It judged that against real time with a 200 ms threshold, so any pause on a loaded runner between the takeover and the check made the lock look stale. The observer tests were exposed the same way, because they renewed and checked in real time against the sameobserverStale.Changes
TestStaleTakeover_SlowSweepuses a stopped clock through thedirLock.nowhook. Its slow sweep ages whatever lock directory exists while the sweep runs, instead of sleeping past the threshold. This replaces the 1 s threshold that Give each step only the secrets it lists #4511 gave the test, so the threshold goes back to 200 ms.TestObserverSkew,ColdStart,ReadError,FencedHeartbeat, andLegacyHoldershare atestClockthat the test advances byobserverStale/4between looks, instead of sleeping.TestHeartbeatAfterLapseuses the sametestClockinstead of its own atomic clock.ColdStartandLegacyHolderboth require a conflict through exactlyobserverStale.TestObserverFrozenandTestObserverRestrictedDirkeep real time. Their only timing assertions are a lower bound and a 5 sEventually, which a slow runner cannot break.Core change
Lock staleness compares
l.now()with a directory timestamp or with the time a heartbeat was last seen to change. With both locks on a stopped clock, the new lock's directory, created after the clock stopped, is never older than the threshold, however slow the runner is. To simulate a sweep that takes an hour, the test ages the lock directory that exists while the sweep runs. With the current order (sweep, then create) nothing exists yet, so nothing is aged. If the sweep ran after the new lock was created, it would age that lock and the test would fail. Running the test against that reordered code makes it fail.internal/cmn/dirlock/dirlock_test.go:Testing
go test -race -run 'SlowSweep|Observer|HeartbeatAfterLapse' -count=20passes. The full package passes.removeAbandonedTempDirs()aftercreateLockmakesTestStaleTakeover_SlowSweepfail.GOOS=windows go vetand golangci-lint (plain andGOOS=windows) pass on the package.Performance
No performance risk: the change is test-only.
Agent
Claude Code, claude-opus-5-5, high
Summary by CodeRabbit