Skip to content

テスト: 全体テストを並列・2 分割で回し、重複した競合試験と繰り返しを減らす(#882 #884) - #891

Merged
takemi-ohama merged 3 commits into
developfrom
test/issue-882-884-test-speedup
Sep 23, 2026
Merged

takemi-ohama merged 3 commits into
developfrom
test/issue-882-884-test-speedup

Conversation

@takemi-ohama

@takemi-ohama takemi-ohama commented Sep 23, 2026

Copy link
Copy Markdown
Contributor

Summary

全体テストの待ちを縮める(マイルストーン 26 の 2')。モードは light(テスト・継続的統合の設定・テストを案内する文書だけ。本番のスクリプトは変えない)。要求と受け入れ条件は issues/issue-882-884-test-speedup.md にある。

所要の実測(手元・9 コア・別の作業と並行)

実行 件数 変更前 変更後
順(CI と同じコマンド) 5337 → 5333 200 秒 176 秒
-n 4 5337 → 5333 55 秒 53 秒
-n auto 5333 35 秒
-n 4taskset -c 0-3、4 vCPU の runner 相当) 5333 53 秒
0.5 秒以上のテストの合計(順) 42 件 → 39 件 106.5 秒 88 秒

継続的統合の所要(ubuntu-latest

実行 テストの段 起動からまとめの結果まで
変更前(PR #886、run 35821421926) 5 分 30 秒 約 5 分 40 秒
-n auto の 1 ジョブ(22d12293、run 35824147678) 1 分 53 秒(108.84 秒、5333 passed) 2 分 6 秒
2 分割+まとめジョブ(89ff29f5、run 35824519073) 57 秒(2085 passed)/ 63 秒(3248 passed) 1 分 21 秒

件数の減少 4 件は、寄せた競合試験(4 通り → 1 通り、A7 の 1 件を削除)の分である。

#884 の残り(本番のスクリプトの変更が要るため、この PR では行わない)

#884 の受け入れ条件「0.5 秒以上の合計が 40 秒以下」はこの PR だけでは満たさない。#884 は開いたまま残す。

残り 所要(順) 要るもの
test_git_facts.py の猶予待ち 21 秒 #883(2'' で扱う)
test_bg_wait.pysleep 1 ポーリング 20 秒 bg-wait.sh の間隔の注入(本番のスクリプト)
ロックの上限 5 秒を待つテスト(test_testenv.py 2 件・test_the_timeout_override_reaches_only_the_stage_state 約 19 秒 台帳の上限の注入(#293 の決定の更新)

関連する issue: Fixes #882 / Refs #884

Test plan

  • uv run --project plugins/playwright-kit/skills/playwright-kit-ops --with pytest pytest . -q -n 4 → 5333 passed / exit=0

  • uv run --project plugins/playwright-kit/skills/playwright-kit-ops --with pytest pytest . -q -n auto → 5333 passed / exit=0

  • uv run --project plugins/playwright-kit/skills/playwright-kit-ops --with pytest pytest . -q(順)→ 5333 passed / exit=0

  • uv run --with pytest --with pytest-xdist pytest scripts/tests plugins/ndf -q -n 4 → 5149 passed / exit=0

  • --with pytest-xdist を省いて -n を渡すと unrecognized arguments: -n で exit=4(開発ガイドに書いた挙動の確認)

  • 検出力の確認: ndf_lock_acquire の排他を外すと、寄せた test_many_at_once_never_share_the_critical_section(重なり 3 件)と test_records_at_once_never_skip_a_stage が落ちる。排他を無視させると test_lock_held_passes が落ちる(確認後に元へ戻した)

  • python3 scripts/check-markdown-links.py --root . → exit=0

  • python3 scripts/check-doc-staleness.py --root . → exit=0

  • SHARD_TOTAL=2 SHARD_INDEX=0/1-n 4taskset -c 0-3)→ 2085 + 3248 = 5333 passed / 各 exit=0、各 28〜30 秒

  • SHARD_TOTAL=2 SHARD_INDEX=2 → 範囲の誤りを示して exit=4

  • CI の pytest (0/2) / pytest (1/2) / pytest が合格し、全検査 17 件が pass。所要は変更前の約 24%

  • 実装レビュー(cross-review、codex / kiro): round 1 で codex が分割の検査の不足を指摘(08540b27 で対応)、round 2 で両者 APPROVE。未解決の指摘 0 件

  • uv run --with pytest --with pytest-xdist pytest scripts/tests/test_root_conftest.py -q → 18 passed。分け方を壊すと追加したテストが落ちることを確かめた(確認後に元へ戻した)

  • 08540b2uv run --with pytest --with pytest-xdist pytest scripts/tests plugins/ndf -q -n 4 → 5150 passed / exit=0(2026-09-23 06:12)

  • python3 scripts/check-skill-frontmatter.py / python3 plugins/ndf/scripts/instructions-check.py --root . / claude plugin validate . → 各 exit=0

  • 08540b2 の CI(run 35825281051)で全検査 17 件が pass

🤖 Generated with Claude Code

https://claude.ai/code/session_01G5uEPdcjhFR1Aerv5JMfpP

takemi-ohama and others added 2 commits September 23, 2026 05:50
- 継続的統合の全体テストを -n auto で回す。release/** の push 契機を外し、同じテストの 2 重実行をやめる
- 全体テストを案内するコマンドを並列の形にする(CONTRIBUTING.md・PR テンプレート・開発ガイド・確定仕様 2 件)
- 臨界区間の競合試験を共通実装への 1 通り(並列 12・試行 3)へ寄せる
- test_records_at_once_never_skip_a_stage の試行を 8 → 4 回、test_lock_held_passes を 4 → 3 回にする

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G5uEPdcjhFR1Aerv5JMfpP
並列にした後もジョブが 2 分 6 秒で 2 分を超えたため、#882 の段 2 を行う。
根の conftest.py が SHARD_TOTAL / SHARD_INDEX からファイルのパスの剰余で自分の分を選び、
まとめジョブ pytest が ruleset の必須の検査として 1 つの結果を返す。

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G5uEPdcjhFR1Aerv5JMfpP
@takemi-ohama takemi-ohama changed the title テスト: 全体テストを並列で回し、重複した競合試験と繰り返しを減らす(#882 #884) テスト: 全体テストを並列・2 分割で回し、重複した競合試験と繰り返しを減らす(#882 #884) Sep 23, 2026

@takemi-ohama takemi-ohama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 cross-review | round 1 | codex | REQUEST_CHANGES

CI の分割でテスト欠落を起こさないことを自動検証する必要があります。

Comment thread conftest.py

@takemi-ohama takemi-ohama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 cross-review | round 1 | kiro | APPROVE

テスト高速化(#882 / #884)の変更を確認した。CI のシャード分割・集約ゲート・conftest のシャード選別・競合試験の集約・試行回数の削減のいずれも、根拠が揃っており修正を要する欠陥は見つからなかった。シャード分割は 245 テストファイルで排他かつ網羅(重複・欠落なし)であること、env 検証が total=0 / index>=total / 負数を拒否することを実測で確認した。競合試験の集約は wf_lock_acquire / wt_lock_acquire がともに ndf_lock_acquire への 1 行委譲であることを確認済みで、カバレッジの実質的な欠落はない。

SHARD_TOTAL=2 の各 shard と未分割の収集を実際に比べ、和の一致・重複なし・
同一ファイルが複数 shard に割れないことを検証する(#891 のレビュー指摘)。

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01G5uEPdcjhFR1Aerv5JMfpP
@takemi-ohama

Copy link
Copy Markdown
Contributor Author

🔧 /ndf:fix サマリ | round 1 | commit 08540b2

対応件数: critical=0 / major=1 / minor=0(合計 1 件)
決着: 1 件 / 見送り: 0 件 / 却下: 0 件
CI: SUCCESS

@takemi-ohama takemi-ohama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 cross-review | round 2 | codex | APPROVE

修正が必要な指摘はありません。

@takemi-ohama takemi-ohama left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤖 cross-review | round 2 | kiro | APPROVE

テスト高速化(#882 shard 分割 + -n auto 並列化、#884 重複競合試験の集約と繰り返し削減、release/** の push 契機除去)。変更範囲は PR の目的と一貫しており、指摘すべき修正アクションは検出されなかった。安全性の核となる主張(AC5: de-parametrize した競合試験が排他破壊を検出する)を実機で確認済み: lock-common.sh の 2 段目の関門 _ndf_lock_hold を無効化した状態で test_many_at_once_never_share_the_critical_section(parallel=12, trials=3)が overlap 3 件で失敗、その後ファイルは git clean に復元。shard + xdist の組合せ実行で 2086+3248=5334 件が未分割の全件と一致し、CI 集約ジョブ(needs.pytest-shard.result = success + if: always())の判定も GitHub の matrix 集約仕様に沿って正しい。

@takemi-ohama

Copy link
Copy Markdown
Contributor Author

🔧 /ndf:fix サマリ | commit (なし)

対応件数: critical=0 / major=0 / minor=0(合計 0 件)
決着: 0 件 / 見送り: 0 件 / 却下: 0 件
CI: NONE

@takemi-ohama
takemi-ohama marked this pull request as ready for review September 23, 2026 06:14
@takemi-ohama
takemi-ohama merged commit 9117955 into develop Sep 23, 2026
18 checks passed
@takemi-ohama
takemi-ohama deleted the test/issue-882-884-test-speedup branch September 23, 2026 06:15
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