test: prove lease revival after sleep and trace drain on continuation release (U6) - #23
Merged
Merged
Conversation
… release (U6) R12: a repair round whose lease expired server-side while it ran is revived by freshen's heartbeat when the local clock says the last renewal is older than HeartbeatInterval, and is then authorized, pushed, and recorded. The same round with a fresh clock is refused on lease_not_owner, and a superseded lease (a successor attempt exists) is never revived. R13: through the real workerAttemptRunner wiring, trace ingestion is refused until CI goes green on the round's fix, so the whole trace is still buffered when the continuation is released. Once ClaimOnce returns, the control plane holds exactly the attempt's JSONL raw record. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedNext included review available in 49 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
Implements U6 of the factory-quality follow-ups plan (PR #21): closes the two test gaps that CI repair shipped with (R12, R13). This PR changes tests only. No production code changed.
R12: lease revival after a gap (
internal/worker/publish_repair_test.go)Each test runs a real repair round through the worker, control plane and git remote. While the round runs, the lease is expired on the server (
expireLease, left unswept) and the lease's injected clock (attemptLease.now) is set. The fence the round meets next is the pre-pushauthorizeRound.TestAStaleClockRevivesAnExpiredLeaseBeforeTheRoundIsAuthorizednow + HeartbeatInterval(stale)freshensends a heartbeat, the heartbeat revives the lease, and the round is then authorized, pushed, recorded, and judged green. The attempt isaccepted.TestAFreshClockSkipsTheHeartbeatAndTheExpiredLeaseIsRefusedfreshenskips the heartbeat, so authorization is refused withlease_not_ownerand nothing is pushed. This shows it was the heartbeat that revived the lease in the first test.TestAStaleClockDoesNotReviveASupersededLeaselease_superseded. Nothing is pushed and no round is recorded.The publishing runner's
Outcomeis captured by wrappingw.config.Runner. When the lease stays lost, the attempt's completion is also refused, and the round's own stop code can only be read from that captured outcome. The only other change to the test scaffolding is thatscriptedContinuationnow keeps the attempt's lease.R13: releasing the continuation drains the trace (
cmd/jig/ci_repair_test.go)TestReleasingTheRepairContinuationDrainsTheTraceBeforeTheAttemptCompletesruns through the realworkerAttemptRunner, which is wrapped in the publishing runner, against an in-processjig serve. The setup it shares with the existing end-to-end test is moved into helpers.Determinism mechanism.
TraceStream.Emitwakes the sender on every event. With a healthy control plane, events therefore reach the store long before release, whether or not the host closes the trace. I confirmed this: the existing end-to-end test still passes withcloseTraceremoved. An "events == JSONL" comparison on its own proves nothing.The test puts a gate (a reverse proxy) between the worker and the control plane. The gate refuses
POST …/eventsuntil CI goes green on the round's fix, and a probe checks that the store holds 0 events at that point. When the continuation is released, every event from both the chain and the round is still buffered, and the background sender is in retry backoff.TraceStream.Closedrains synchronously, and the host's release closure runs before the attempt completes. So the assertion runs as soon asClaimOncereturns, with no sleeping and no polling: the control plane must hold exactly the attempt's JSONL raw record, compared on seq, type, phase, name and payload, and includingci_repair_start.I chose this over a test flush interval because a longer flush interval would not stop the per-emit wake. It would also have needed a new production seam in
OpenTrace.Mutation checks
Each mutant compiled, and each file was restored with
git checkoutafter the commit.freshenfromauthorizeRoundlease_not_owner. The superseded test also fails, because it getslease_not_ownerinstead oflease_superseded. The fresh-clock control still passes, as intended.closeTrace()from theDeferToContinuationcleanup incmd/jig/worker.goFlake checks
go test -race -count=20 -run 'StaleClock|FreshClock' ./internal/worker/: okgo test -race -count=20 -run 'CIRepair|RepairContinuation' ./cmd/jig/: okjust check: ok🤖 Generated with Claude Code