Skip to content

test(native): await SSH fixture startup and exit - #181

Merged
rynfar merged 2 commits into
nativefrom
nw/172-ssh-fixture
Nov 3, 2026
Merged

rynfar merged 2 commits into
nativefrom
nw/172-ssh-fixture

Conversation

@rynfar

@rynfar rynfar commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

The fake SSH fixture polled PID files and process status against wall-clock bounds. Under parallel build load the fixture could fail before the fake process reached startup, even though shutdown worked correctly.

Replace every such wait in crates/client/src/ssh/tests.rs with a nonce-bearing startup message over a loopback socket and EOF for exit. The fake launch and tunnels block on socket reads rather than sleeps. Unrelated HTTP probes and silent peers cannot block the startup event. The stop-script fixture now owns and concurrently reaps a process blocked on stdin rather than relying on a detached process's 30-second lifetime.

Every startup caller watches its owner as well as the startup socket. Pending launch/tunnel attempts race their operation task; callers whose connection operation has already succeeded race the tunnel monitor's exit watch. An early failure is reported with the owning result instead of leaving the listener waiting forever. The failure branch takes priority over queued socket data.

A five-row regression covers launch exit, tunnel exit, EOF before a startup line, an invalid line, and a missing interpreter. It observes one poll after the owner has failed, making a missing completion branch fail immediately rather than hang the regression, then checks an in-flight operation too. With the previous waiting behavior this assertion failed; with the race it returns the operation's actual error. No sleep, polling loop, test timeout or retry is involved.

A shared scratch-directory guard is established before the remaining fallible fixture initialization, and also owns the stop-script test's directory. Both successful completion and unwinding clean up these directories without adding a dependency.

The SIGTERM-resistant quit test holds Tokio's monitor unpolled while reading EOF. It therefore proves shutdown sends the kill synchronously, without measuring elapsed time or relying on the async grace period. Removing production's synchronous SIGKILL temporarily makes this test fail with fake ssh survived synchronous shutdown: survived; production code was restored.

Audited the remainder of crates/client: no other test uses this helper or a wall-clock polling loop. Existing local CLI process tests already use event sockets. No production race was found for the reported milestone: both spawn paths register the PID before their first await, and shutdown synchronously signals those registered process groups. Production behavior, CN-SSH and #88 are unchanged; no ledger edit is needed.

Validation:

  • Original load comparison at 09b16e2539: interleaved 200 unchanged and 200 fixed complete SSH suites, eight concurrent workers, four test threads per suite, alongside an owned cargo build -p t3-native, followed by required Clippy/workspace-test compilation. Every result is retained; no retries or increased bounds.
  • Fixed: 200/200 suites passed, 2,400/2,400 tests passed. Baseline: 85/200 suites passed, 115 failed. All baseline failures are PID-file milestones (108 launch.pid was never recorded, 7 tunnel.pid was never recorded).
  • Entirely within the owned native build: fixed 43/43 suites passed; baseline 8/44 passed and 36/44 failed. The remaining runs include later compilation and parallel fixture load; the logs record build overlap explicitly.
  • Updated fixture: 50/50 complete SSH suites passed (650 tests) in a fresh parallel run with an owned native build; 16/16 completed entirely during that build. Per-run transcripts and build-overlap flags are retained.
  • cargo build -p t3-native, cargo clippy --workspace --all-targets -- -D warnings, and cargo test --workspace passed (1,226 tests).
  • Theme generation check, parity sync tests, conformance generation check from packages/client-runtime, and vp run check:changed passed.
  • Real SSH hosts and UI verification are excluded from this test-only change. No app windows, dev servers, paid turns, clipboard or user data used.

Local evidence:

  • /private/tmp/native-172-review-audit.txt: ownership-watch and cleanup changes.

  • /private/tmp/native-172-review-red.log, /private/tmp/native-172-review-green.log: failing/passing early-exit regression.

  • /private/tmp/native-172-review-load/, /private/tmp/native-172-review-load.py: updated 50-run transcripts, runner, summary and build log.

  • /private/tmp/native-172-review-workspace-tests.log, /private/tmp/native-172-review-clippy.log, /private/tmp/native-172-review-check-changed.log: updated gates.

  • /private/tmp/native-172-load/: runner results, per-iteration transcripts, summary, build-overlap details and build log.

  • /private/tmp/native-172-load.py: exact stress runner.

  • /private/tmp/native-172-audit.txt: full client audit and production-race assessment.

  • /private/tmp/native-172-mutation.log: missing synchronous kill is rejected.

  • /private/tmp/native-172-workspace-tests.log, /private/tmp/native-172-clippy.log, /private/tmp/native-172-check-changed.log.

  • /private/tmp/native-172-theme.log, /private/tmp/native-172-parity.log, /private/tmp/native-172-conformance.log.

Closes #172.

Built with GPT-6.1 Sol in Codex

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.

1 participant