[CI]【Hackathon 10th Spring No.36】worker_process unit test [cf]#7694
[CI]【Hackathon 10th Spring No.36】worker_process unit test [cf]#7694ghost wants to merge 1 commit intoPaddlePaddle:developfrom
Conversation
|
Thanks for your contribution! |
CI报告基于以下代码生成(30分钟更新一次): 1 任务总览当前 2 个已执行任务全部通过,无 Required 任务失败。但有 7 个 Workflow 处于
2 任务状态汇总2.1 Required 任务:0/0 通过
当前未检测到 Required 任务(GitHub Branch Protection Rules 中未配置,或 API 权限不足)。 2.2 可选任务 — 2/2 通过
3 失败详情(仅 required)无 required 失败任务。 |
PaddlePaddle-bot
left a comment
There was a problem hiding this comment.
🤖 Paddle-CI-Agent | pr_review |
2026-05-03 21:42:19
📋 Review 摘要
PR 概述:重构 tests/worker/test_worker_process.py,大幅扩展 worker_process 模块的单元测试覆盖面(从 278 行扩展至 419 行)。
变更范围:tests/worker/
影响面 Tag:[CI]
📝 PR 规范检查
标题中 [CI] 为官方合法 Tag,但末尾附有 [cf] 后缀,不属于官方 Tag 列表,建议删除。PR 描述仅为 placeholder,缺少所有必填 section(Motivation / Modifications / Usage or Command / Accuracy Tests / Checklist),需补充完整。
标题建议(可直接复制):
[CI] Add unit tests for worker_process module
PR 描述建议(可直接复制,必须复刻 checklist §D2 模板的完整结构):
## Motivation
为 `fastdeploy/worker/worker_process.py` 补充全面的单元测试,提升该模块的测试覆盖率,满足 Hackathon 10th Spring No.36 任务要求。
## Modifications
- 重构 `tests/worker/test_worker_process.py`,从 278 行扩展至 419 行
- 新增 `_cfg()` / `_make()` / `_fd_env()` 辅助函数,减少重复 mock 代码
- 新增 `TestWorkerUtils` 类,覆盖 `intercept_paddle_loggers`、`parse_args`、`get_worker`、`update_fd_config_for_mm`、`init_distributed_environment`、`initialize_fd_config` 等工具函数
- 新增 `TestPaddleDisWorkerProc` 类,覆盖构造函数、健康检查、KV Cache 初始化、EPLB、控制方法、barrier/broadcast、kvcache lock、`run_worker_proc` 等核心流程
## Usage or Command
N/A
## Accuracy Tests
N/A
## Checklist
- [x] Add at least a tag in the PR title.
- Tag list: [`[FDConfig]`,`[APIServer]`,`[Engine]`, `[Scheduler]`, `[PD Disaggregation]`, `[Executor]`, `[Graph Optimization]`, `[Speculative Decoding]`, `[RL]`, `[Models]`, `[Quantization]`, `[Loader]`, `[OP]`, `[KVCache]`, `[DataProcessor]`, `[BugFix]`, `[Docs]`, `[CI]`, `[Optimization]`, `[Feature]`, `[Benchmark]`, `[Others]`, `[XPU]`, `[HPU]`, `[GCU]`, `[DCU]`, `[Iluvatar]`, `[Metax]`]
- You can add new tags based on the PR content, but the semantics must be clear.
- [ ] Format your code, run `pre-commit` before commit.
- [x] Add unit tests. Please write the reason in this PR if no unit tests.
- [ ] Provide accuracy results.
- [ ] If the current PR is submitting to the `release` branch, make sure the PR has been submitted to the `develop` branch, then cherry-pick it to the `release` branch with the `[Cherry-Pick]` PR tag.问题
| 级别 | 文件 | 概述 |
|---|---|---|
| 📝 PR 规范 | — | PR 描述为 placeholder,所有必填 section 缺失;标题末尾含非官方后缀 [cf] |
| 🟡 建议 | tests/worker/test_worker_process.py |
原 test_intercept_paddle_loggers_non_paddle_logger_unchanged 场景在重构后被删除,non-paddle 前缀 logger 的不受影响行为不再有专项验证 |
| ❓ 疑问 | tests/worker/test_worker_process.py |
_cfg() 使用 types.SimpleNamespace 模拟 FDConfig,跳过了 FDConfig.__init__ 内部的字段校验逻辑,真实的参数约束可能在测试中被绕过 |
🟡 建议详情(
tests/worker/test_worker_process.py)原有
test_intercept_paddle_loggers_non_paddle_logger_unchanged测试验证了当 context manager 激活时,非paddle.*前缀的 logger 的 handler 列表不会被修改。本次重构将四个独立用例合并为一个test_intercept_paddle_loggers,删去了 non-paddle 场景,建议补回该断言:# 在 test_intercept_paddle_loggers 末尾追加 other_lg = logging.getLogger("other.test.check") other_lg.addHandler(logging.StreamHandler()) cnt = len(other_lg.handlers) with intercept_paddle_loggers(): self.assertEqual(len(logging.getLogger("other.test.check").handlers), cnt) other_lg.handlers = []
总体评价
测试重构思路清晰,_cfg() / _make() / _fd_env() 辅助函数有效降低了样板代码,新增的测试场景(KV Cache 分支、EPLB、dispatch)覆盖面有显著提升。主要需修复 PR 描述占位符,并补回 non-paddle logger 隔离性的验证场景。
placeholder