Repository navigation
test: remove timing races from recovery, emulator and vnc tests - #158
Merged
Merged
Conversation
Three subprocess-timing tests each assumed an ordering that a loaded runner does not guarantee. Evidence recovery: a recovering process classifies a run's manifest before it takes that run's journal lock. A peer that wins the lock replaces manifest.json by rename, so the loser's already open descriptor points at an unlinked inode, the nlink check fails and the run is reported as "invalid evidence manifest". The test assumed all four processes print identical results. It now asserts the state they must agree on instead: every process that recovered the run recovered exactly the same run, any other process skipped it only for that transient reason, and the run ends up recovered once with one session index and three manifest artifacts. Reproduced 3 times in 60 four-process rounds under load. Android emulator: waitForBoot checks the emulator process and probes adb getprop in the same loop, and the fake adb reported a finished boot immediately, so the test assumed the fake emulator died before the first probe returned. Under load the probe wins and startEmulator resolves instead of rejecting. The failing test now uses an adb that never reports a boot, which leaves the early exit as the only way out of the loop. Confirmed by delaying the fake emulator's exit by 300ms: that reproduces the CI failure before the change and passes after it. x11vnc supervision: the fake server bound a port inside the kernel's local port range and had no error handler, so a lost bind killed it and startVnc reported "x11vnc exited during startup". The ports moved below that range and the fake now logs a failed bind and retries it, so a bind it cannot win surfaces as a startup timeout with the reason in the log rather than as a supervision failure. Production lock and supervision code is unchanged. The transient "invalid evidence manifest" skip is a misleading but non-destructive report from a real concurrent recovery, worth a follow-up rather than a change here. Refs #144
Review follow-up on the concurrent recovery test. Tolerating an "invalid evidence manifest" skip did not establish that the skip was transient: a run left persistently invalid could have passed as long as its JSON still held three artifacts. The concurrent round is now followed by a single further recovery that must report the run as recovered with no skips, and the report and session index bytes it leaves must equal the bytes the concurrent round settled on. The final manifest is checked for the recovered state as well, so a differing rendering fails and not only a differing index path or skip message. Verified against 2 real races in 60 four-process rounds. The comment now describes the window as a tolerated product race, filed as #159, rather than as a legal serialization, since recovering this fixture sequentially never produces that error. The x11vnc supervision test now uses a fake that only binds after a delay and asserts the port accepts a connection once startVnc returns, which proves the wait instead of only checking the returned port and liveness. The fake x11vnc setup moved into one helper shared by the immediate and delayed variants, and its comment no longer claims what a lost bind surfaces as, since an unrelated listener could satisfy readiness while the fake is still retrying. Refs #144
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 subprocess-timing tests failed on separate CI attempts of unrelated changes (#144). Root causes and changes:
packages/core/test/evidence-recovery.test.ts): a recovery process inspects the manifest before taking the journal lock, so a peer that wins the lock and replacesmanifest.jsonatomically leaves the loser with an unlinked inode (nlink 0), which the singleton-file check rejects asinvalid evidence manifest. That is a legal interleaving, so the test now asserts the state every process must agree on (same recovered run, one session index, three artifacts, any skip only for that transient reason) instead of byte-identical stdout. The window is documented above the test.packages/android/test/emulator.test.ts): the shared fake adb answered booted on the first probe, so under load the boot probe could win against the fake emulator's exit. A never-booting adb fake makes the early exit the only way out; the CI symptom was reproduced with an injected delay before the change and is gone after.packages/desktop-linux/test/integration.test.ts): the fake x11vnc bound ports inside the kernel ephemeral range and died silently on a failed bind. Ports moved below that range and the fake logs and retries a failed bind, so a lost port shows up as a named startup timeout instead of a supervision failure. The CI symptom could not be reproduced locally (145 rounds), so this is hardening against the failure the symptom names.Production lock and supervision code is unchanged. Validation on this branch: the three files (loops of 5 under load by the worker: recovery 1/5 failing before, 0/10 after), oxlint, complexity-gate, typecheck; lead re-ran the three files once more.
Author: Opus worker. Reviewer: separate Astra review.
Closes #144