Repository navigation
Make three timing-dependent unit tests deterministic - #1237
Merged
Merged
Conversation
…verrun a_pause_projection_spends_neither_reserve_nor_transport_liveness built a 50 ms wall-clock TransportWatchdog, slept 2 ms and expected the watchdog not to be due. Any scheduler stall of 50 ms between the two reads made observe_hls_deadline report transport_due and the test fail with "HLS transport stalled"; on a loaded or swapping machine that is routine. The test's subject is the playhead-funded reserve, not liveness, so the three tests that assert a live watchdog now share LIVENESS_NEVER_DUE (an hour). The body moves into a helper taking the stall, and a second test runs it with a 120 ms stall: it fails against the 50 ms budget on every run (transport_due: true) and passes now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
a_hold_accepted_during_a_blocked_body_read_ends_that_read waits for the runtime's second body Continue on a channel, then publishes the hold from a second thread and asserts the first answer after it is Stop. The reading thread is blocked for one CHECK_SLICE (100 ms) after that answer and then asks again, so a publisher descheduled for longer let a recheck that still answered Continue land first (observed: left Continue, right Stop). The sibling short-deadline reads have the same window, 60 ms wide. observe gains on_nth_continue, which runs the change on the watched thread itself between the nth Continue and that thread's next ask, and blocked_body_read uses it for the hold. A new test stalls the publisher for three slices: it failed on every run before and passes now. Co-Authored-By: Claude Opus 5.5 <[email protected]>
arm_candidate_assembly_puts_the_canonical_wrapper_first calls path() twice, once inside insert_arm_canonical_wrapper and once in the assert, without plx_base::testlock::serial(). path() reads the process-global persistent state root, which every redirecting test in the binary moves under that lock, so the two reads can straddle a redirect and disagree. A scratch harness with a lock-respecting writer toggling the root saw 56-77 mismatches per 20000 unlocked reads and none per 20000 locked ones. Co-Authored-By: Claude Opus 5.5 <[email protected]>
demux_against_when's AfterContinue still fired from a second thread that had taken the runtime's answer off the channel, the window the previous commit closed for blocked body reads. The open and NotReady-wait tests (a_hold_before_an_opens_short_deadline_settles_as_a_stall_abort, at_the_floor_an_opens_short_deadline_keeps_its_classification and the two NotReady waits) share it: a publisher stalled past their 60 ms deadline or the 250 ms retry wait let the world move on before the hold existed. Two of them failed together in one stalled local run. AfterContinue now goes through observe::on_nth_continue, and report runs the action before it delivers the answer, so a receiver woken by that answer, the publisher's after_hold included, finds the change made. Co-Authored-By: Claude Opus 5.5 <[email protected]>
GLinnik21
added a commit
that referenced
this pull request
Nov 4, 2026
Tree of the integration branch after merging main (through #1237), the W3c-2 move, the playurl offer-gate fix and the CI decode fixes. Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
Three unit tests that kept
make checkred onmainin code no PR touches. Each had a cause that can be named; none is a production bug, and all changes are test-only (theobserveseam inff_acquisition.rsiscfg(any(test, feature = "test-support"))).1.
ff::hls_reserve_tests::a_pause_projection_spends_neither_reserve_nor_transport_livenessCause: a wall-clock bound shorter than the scheduler can promise. The test built a 50 ms
TransportWatchdog(wall-clock inactivity by design), slept 2 ms and expected the watchdog not to be due. Any stall of 50 ms between creating it andobserve_hls_deadlinereadingInstant::now()makestransport_duetrue and the verdictHLS transport stalled. Every writer ofplaypos_ns/TX.pausedin the module already holdstestlock::serial(); the playhead clock is not wall-based, so nothing else is involved.Fix. The test's subject is the playhead-funded reserve, so the three tests that assert a live watchdog now build it with
LIVENESS_NEVER_DUE(one hour). The body moved intopause_projection_verdict_after(stall), and a second test runs it with a 120 ms stall.a pause projection classified a boundary: BlockingWake { owner: Reserve, reserve_spent: false, transport_due: true }.reserve_spent: falserules out a strayplaypos_nswriter.test result: FAILED. 26 passed; 1 failed; ... finished in 18.13s), then 0 of 150 once the machine was quiet. After: 0 of 150 and 0 of 100 ambient, 0 of 100 under 40 CPU hogs.test result: ok. 28 passed; 0 failedfor the module.2.
ff::stall_guard_tests::a_hold_accepted_during_a_blocked_body_read_ends_that_readCause: an ordering assumption in the
observeseam. The test waits for the runtime's second bodyContinueon a channel, then publishes the hold from a second thread and asserts the first answer after it isStop. The reading thread blocks for oneCHECK_SLICE(100 ms) after that answer and then asks again, so a publisher descheduled for longer let a recheck that still answeredContinueland first. Failure observed locally:left: Some((Body, Continue { .. })) right: Some((Body, Stop)). CPU hogs alone do not produce a 100 ms deschedule: the test alone was 0 of 60 idle and 0 of 60 under 20 hogs; it failed in one 83 s module run (three tests red, 1 of 25 runs).Fix.
observe::on_nth_continue(phase, n, action)runs the change on the watched thread itself, between the nthContinueand the next ask, andreportruns it before the answer is delivered, so a receiver woken by that answer finds the change made.blocked_body_readpublishes the hold that way, and so doesdemux_against_when'sAfterContinue, which had the same shape. The pr-reviewer found those four callers: the open-leg short-deadline pair (60 ms window) and the two NotReady waits (250 ms retry). The open pair is the other two tests that failed in that 83 s run (PrimeExpiredinstead ofStallAbort; "the hold was requested").a_stalled_observer_cannot_reorder_the_hold_against_the_runtimes_rechecks, publisher stalled 3 slices, 3 of 3 runs): the sameContinuevsStopassertion.test result: ok. 35 passed; 0 failed; 0 of 40 ambient, 0 of 30 under 40 hogs.Not fixed. The 60 ms short-deadline tests (two body, two open) still arm a wall deadline before the read or open starts, so a stall of 60 ms inside the reading thread itself can still beat them. That is those tests' design (a deadline shorter than
CHECK_SLICE); removing it needs an injectable clock inTransportWatchdog/ReserveDeadlineState, which this PR does not add.3.
plex::session::persistence::db8_policy_tests::arm_candidate_assembly_puts_the_canonical_wrapper_firstCause: an unlocked reader of a process global. The test calls
path()twice (insideinsert_arm_canonical_wrapperand in the assert) withouttestlock::serial().path()reads the process-global persistent state root, which about a dozen tests in the binary redirect under that lock, so the reads can straddle a redirect. I checked every redirect writer inplx_plex(async_persistence,migration_tests,prefs_characterisation_tests,session_cache_tests,session_persistence_tests,persistence): all hold the lock, so the unlocked reader is the only gap.Fix. The test takes
serial().plx_plexruns (768 tests each), and 0 of 20 with a 10 ms sleep placed in the window at 16 test threads.serial()saw 0 of 20000 in each.test result: ok. 768 passed; 0 failedforplx_plex.Verification and what was not run
make test-hostsim C=plx_media T=stall_guard_tests(35 passed), the finalplx_mediahostsim binary looped directly as above, andmake test-crate C=plx_plex(768 passed). Loops used a hog script with an EXIT trap;psshowed no survivors.make check(the Mac was shared and swapping; CI is the gate), clippy/lint,make check-nodef(no code outsidecfg(test)/test-supportchanged).plx_mediahostsim binary was not looped: one run takes 6 minutes on this machine.🤖 Generated with Claude Code