Skip to content

test(desktop-linux): stop display, port and session collisions under load - #256

Merged
ElbertePlinio merged 13 commits into
mainfrom
fix/252-desktop-linux-load-flakes
Oct 6, 2026
Merged

ElbertePlinio merged 13 commits into
mainfrom
fix/252-desktop-linux-load-flakes

Conversation

@ElbertePlinio

Copy link
Copy Markdown
Member

The desktop-linux display, integration, takeover and identity tests no longer collide when two runs share a host, and they no longer leak a session's Xvfb when a test times out.

The live unrelated server test now waits until the lock names the spawned Xvfb, that Xvfb holds the socket, and the server answers an X11 setup request. File presence alone was not enough. Takeover, display-identity and integration used fixed VNC ports and displays, so they now pick a free port and an unused high display per run. Integration sessions are tracked, and afterAll waits for creates still in progress and destroys leftover sessions before it deletes the registry. That closes the timed-out-test leak. The destroy check now asks whether this session's Xvfb still owns the display, because a concurrent run may take the freed number at once. The race worker publishes its result atomically. Product code is unchanged.

One leak path stays open. When a vitest worker is SIGKILLed from outside, no teardown runs. That is tracked in #253.

Closes #252

Requirement Verification Scenario Result Evidence
Wait for a verifiable owner in the live unrelated server test Automated test 48 copies pinned to 2 CPUs with busy loops, two concurrent full suites 0 failures of this test 252/final-alloc-pinned/, 252/after2-2x/
Fix takeover under concurrent runs Automated test Two concurrent copies of the 4 files origin/main 12/12 copies fail, branch 16/16 pass 252/before-2x/, 252/after2-2x/summary.txt
Fix display-identity under concurrent runs Automated test Same Fixed :242 collision gone same
Fix integration under concurrent runs Automated test plus probe Same, plus freed-display reuse 0 assertion failures 252/probe/reuse-probe.log
Close the Xvfb leak path Deterministic repro Timed-out test, then afterAll Leak on old test code, none on branch 252/leak-proof/leak-before.txt, leak-after.txt
Full suite bun run test:coverage Final head 2888 tests pass, thresholds met 252/coverage.log

Evidence lives in ~/Artifacts/pickforge-kickoff-2026-10-06/ on the dev host. The QA pass was skipped because this is a test-only change with nothing to drive.

…display

Xvfb creates its lock and socket before startup ends, so file presence raced a server that was still starting. Wait until the lock names the child, the child holds the listed socket, and the server answers an X11 setup request. Keep the server inside try/finally and report its stderr if it exits. Refs #252.
takeover.test.ts walked fixed ports from 15901 and display-identity.test.ts used :242, so two concurrent suites collided. The second run saw "already in use", a fake x11vnc that crashed on bind, or a lost-race XvfbStartError. Pick a free loopback port below the local port range and an unused display at random instead. Refs #252.
A test that exceeds its timeout keeps running after vitest moves on. afterAll then deleted the registry, so the test's own destroy found no session, or the worker exited first, and Xvfb outlived the run. Track every created session and destroy leftovers in afterAll before the registry goes. Also give the registry reaping test the session budget, and pick free ports and unused displays instead of fixed ones. Refs #252.
Display allocation picks the lowest free number, so a concurrent run can claim a destroyed session's display at once. isDisplayAlive then reports that new server. Assert that this session's Xvfb no longer owns the display instead. Refs #252.
The race test parses each result as soon as the file exists. Under load it read a half-written file and failed with "Unexpected end of JSON input". Write the result aside and rename it into place. Refs #252.
…led teardown state

Hold a per-user lock file for each picked loopback port until teardown, so
concurrent suites never receive the same port before VNC binds it. A
reservation whose owner process is gone counts as stale.

Integration teardown now tries every tracked session and keeps the registry
when any destroy fails. The display allocation tests reuse the shared
unused display picker, and a redundant release assertion is dropped.
…rge/pickforge into fix/252-desktop-linux-load-flakes
@ElbertePlinio
ElbertePlinio merged commit 23c0602 into main Oct 6, 2026
10 checks passed
@ElbertePlinio
ElbertePlinio deleted the fix/252-desktop-linux-load-flakes branch October 6, 2026 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: desktop-linux live server, integration and takeover tests flake under load

1 participant