Skip to content

[CI]【Hackathon 10th Spring No.36】worker_process unit test#7324

Open
r-cloudforge wants to merge 18 commits intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-036-worker-process-test-v2
Open

[CI]【Hackathon 10th Spring No.36】worker_process unit test#7324
r-cloudforge wants to merge 18 commits intoPaddlePaddle:developfrom
CloudForge-Solutions:task/h10-036-worker-process-test-v2

Conversation

@r-cloudforge
Copy link
Copy Markdown

Motivation

No.36 功能模块 fastdeploy/worker/worker_process.py 单测补充

Modifications

add unittest tests/worker/test_worker_process.py

develop 分支:覆盖率61%,Miss行数169(85-87, 92-111, 134, 193-209, 300-314, 317-320, 332-385, 399-436, 452-453, 464-465, 486-488, 496->505, 500, 508-558, 568, 575, 582-585, 606-608, 620, 660, 683, 693-699, 713, 740-763, 1126-1127, 1132-1143, 1170, 1205-1206, 1234, 1259-1261, 1273-1277)

当前PR:覆盖率97%,Miss行数17

注:截图为本测试文件单独运行的 pytest --cov 输出(含 branch coverage),上方文字为 develop 已有测试与本 PR 合并后的 statement 覆盖率预估值,两者统计口径不同,以 CI 合并后实际值为准。

完成单测覆盖行数 169-17 = 152 → 四舍五入 200 → 预估贡献度 0.2⭐

Usage or Command

pytest tests/worker/test_worker_process.py

Accuracy Tests

no need

Checklist

  • 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.
  • 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.

cloudforge1 and others added 18 commits March 12, 2026 23:40
…lat structure, 80% coverage

- Flatten class-based tests to flat pytest functions (32→25 tests)
- Add _run_eplb enabled path (token stats + weight update + value=None)
- Add initialize_fd_config EP branch + quant_config branch
- Add kv_cache cap at 40000, graph_optimize splitwise path
- Add run_worker_proc with deterministic mode + iluvatar dispatch
- Coverage: 69% → 80% (395/493 stmts)
Add test cases for:
- EP config with int moe_num_experts (else branch)
- Non-CUDA/XPU platform V1 scheduler fallback
- v1_loader_support fallback to default
- PaddleOCR architecture branch
- num_hidden_layers=None ValueError
- Replace 33 MagicMock instances with types.SimpleNamespace, real numpy
  arrays, and real callables (lambda/async def)
- Remove unittest.mock.MagicMock and AsyncMock imports
- Keep only unittest.mock.patch for module-level substitution
- All 21 tests pass, coverage unchanged at 80%
Per reviewer @CSWYF3634076 feedback:
- Keep all tests in unittest.TestCase classes
- Minimize mock content, use real logic
- Two classes: TestWorkerUtils (real logic) + TestPaddleDisWorkerProc
- Removed MagicMock entirely (83 → 0 references)
- Reduced patch usage (was excessive, now 35 targeted patches)
Address 3 Copilot review comments:
1. Fix double space in copyright header
2. Add # fmt: on to close the # fmt: off block after _cfg()
3. Use assertEqual instead of assertIs for integer comparison
…ker-process-test

# Conflicts:
#	tests/worker/test_worker_process.py
@paddle-bot
Copy link
Copy Markdown

paddle-bot bot commented Apr 10, 2026

Thanks for your contribution!

@paddle-bot paddle-bot bot added the contributor External developers label Apr 10, 2026
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
2 out of 3 committers have signed the CLA.

✅ CSWYF3634076
✅ EmmonsCurse
❌ cloudforge1


cloudforge1 seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown

@fastdeploy-bot fastdeploy-bot left a comment

Choose a reason for hiding this comment

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

🤖 AI Code Review | 2026-04-11 04:07 CST

📋 Review 摘要

PR 概述:为 fastdeploy/worker/worker_process.py 补充单元测试,覆盖率从 61% 提升至 97%

变更范围:新增 tests/worker/test_worker_process.py 单元测试文件

影响面 Tag[CI]

问题

级别 文件 概述
- - 未发现阻塞性问题

总体评价

这是一个高质量的单测 PR。测试设计合理,Mock 使用恰当,覆盖率提升显著(61% → 97%,贡献约 152 行覆盖)。测试代码覆盖了核心功能、边界场景和异常处理,包括多平台分发、KV Cache 初始化、EPLB 配置、控制方法执行等关键逻辑。

对于少数未覆盖的复杂场景(如 nnode > 1data_parallel_size > 1 等),由于测试难度较高且影响有限,当前覆盖率已非常出色。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor External developers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants