Skip to content

test: reap e2e dirsql servers when the test process dies - #1116

Merged
thekevinscott merged 3 commits into
mainfrom
claude/1114-reap-e2e-servers
Sep 17, 2026
Merged

thekevinscott merged 3 commits into
mainfrom
claude/1114-reap-e2e-servers

Conversation

@thekevinbot

@thekevinbot thekevinbot commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #1114

The CLI e2e tests spawn dirsql server with Command::spawn() and kill it at the end of the body. Child does not kill on drop, so a panic before that call or a SIGKILL of the test binary (OOM killer, cargo-mutants timeout, Ctrl-C) leaves the server at PPID 1.

Change

  • packages/rust/tests/common/server.rs: one shared spawn_server helper returning a ServerGuard that kills and waits on Drop. On Linux it sets PR_SET_PDEATHSIG=SIGKILL on the child in pre_exec, so the server dies with the test process even when the process is SIGKILLed and never unwinds. Other platforms get the Drop guard only.
  • cli_e2e.rs, cli_repeatable_config_e2e.rs, on_file_e2e.rs spawn through it.
  • packages/rust/tests/server_reaping_e2e.rs: driver test that runs the test binary as a subprocess filtered to an #[ignore] helper holding a server, SIGKILLs the subprocess, and asserts the server pid is gone within 5 s.

Red/green: the first commit (ee3f3af) is the test alone; CI red for the right reason at https://github.com/thekevinscott/dirsql/actions/runs/35153127300/job/104986071034 (dirsql server 27533 outlived its SIGKILLed test process). The second commit (fe4be59) is the pdeathsig change plus the migration of the three e2e files.

Manual exercise

Ran the helper test by hand (server_reaping_e2e --exact hold_a_server --ignored --nocapture), kill -9 on the test process, then ps -eo pid,ppid,args | grep '[d]irsql server --port'.

  • Before: 3349098 1 .../target/debug/dirsql server --port 43103 --host localhost (orphan at PPID 1).
  • After: no dirsql server from this worktree in ps; the helper test's server (pid 3364680) was gone once its parent was killed. server_dies_when_test_process_is_sigkilled passes in 0.05 s.

CI note

typescript-sdk / Packaging is red here and on main at c53c932 for the same reason (tsx: not found in prepack; the upstream packaging job no longer installs before pnpm pack). Tracked in #1117; nothing in this PR touches packages/ts.

E2E Verification

  • Ran e2e suites locally for every affected SDK
  • Python SDK e2e: N/A (packages/python untouched)
  • TypeScript SDK e2e: N/A (packages/ts untouched)
  • Rust core e2e (if applicable): pass
  • packages/python/e2e-attestations/<branch>.json receipt: not owed (packages/rust/src untouched)
  • packages/ts/e2e-attestations/<branch>.json receipt: not owed (packages/rust/src untouched)
  • Command(s) run: cargo test --workspace --features cli; just preflight --gate <every gate except mutation> (mutation left to CI: uncapped local cargo-mutants runs are off-limits on this host)
  • Result summary: 1351 passed, 0 failed, 2 ignored (hold_a_server is the subprocess helper), exit 0; no orphaned servers after the run

Changelog / Migrations

  • Changelog fragment: not required, test-tree only (packages/rust/tests/); skip-changelog: test harness only on the commits as belt and braces
  • Migration fragment: not required

Adds the shared server-spawn helper (Drop guard only) and a red test that
runs the test binary as a subprocess holding a server, SIGKILLs it, and
asserts the server is gone. Fails today: the server survives at PPID 1.

Refs #1114
skip-changelog: test harness only
The shared spawn helper sets PR_SET_PDEATHSIG=SIGKILL on the child in
pre_exec (Linux), so a server dies with a test process that is SIGKILLed
and never unwinds. cli_e2e, cli_repeatable_config_e2e and on_file_e2e now
spawn through it and hold the Drop guard, which also covers panics.

Fixes #1114
skip-changelog: test harness only
The stale release-ci check runs left on the previous sha carry version
numbers willfire no longer predicts, so CI Gate reports them as
unpredicted checks and cannot confirm the set is complete.
@thekevinscott
thekevinscott merged commit 87c65df into main Sep 17, 2026
76 checks passed
@thekevinscott
thekevinscott deleted the claude/1114-reap-e2e-servers branch September 17, 2026 17:07
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.

e2e test binaries orphan dirsql server children on panic or SIGKILL

2 participants