Skip to content

#630 [test] runner cleanup の終了順序と孫プロセス消滅を直接確認する - #639

Merged
Kewton merged 3 commits into
developfrom
feature/issue-630-test-runner-cleanup
Oct 9, 2026
Merged

Kewton merged 3 commits into
developfrom
feature/issue-630-test-runner-cleanup

Conversation

@Kewton

@Kewton Kewton commented Oct 9, 2026

Copy link
Copy Markdown
Owner

概要

runner の dev server の cleanup のテスト(dev_server_cleanup_kills_grandchild_process_group_without_pipe_deadlock)は、起動から probe・cleanup までの全体を 5 秒で測っていたため、起動待ちが cleanup の遅さとして扱われることがありました(#541 の分割 H)。この PR は、子と孫の起動完了を合図で確かめてから cleanup の区間だけを測り、cleanup の完了、pipe の EOF、process group の消滅を別々に確かめます。

変更(テストのみ、対象 2 ファイル)

  • src/planner/runner/tests/acceptance_boundary_tests.rs:
    • 孫がテストの一時ディレクトリの中の FIFO を write で開き、ready の合図を書いてから眠る。
    • 既存の cleanup_fn の注入点に、孫の ready を(上限 5 秒で)読んでから cleanup の区間だけを測る関数を渡す。
    • cleanup の区間の上限は、元の全工程の上限と同じ 5 秒(テスト側の名前つきの定数、< で比較)。区間は全工程の一部なので、元と同じか厳しい。TERM で終わらず KILL に頼る cleanup は 5 秒を超えて落ちる。
    • cleanup 後に、cleanup ok、process group の ESRCH、FIFO の EOF を別々に assert。start・wait・probe・cleanup の順序、readiness evidence、ログの assert は残した。
  • src/planner/runner/tests/support/process.rs:重複していた lifecycle イベントの検索を dev_server_lifecycle_event にまとめた。
  • 製品コード、timeout の既定値、イベント名・schema、tests/generality_guardrails.rs は変えていません。テストの数(#[test] 25)も同じです。

検証

  • commandmate verify の 15 ゲート:develop e5c6a37c を取り込んだ HEAD で 15/15 pass(af6824b6、scope 2 本、違反 0)。
  • cargo test --test generality_guardrails:取り込んだ HEAD で exit 0、10 passed・0 failed。行数(generality_guardrails の数え方):acceptance_boundary_tests.rs 1350(上限 1,367)、support/process.rs 103(上限 106)、runner のテストの総量 15507(上限 15,511)
  • 二点測定(HEAD をコピーし、1 か所ずつ変えた):
    • cleanup を呼ばない → FAIL(process group … should be gone)。
    • 孫を dev server の process group の外に出す(group を kill しても孫が残る)→ FAIL(grandchild pipe must reach EOF once the grandchild is reaped。process group の確認は通り、FIFO の EOF の確認だけが検出した)。
    • 孫が SIGTERM を無視する(cleanup が KILL に頼る)→ FAIL(cleanup that needs the KILL fallback (SIGTERM not enough) exceeds 5s: 5110ms)。
  • 同時実行:受け入れ条件の「2 checkout で同時に 3 回」は、同じビルドの lib のテストバイナリを 2 プロセス同時に 3 回走らせることで代えました。3 回とも両方 exit 0。

レビュー

テストだけの変更です。merge 前レビューは行いません(利用者承認済み)。

Refs #630
Refs #541

🤖 Generated with Claude Code

Kewton and others added 3 commits October 9, 2026 01:49
… before cleanup timing

Replace the whole-run 5s wall-clock assertion in
dev_server_cleanup_kills_grandchild_process_group_without_pipe_deadlock with
signals bound to this run: the fake grandchild holds a named pipe open and
announces readiness on it. The injected cleanup_fn (the existing
run_nextjs_dev_route_probe_with_runtime hook) waits for that readiness, then
measures only the cleanup interval against the cleanup's own term+kill bound.
Cleanup completion, pipe EOF, and process-group ESRCH are asserted separately,
so a change that skips cleanup or leaves the grandchild is detected. The
duplicated dev_server_lifecycle event lookup moves to a shared helper, and the
test workspace moves under the cargo target directory.

読み替え: 「pipe の EOF」は実 child/grandchild が保持する名前付きパイプ (FIFO) の write 端が閉じることと読んだ。production は child の stdout を file へ向けるため、既存の cleanup_fn 注入点の内側で当該実行の pipe を観測できる経路は FIFO だけである。
判断: cleanup 区間の上限は既存の DEV_SERVER_CLEANUP_TERM_TIMEOUT + DEV_SERVER_CLEANUP_KILL_TIMEOUT (=6s) を inclusive に使った。テストの一時ディレクトリは読み取り許可プレフィックスの下に置かず、test 実行ファイル配下(target)に作った。
本文に無い指摘: 全工程の 5 秒 assertion は起動待ちを cleanup の遅さとして扱っていたため削除し、cleanup 自体の上限と deadlock 検出(bounded な pipe 読み)に置き換えた。単純削除はしていない。

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
Use a test-side CLEANUP_INTERVAL_BOUND (5s) and a strict `< 5s` comparison
instead of the product term+kill sum, so the rewritten assertion is equal to
or stricter than the original whole-run 5s bound (the cleanup interval is a
subset of the whole run). The message states that a cleanup which only ends
after the KILL fallback also fails. Other assertions are unchanged.

判断: 「cleanup 自体の既存上限」は元の全工程 5 秒 assertion と同じ 5 秒をテスト側の名前つき定数で持つと解釈した(製品の定数の和には依存しない)。

Co-authored-by: CommandCodeBot <noreply@commandcode.ai>
@Kewton
Kewton merged commit ddcb802 into develop Oct 9, 2026
5 checks passed
@Kewton
Kewton deleted the feature/issue-630-test-runner-cleanup branch October 9, 2026 09:14
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