| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
Refactor: testing system overhaul — network marker, nightly 4-phase pipeline, config drift check, and in-process CLI coverage Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !281 merge fix-tests into develop Refactor: testing system overhaul — network marker, nightly 4-phase pipeline, config drift check, and in-process CLI coverage Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 🔍 Motivation / 变更动机 The current msmodeling testing system has several structural weaknesses: UT/ST responsibilities are blurred, slow test cases are concentrated, Hub access is uncontrolled, and CLI tests running via subprocess are invisible to coverage collection. This PR completes a testing system overhaul by introducing a network marker to isolate live-Hub tests, splitting nightly into a four-phase pipeline with a non-blocking config drift check, centralizing model/config caching, and replacing subprocess CLI invocations with in-process runners so coverage and test_map can observe the real execution paths. ------ ## 📝 Modification / 修改内容 ### Design Document (docs/design/ut_refactor.md) - Introduce third cross-cutting marker network alongside nightly and npu - Change CI incremental marker from not npu and not nightly to not npu and not nightly and not network - Nightly pipeline expands from three phases to four: Phase 1 (test_map UT), Phase 2a (nightly), Phase 2b (benchmark), Phase 2c (network with live Hub) - Add non-blocking config drift check after Phase 2c comparing vendored remote configs against live Hub - CI gate no longer enforces coverage thresholds (moved to nightly report-only); remove per-symbol coverage advisory from CI path - Remove MIN_LINES_PER_SYMBOL threshold; collect_from_coverage now registers any hit - Coverage gate thresholds changed from 70/50 (blocking) to 60/40 (nightly report-only) - Session model cache centralized to tests/helpers/model_cache.py - Shell scripts use -q --tb=short instead of -vv - Feishu payload now includes per-phase breakdown, slowest tests, and config drift warnings - Gate policy format changed from gate_policy.json to gate_policy.yaml ### pyproject.toml - Register network marker; global addopts now excludes npu, nightly, and network ### CI Gate (scripts/helpers/ci_gate/) - diff.py: classify modified test files (modified_test field) - models.py: add modified_test to ChangeSet - rules.py: gate_new_tests now includes modified_test paths - main.py: remove coverage gate enforcement and per-symbol advisory; modified tests are re-run and re-mapped via Phase 0; pytest runs with -vv instead of -q --no-header ### Nightly (scripts/helpers/nightly/) - main.py: four-phase pipeline with Phase 2c (network), config drift check, Feishu-aware console suppression - feishu_notifier.py: payload extended with per-phase breakdown, slowest tests, and drift warnings - pytest_parser.py: add parse_junit_file and slowest_testcases ### Coverage Helpers - build_test_map.py: remove MIN_LINES_PER_SYMBOL=3 filter - coverage_gate.py: docstring clarification (threshold check only, not gate) ### Execution Scripts - All run_*.sh: adopt not npu and not network marker (plus not nightly for ci_gate); switch from -vv to -q --tb=short - run_nightly.sh: updated for four-phase pipeline and config drift check ### Test Infrastructure - tests/helpers/model_cache.py: centralized session-scoped caches for HF configs and built models - tests/helpers/cli_runner.py: in-process CLI runner for coverage visibility - tests/conftest.py: add _seed_rng and _restore_environ autouse fixtures; cfg_registry delegates to model_cache - tests/regression/tensor_cast/conftest.py: delegate to model_cache - tests/README.md: comprehensive update covering all changes ### Test Coverage - tests/regression/cli/test_op_replay.py: switch from subprocess/ast parsing to real imports - tests/regression/cli/test_throughput_optimizer.py: switch to in-process runner - tests/regression/serving_cast/test_main_st.py: switch to in-process runner - tests/regression/scripts/helpers/: new tests for modified_test classification, network marker, drift check, phase breakdown payload, slowest tests - tests/regression/tensor_cast/test_auto_model_config.py: split local and network-marked remote test cases ------ ## 📐 Associated Test Results / 关联测试结果 All unit tests covering the helper modules (ci_gate, nightly, test_map) pass: tests/regression/scripts/helpers/ci_gate/ — all passed tests/regression/scripts/helpers/nightly/ — all passed tests/regression/scripts/helpers/common/ — all passed tests/helpers/tests/ — all passed tests/regression/cli/ — all passed tests/regression/web_ui/ — all passed CLI tests migrated to in-process runner (tests/helpers/cli_runner.py) show full coverage on core paths that were previously invisible. ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!281 | 25 天前 | |
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 | |
【FIX】修复 nightly Feishu 误报与 web_ui conftest 全局污染 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !306 merge issue-fix into develop 【FIX】修复 nightly Feishu 误报与 web_ui conftest 全局污染 Created-by: AvadaKedavrua Commit-by: AvadaKedavrua;liujiawang Merged-by: ascend-robot Description: ## 修改原因 1. **#97 nightly Feishu 误报**:pytest 各 phase exit=1(collection/import 失败)但 JUnit 为空时,Feishu 仍显示 All passed / Passed: 0 | Failed: 0。 2. **#96 web_ui conftest 污染**:tests/regression/web_ui/conftest.py 在 import 时 sys.modules["tensor_cast"] = MagicMock(),xdist 全量收集时污染全局模块,触发 tensor_cast.__spec__ is not set。 3. **transformers 5.8.0**:deepseek_v4 重复注册导致 collection 失败。 --- ## 修改内容 ### Nightly 报告(#97) - FeishuReportInput / PhaseBreakdownEntry 结构化报告输入 - build_phase_breakdown()、resolve_first_error()、extract_pytest_log_snippet() 解析 phase log - Feishu payload 按 overall_exit + errors 判定状态,展示 per-phase breakdown 与 infra failure - 新增/更新 tests/regression/scripts/helpers/nightly/ 回归用例 ### Conftest 与 CI Gate(#96) - 移除 web_ui/conftest.py 模块级 sys.modules mock - is_config_path() 匹配 tests/**/conftest.py,conftest 变更触发全量回归 - 新增 tests/smoke/test_conftest_hygiene.py 守卫 ### 测试规范补强 - 新增 tests/helpers/junit_xml.py 共享 JUnit XML 构造 - 新增四 phase 全 infra failure 集成测 test_emit_report_four_phase_all_infra_failure ### 其他 - transformers 上限 <5.8.0 - pytest xdist 默认 --dist=worksteal(scripts/lib/common.sh 与各 run_*.sh) - 更新 tests/README.md / tests/SKILL.md / docs/design/ut_refactor.md --- ## 自验证 ### Nightly 工具链 UT collect-only 目的:确认新增/重构用例可被 pytest 正常收集,无 import 错误。 步骤: 1. 同步 CI 依赖: bash uv sync --frozen --group ci 2. 仅收集 nightly 回归用例: bash uv run pytest tests/regression/scripts/helpers/nightly/ --collect-only -q 结果: 85 tests collected in 0.04s ### Lint / 类型检查 目的:确认改动文件符合项目 ruff / mypy 要求。 步骤:对以下路径执行 MCP lint 与 type_check(explicit_package_bases=true): - scripts/helpers/nightly/*.py - tests/helpers/junit_xml.py - tests/regression/scripts/helpers/nightly/test_*.py 结果: ruff: clean mypy: clean (follow-imports=skip, explicit-package-bases) ### Conftest 卫生(#96 回归场景) 目的:验证 web_ui conftest 不再污染 tensor_cast.__spec__。 步骤: bash uv run pytest tests/smoke/test_conftest_hygiene.py -q 结果:该用例在 dfb66f0 提交中已添加;全量回归由用户在远端环境验证通过(见会话记录)。 See merge request: Ascend/msmodeling!306 | 20 天前 | |
Refactor: testing system overhaul — network marker, nightly 4-phase pipeline, config drift check, and in-process CLI coverage Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !281 merge fix-tests into develop Refactor: testing system overhaul — network marker, nightly 4-phase pipeline, config drift check, and in-process CLI coverage Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 🔍 Motivation / 变更动机 The current msmodeling testing system has several structural weaknesses: UT/ST responsibilities are blurred, slow test cases are concentrated, Hub access is uncontrolled, and CLI tests running via subprocess are invisible to coverage collection. This PR completes a testing system overhaul by introducing a network marker to isolate live-Hub tests, splitting nightly into a four-phase pipeline with a non-blocking config drift check, centralizing model/config caching, and replacing subprocess CLI invocations with in-process runners so coverage and test_map can observe the real execution paths. ------ ## 📝 Modification / 修改内容 ### Design Document (docs/design/ut_refactor.md) - Introduce third cross-cutting marker network alongside nightly and npu - Change CI incremental marker from not npu and not nightly to not npu and not nightly and not network - Nightly pipeline expands from three phases to four: Phase 1 (test_map UT), Phase 2a (nightly), Phase 2b (benchmark), Phase 2c (network with live Hub) - Add non-blocking config drift check after Phase 2c comparing vendored remote configs against live Hub - CI gate no longer enforces coverage thresholds (moved to nightly report-only); remove per-symbol coverage advisory from CI path - Remove MIN_LINES_PER_SYMBOL threshold; collect_from_coverage now registers any hit - Coverage gate thresholds changed from 70/50 (blocking) to 60/40 (nightly report-only) - Session model cache centralized to tests/helpers/model_cache.py - Shell scripts use -q --tb=short instead of -vv - Feishu payload now includes per-phase breakdown, slowest tests, and config drift warnings - Gate policy format changed from gate_policy.json to gate_policy.yaml ### pyproject.toml - Register network marker; global addopts now excludes npu, nightly, and network ### CI Gate (scripts/helpers/ci_gate/) - diff.py: classify modified test files (modified_test field) - models.py: add modified_test to ChangeSet - rules.py: gate_new_tests now includes modified_test paths - main.py: remove coverage gate enforcement and per-symbol advisory; modified tests are re-run and re-mapped via Phase 0; pytest runs with -vv instead of -q --no-header ### Nightly (scripts/helpers/nightly/) - main.py: four-phase pipeline with Phase 2c (network), config drift check, Feishu-aware console suppression - feishu_notifier.py: payload extended with per-phase breakdown, slowest tests, and drift warnings - pytest_parser.py: add parse_junit_file and slowest_testcases ### Coverage Helpers - build_test_map.py: remove MIN_LINES_PER_SYMBOL=3 filter - coverage_gate.py: docstring clarification (threshold check only, not gate) ### Execution Scripts - All run_*.sh: adopt not npu and not network marker (plus not nightly for ci_gate); switch from -vv to -q --tb=short - run_nightly.sh: updated for four-phase pipeline and config drift check ### Test Infrastructure - tests/helpers/model_cache.py: centralized session-scoped caches for HF configs and built models - tests/helpers/cli_runner.py: in-process CLI runner for coverage visibility - tests/conftest.py: add _seed_rng and _restore_environ autouse fixtures; cfg_registry delegates to model_cache - tests/regression/tensor_cast/conftest.py: delegate to model_cache - tests/README.md: comprehensive update covering all changes ### Test Coverage - tests/regression/cli/test_op_replay.py: switch from subprocess/ast parsing to real imports - tests/regression/cli/test_throughput_optimizer.py: switch to in-process runner - tests/regression/serving_cast/test_main_st.py: switch to in-process runner - tests/regression/scripts/helpers/: new tests for modified_test classification, network marker, drift check, phase breakdown payload, slowest tests - tests/regression/tensor_cast/test_auto_model_config.py: split local and network-marked remote test cases ------ ## 📐 Associated Test Results / 关联测试结果 All unit tests covering the helper modules (ci_gate, nightly, test_map) pass: tests/regression/scripts/helpers/ci_gate/ — all passed tests/regression/scripts/helpers/nightly/ — all passed tests/regression/scripts/helpers/common/ — all passed tests/helpers/tests/ — all passed tests/regression/cli/ — all passed tests/regression/web_ui/ — all passed CLI tests migrated to in-process runner (tests/helpers/cli_runner.py) show full coverage on core paths that were previously invisible. ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!281 | 25 天前 | |
Refactor: testing system overhaul — network marker, nightly 4-phase pipeline, config drift check, and in-process CLI coverage Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !281 merge fix-tests into develop Refactor: testing system overhaul — network marker, nightly 4-phase pipeline, config drift check, and in-process CLI coverage Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: ## 🔍 Motivation / 变更动机 The current msmodeling testing system has several structural weaknesses: UT/ST responsibilities are blurred, slow test cases are concentrated, Hub access is uncontrolled, and CLI tests running via subprocess are invisible to coverage collection. This PR completes a testing system overhaul by introducing a network marker to isolate live-Hub tests, splitting nightly into a four-phase pipeline with a non-blocking config drift check, centralizing model/config caching, and replacing subprocess CLI invocations with in-process runners so coverage and test_map can observe the real execution paths. ------ ## 📝 Modification / 修改内容 ### Design Document (docs/design/ut_refactor.md) - Introduce third cross-cutting marker network alongside nightly and npu - Change CI incremental marker from not npu and not nightly to not npu and not nightly and not network - Nightly pipeline expands from three phases to four: Phase 1 (test_map UT), Phase 2a (nightly), Phase 2b (benchmark), Phase 2c (network with live Hub) - Add non-blocking config drift check after Phase 2c comparing vendored remote configs against live Hub - CI gate no longer enforces coverage thresholds (moved to nightly report-only); remove per-symbol coverage advisory from CI path - Remove MIN_LINES_PER_SYMBOL threshold; collect_from_coverage now registers any hit - Coverage gate thresholds changed from 70/50 (blocking) to 60/40 (nightly report-only) - Session model cache centralized to tests/helpers/model_cache.py - Shell scripts use -q --tb=short instead of -vv - Feishu payload now includes per-phase breakdown, slowest tests, and config drift warnings - Gate policy format changed from gate_policy.json to gate_policy.yaml ### pyproject.toml - Register network marker; global addopts now excludes npu, nightly, and network ### CI Gate (scripts/helpers/ci_gate/) - diff.py: classify modified test files (modified_test field) - models.py: add modified_test to ChangeSet - rules.py: gate_new_tests now includes modified_test paths - main.py: remove coverage gate enforcement and per-symbol advisory; modified tests are re-run and re-mapped via Phase 0; pytest runs with -vv instead of -q --no-header ### Nightly (scripts/helpers/nightly/) - main.py: four-phase pipeline with Phase 2c (network), config drift check, Feishu-aware console suppression - feishu_notifier.py: payload extended with per-phase breakdown, slowest tests, and drift warnings - pytest_parser.py: add parse_junit_file and slowest_testcases ### Coverage Helpers - build_test_map.py: remove MIN_LINES_PER_SYMBOL=3 filter - coverage_gate.py: docstring clarification (threshold check only, not gate) ### Execution Scripts - All run_*.sh: adopt not npu and not network marker (plus not nightly for ci_gate); switch from -vv to -q --tb=short - run_nightly.sh: updated for four-phase pipeline and config drift check ### Test Infrastructure - tests/helpers/model_cache.py: centralized session-scoped caches for HF configs and built models - tests/helpers/cli_runner.py: in-process CLI runner for coverage visibility - tests/conftest.py: add _seed_rng and _restore_environ autouse fixtures; cfg_registry delegates to model_cache - tests/regression/tensor_cast/conftest.py: delegate to model_cache - tests/README.md: comprehensive update covering all changes ### Test Coverage - tests/regression/cli/test_op_replay.py: switch from subprocess/ast parsing to real imports - tests/regression/cli/test_throughput_optimizer.py: switch to in-process runner - tests/regression/serving_cast/test_main_st.py: switch to in-process runner - tests/regression/scripts/helpers/: new tests for modified_test classification, network marker, drift check, phase breakdown payload, slowest tests - tests/regression/tensor_cast/test_auto_model_config.py: split local and network-marked remote test cases ------ ## 📐 Associated Test Results / 关联测试结果 All unit tests covering the helper modules (ci_gate, nightly, test_map) pass: tests/regression/scripts/helpers/ci_gate/ — all passed tests/regression/scripts/helpers/nightly/ — all passed tests/regression/scripts/helpers/common/ — all passed tests/helpers/tests/ — all passed tests/regression/cli/ — all passed tests/regression/web_ui/ — all passed CLI tests migrated to in-process runner (tests/helpers/cli_runner.py) show full coverage on core paths that were previously invisible. ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [x] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 See merge request: Ascend/msmodeling!281 | 25 天前 | |
【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Co-authored-by: liujiawang<anonymousdev@163.com> # message auto-generated for no-merge-commit merge: !266 merge refactor-tests into develop 【REFACTOR】【TESTS】重构 tests 目录并补充 smoke 测试 Created-by: AvadaKedavrua Commit-by: liujiawang;AvadaKedavrua Merged-by: ascend-robot Description: # PR Template Thanks for your contribution; we appreciate it a lot. The following instructions will make your pull request healthier and help you get feedback more easily. If you do not understand some items, don't worry, just make the pull request and seek help from maintainers. 感谢您的贡献,我们非常重视。以下说明将使您的拉取请求更健康,更易于获得反馈。如果您不理解某些项目,请不要担心,只需提交拉取请求并从维护人员那里寻求帮助即可。 **PR Type / PR类型** - [x] Feature(功能新增) - [x] Bugfix(Bug 修复) - [x] Docs(文档更新) - [x] CI/CD(持续集成/持续部署) - [x] Refactor(代码重构) - [x] Perf(性能优化) - [x] Test-Cases(测试用例更新) - [ ] Other(其他) ## 🔍 Motivation / 变更动机 现有 UT 目录混合了 smoke、regression、benchmark、模型配置资产和脚本测试,导致本地执行入口不统一、CI 无法稳定做增量选择,nightly 也缺少统一的 test_map 刷新和报告链路。旧的 tests/run_ut.sh 入口难以表达“快速 smoke / 完整 regression / benchmark / PR gate / nightly”这些不同场景,新增或删除源码时也缺少基于 test_map 的覆盖检查。 本 PR 目标是把测试体系拆成清晰分层,并补齐 CI gate、nightly、coverage gate、test_map 构建和文档,让开发者和流水线都能按同一套目录与脚本执行测试。同时修复整理过程中暴露出的少量模型配置、serving 输出文本和文档问题。 ------ ## 📝 Modification / 修改内容 本次按 hunk/主题重新整理为 17 个提交,主要修改如下: - 重构测试目录:将旧 tests/test_tensor_cast、serving_cast/tests、web_ui/tests、tests/tools、tests/perf_database、tests/st 拆分到 tests/smoke/、tests/regression/、tests/benchmark/。 - 统一测试资产:将模型配置移动到 tests/assets/model_config/,同步更新 pre-commit exclude、缓存目录和文档说明。 - 新增共享测试 helper:补充断言、配置工厂、fake subprocess、模型构造、op registry 等公共测试工具,减少测试重复代码。 - 新增 CI gate helper:增加 diff 分类、test_map 读取、AST 符号映射、coverage gate、增量测试选择和 gate policy 配置。 - 新增 nightly helper:增加 pytest 结果解析、报告模型、报告构建、Feishu webhook 通知、test_map 刷新和 benchmark 调度入口。 - 新增统一脚本入口:新增 scripts/run_smoke.sh、scripts/run_regression.sh、scripts/run_benchmark.sh、scripts/run_ci_gate.sh、scripts/run_nightly.sh,替换旧 tests/run_ut.sh。 - 更新配置与文档:补充 pyproject.toml 的 pytest marker/testpaths/filterwarnings,更新 README.md、tests/README.md、docs/en/web_ui.md、web_ui/README.md、tools/perf_data_collection/README.md。 - 修复模型/输出细节:为 DeepseekV32DecoderLayer 注册 config_class;规范 serving_cast optimizer summary 的冒号和 runner 日志文案。 ### 后续 UT 怎么上 - 新增快速兜底用例放到 tests/smoke/:覆盖导入、基础 compile path、轻量 config resolver、轻量 serving/tensor_cast 主路径,要求无 NPU、无大模型权重、反馈快,适合每个 PR 先跑。 - 新增功能回归用例放到 tests/regression/<domain>/:按 tensor_cast、serving_cast、cli、web_ui、scripts/helpers 等领域归档,覆盖具体 bugfix、边界条件、行为契约和工具脚本逻辑。 - 新增长耗时或性能相关用例放到 tests/benchmark/:模型基准、perf_database、trace/CSV 性能数据处理等不阻塞普通 PR gate 的测试归到 benchmark 层。 - 新增模型配置、fixture、样例数据优先放到 tests/assets/ 或就近 fixtures/,避免继续散落在测试包内部;大文件或生成缓存走 .msmodeling_cache/、tests/assets/cache/,不直接进入源码目录。 - 新测试默认使用 tests/helpers/ 的公共构造器和断言工具;需要 fake subprocess、模型配置、op registry 时复用已有 helper,减少每个测试重复 mock 和手写配置。 - 需要 NPU 的用例必须打 @pytest.mark.npu;只应 nightly 跑的大模型/长耗时 compile 用例打 @pytest.mark.nightly,避免进入默认本地和 PR 快速路径。 ### 怎么根据语义上 UT - 测试不再只按文件名机械归类,而是按“被测语义”挂到对应源码符号:产品源码的函数、类、方法、顶层行为需要在 test_map 中映射到验证它的测试 nodeid。 - 新增产品源码时,如果是可执行逻辑,应新增对应 smoke 或 regression 用例,并让 test_map 能找到该源码/符号;确实不需要测试的符号需要在 exemption 中写明原因。 - 修改已有源码时,CI gate 会用 AST 定位变更行落在哪个 top-level definition 或 class/method span,再通过 test_map 选择关联测试;如果符号没有映射,会阻断或扩大测试范围,避免“改了逻辑但没跑语义相关 UT”。 - 删除源码时,CI gate 会检查 test_map 中是否仍有引用该源码的测试,防止遗留无效映射;删除测试时也会检查是否破坏已有源码覆盖关系。 - 跨层依赖变更会按语义优先选择所属 regression layer,无法明确归属或配置变更时升级为更完整的套件,保证增量选择不会漏测。 - test_map 由 nightly 在完整测试通过后刷新,PR gate 消费稳定版本;这样避免每个 PR 临时生成不可信映射,同时让语义映射随主干测试演进。 ### 流水线做了什么调整 - 本地与 CI 统一入口:run_smoke.sh 跑快速 smoke,run_regression.sh 跑完整 regression,run_benchmark.sh 跑 benchmark,run_ci_gate.sh 跑 PR 增量门禁,run_nightly.sh 跑夜间全流程。 - PR gate 从“固定跑一批 UT”改为“diff -> classify changes -> load test_map -> apply gate rules -> run selected pytest -> coverage gate”。配置变更、源码新增/删除、测试新增/删除、源码修改会走不同 gate 规则。 - coverage gate 统一读取 MSMODELING_TEST_LINE_THRESHOLD 和 MSMODELING_TEST_BRANCH_THRESHOLD,默认 line 70、branch 50;pytest 默认排除 npu,PR gate 额外排除 nightly。 - nightly 分两阶段:先跑非 NPU、非 nightly 的 smoke/regression 并在通过后刷新 test_map;再跑 nightly 标记用例与 benchmark,并构建结构化报告。 - 流水线统一支持 MSMODELING_OFFLINE、MSMODELING_TEST_WEIGHTS_PRUNE、MSMODELING_TEST_MAP_PATH 等环境变量,减少不同脚本各自处理缓存、离线和权重清理的差异。 - benchmark 不纳入普通 coverage gate,避免性能/长耗时用例拖慢 PR 门禁;必要时可通过独立 benchmark pipeline 或 nightly 验证。 - pre-commit exclude 同步到新目录,模型配置资产和 fixtures 不再被无意义格式化或误报。 已处理问题清单: - 旧 UT 入口单一,无法区分 smoke、regression、benchmark、nightly 和 PR gate。 - 模型配置资产散落在测试用例目录下,pre-commit 与测试引用路径容易漂移。 - 新增/删除源码缺少 test_map 覆盖检查,CI 不能精准阻断未补测试的变更。 - coverage 阈值、pytest marker、离线模式、权重缓存清理等 CI 参数缺少统一入口。 - nightly 缺少结构化报告、失败摘要和 Feishu 通知链路。 - web UI 测试仍在模块内,未纳入统一 regression 层级。 - DeepseekV32DecoderLayer 缺少 config_class,影响配置类识别一致性。 - serving_cast 部分日志/summary 文案有多余空格或表达不统一。 ------ ## 📐 Associated Test Results / 关联测试结果 提交过程中每个 commit 均触发 pre-commit hook,已通过已检查文件的 trailing whitespace、EOF、YAML/JSON、大文件、merge conflict、private key、ruff、ruff-format、codespell、pylint、bandit、typos 等检查。 本地未额外执行完整 smoke/regression/benchmark 全量测试;推送后以 GitCode CI 结果为准。建议重点关注: - bash ./scripts/run_smoke.sh - bash ./scripts/run_regression.sh - bash ./scripts/run_ci_gate.sh(需设置 MSMODELING_TEST_MAP_PATH) - bash ./scripts/run_nightly.sh(需设置 MSMODELING_TEST_MAP_PATH) ------ ## 🌟 Use cases (Optional) / 使用案例(可选) - 本地快速验证:开发者运行 bash ./scripts/run_smoke.sh 获取快速反馈。 - 本地完整回归:开发者运行 bash ./scripts/run_regression.sh 覆盖主要回归用例。 - PR 增量门禁:CI 设置 MSMODELING_TEST_MAP_PATH 后运行 bash ./scripts/run_ci_gate.sh,按 diff 与 test_map 选择用例并执行 coverage gate。 - 夜间任务:nightly 先跑非 nightly 的 smoke/regression 并刷新 test_map,再执行 nightly/benchmark 并生成报告,可选 Feishu 通知。 ------ ## ✅ Checklist / 检查列表 **Before PR**: - [x] Bug fixes are fully covered by unit tests, the case that causes the bug should be added in the unit tests. / 修复的 Bug 已完全由单元测试覆盖,导致 Bug 的情况应在单元测试中添加。 - [ ] The modification is covered by complete unit tests. If not, please add more unit tests to ensure the correctness. / 此拉取请求中的修改已完全由单元测试覆盖。如果不是,请添加更多单元测试以确保正确性。 - [x] All relevant documentation (API docs, docstrings, example tutorials) has been updated to reflect these changes. / 所有相关文档(API 文档、文档字符串、示例教程)已更新以反映这些更改。 - [x] Please ensure code files contain no Chinese comments. / 请保证代码文件中不含中文注释。 ------ See merge request: Ascend/msmodeling!266 | 27 天前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 27 天前 | ||
| 27 天前 | ||
| 27 天前 | ||
| 25 天前 | ||
| 27 天前 | ||
| 27 天前 | ||
| 20 天前 | ||
| 25 天前 | ||
| 25 天前 | ||
| 27 天前 |