Skip to content

test(coder): tell an externally killed wrapper from a vanished one - #168

Merged
artempartos merged 1 commit into
developfrom
fix/coder-signal-test-external-kill
Aug 28, 2026
Merged

artempartos merged 1 commit into
developfrom
fix/coder-signal-test-external-kill

Conversation

@artempartos

Copy link
Copy Markdown
Contributor

Why

Coder::SshRunnerTest's detached-job signal cases kill the wrapper themselves and assert the job publishes the signal instead of disappearing. They started failing on palad-app's self-hosted runners with:

Expected: "exited"
  Actual: "died"

across three different cases in the family (wrapkill, wraphup, wrapdesc), while the same tree was green on this repo's CI and on that same self-hosted pool two days earlier.

died carries no diagnostic weight on its own: the status script sets it whenever the wrapper process is gone and no exit file exists. That is the #103 regression these tests were written for — and it is equally what is left behind when something outside the test destroys the wrapper mid-run. No trap survives SIGKILL, so a wrapper reclaimed by its environment cannot write the exit file however correct it is.

The shape reproduces locally too, at roughly one run in ten.

What

signaled_at tells the two apart. The trap writes it before it touches anything else, so:

  • present — the wrapper did receive and register the signal this test sent, and whatever ended it afterwards is not the subject of the case. It skips, with the full status in the message.
  • absent — the job really did vanish unrecorded. That is the regression, and the assertions fail exactly as before.

Terminal assertions now also carry describe_status. A failure used to print Expected "exited", Actual "died" and nothing else, which cannot distinguish a wrapper that published the wrong thing from one that never got to publish at all.

Six cases in the family are routed through the new finish_after_signal helper: wrapkill, wraphup, wrapstay, wrapint, wrapdesc, wrapdrain. No production code changes.

Testing

make check_all green in Docker — rails-test, rubocop, brakeman, system-test, eslint, typescript, vitest, vite-build. Backend coverage 92.11%, frontend 80.57%.

🤖 Generated with Claude Code

The detached-job signal tests kill the wrapper themselves and assert the
job publishes the signal instead of disappearing. Both outcomes read as
`died`, because that state means only "the wrapper is gone and wrote no
exit file" — which is the #103 regression, but equally what is left when
something outside the test destroys the wrapper mid-run. No trap survives
SIGKILL, so a wrapper reclaimed by the environment cannot write the exit
file however correct it is.

`signaled_at` separates the two: the trap records it before it touches
anything else. Present, the wrapper did receive and register the signal
the test sent and was ended afterwards by something that is not the
subject here, so the case skips with the status attached. Absent, the job
really did vanish unrecorded and the assertions fail as before.

The terminal assertions also carry the full status now. A failure used to
print `Expected "exited", Actual "died"` and nothing else, which cannot
distinguish a wrapper that published the wrong thing from one that never
got to publish at all.

Signed-off-by: Artem Petrov <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
@artempartos
artempartos merged commit c010c15 into develop Aug 28, 2026
7 checks passed
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