Repository navigation
Studio: fix two intermittently failing tests - #9200
Conversation
|
@codex review |
|
Consolidating the PRs that overlap on the current Three files here, and only I can independently corroborate the Your diagnosis matches what I saw. On the overlapping hunk: your No action needed from you. This is queued behind #9220 only because everything is, while |
Reduced to the one fix of the original three that is still needed. The other two landed by other routes while this sat: the orphan-scan flake was fixed by #9280, and the extensionless `./mmproj-fallback` import is already `.ts` on main. Both are verified identical to main here rather than assumed. On #9280 taking a different approach: it pins `_pid_parent_is_alive` to a constant for the whole test, where this PR stubbed it only for the invented PID and delegated every other PID to the real implementation. That is a real difference in coverage, so I checked whether main lost anything before dropping mine. It did not: `test_reap_recorded_pid_spares_live_server` in test_llama_cpp_wait_for_vram_settle.py exercises the ownership gate for real, against a process the test genuinely owns. So the gate is still covered and #9280's version stands. What is left, and why it is still needed ------------------------------------------------------------------------ `saveMarkdownAsProjectSource` fires `watchIngestion` without awaiting it, and that watcher polls for up to 300 seconds. Watchers from earlier tests therefore outlive them and keep calling the shared fetch stub, which by then belongs to whichever test is running now. The stub answered any `/jobs/` URL and the uploads shared a filename, so a stale watcher emitted a toast byte-identical to the one the running test was waiting on, under a different project id. The test then waited on the toast and read the announce count without polling. The watcher toasts and announces with nothing awaited between them (save-markdown-source.ts, `toast.error(...)` then `announceProjectSourcesUpdated(...)`), so a tick landing in that window saw 1 instead of 2. Each job handler now answers only its own job id and 404s anything else, so a stale watcher dies quietly instead of borrowing the running test's answers. The save under test gets its own filename, and the test polls on the announce, which the watcher does last, then asserts the toast synchronously. Verified ------------------------------------------------------------------------ Gap sweep, inserting a 150 ms delay into the source between the toast and the announce to widen the window the race needs: main's version of the test fails 6 of 6 runs, this version passes 6 of 6. Both pass 6 of 6 on an idle box with no delay, which is why this reads as an intermittent CI failure rather than a reproducible one. Mutation-tested: deleting `announceProjectSourcesUpdated` from the watcher fails this test (9 passed, 1 failed), so it still proves what it did before rather than having been loosened into passing. Full frontend suite: 4087 passed, 0 failed.
01cec7f to
5b9740a
Compare
Two tests were failing intermittently in CI. Both turned out to be faults in the tests themselves, not in the code they cover, so the implementations are unchanged here.
Orphan cleanup test keyed on an invented pid
test_orphan_cleanup_kills_under_real_rootnever spawns a process. It invents a pid asos.getpid() + 888, but_kill_orphaned_serversgates every candidate on_pid_parent_is_alive, which asks the real OS. When something already occupies that pid with a live parent, the candidate is skipped and the test fails withassert 0 == 1. PIDs are handed out sequentially, so the allocator passes that number shortly after pytest starts, which is what makes this reachable rather than theoretical.Reproduced by forking pytest, squatting
pytest_pid + 888with a live process, then releasing pytest: the unmodified test fails with exactly the CI message.The gate was added in #8498 without updating this test, so the flake has been latent since then.
The
[procfs]parametrization was also passing for the wrong reason: itsos.killstub raisedProcessLookupErrorfor every pid except the fake one, andpsutil.pid_existsisos.kill(pid, 0)on POSIX, so every parent read as dead. That is why only[psutil]ever failed.The tests now stub
_pid_parent_is_alivefor the invented pid only and delegate every other pid to the real implementation, and the procfs stub delegates too. A new test covers the ownership gate with a process the test genuinely owns, so nothing is lost by stubbing it elsewhere.Project source test raced its own announce
saveMarkdownAsProjectSourcefireswatchIngestionwithout awaiting it, and that watcher polls for up to 300 seconds. Watchers from earlier tests therefore outlive them and keep calling the shared fetch stub, which by then belongs to whichever test is running now. Since the stub answered any/jobs/URL and the uploads shared a filename, a stale watcher emitted a toast byte-identical to the one the test was waiting on, under a different project id.The test waited on the toast and then read the announce count without polling, so a tick landing between a foreign toast and its own announce saw 1 instead of 2. The 2014 ms duration in the CI log is a stale 2 s watcher.
Each job handler now answers only its own job id and 404s anything else, so a stale watcher dies quietly instead of borrowing the running test's answers. The save under test gets its own filename, and the test polls on the announce, which the watcher does last, then asserts the toast synchronously.
Verified with a gap sweep: with a 150 ms delay inserted the old test fails 10 of 10 and the new one passes 10 of 10.
Import resolution
image-input-support.tsimported./mmproj-fallbackwithout an extension. CI runs Node 22 and is unaffected, but under Node 24 the package is ESM and the specifier does not resolve, which hides four tests from anyone running the suite locally. Test-reachable modules elsewhere already use the explicit.tsform.Checks
Both fixes were mutation tested to confirm they still prove what they did before: removing the parent gate from the implementation fails the new orphan test, and removing
announceProjectSourcesUpdatedfails the new source test.tests/test_local_llama_cpp_link.py: 10 passed, plus 50 sequential runs idle and 40 under CPU load with no failuresnpm run typecheckclean