Pull Request已成功合入, 合并人@CANN-robot
(感谢 starchen_ 的贡献)变更摘要
此 PR 主要适配 dump 落盘文件名超过 Linux NAME_MAX(255 字节)上限的场景。当异常 dump 框架将超长文件名重命名为随机数字串并记录到 mapping.csv 后,采集侧(Collection)和解析侧(DumpDataParser)均能通过该映射表正反查找,正确收集和解析 dump 文件;同时,解析产出文件名超长时也会自动重命名并追加映射记录。
主要改动
- 新增超长文件名检测与映射表基础能力:在
Constant中新增MAX_FILE_NAME_LEN(255)和MAPPING_CSV_FILE("mapping.csv");在utils中新增parse_name_mapping_csv()解析映射 CSV,返回{原名: 映射名}字典。 - 采集侧支持按映射名收集 dump:
Collection新增_is_oversize_name()使用os.fsencode按字节判定超长;_resolve_dump_file_rename()通过mapping.csv反查映射后的随机数字串;collect_data_dump()、check_dump_data_is_valid()和check_host_and_device_kernel_name()均接受可选的rename参数,超长场景下按映射名查找文件并在收集时一并拷贝mapping.csv。 - 解析侧支持映射表反查与产出文件重命名:
DumpDataParser新增_load_name_mapping()加载 dump 目录下的映射表;parse()中按data_name反查映射后的随机数字串匹配文件,并跳过mapping.csv本身;_build_dst_file_name()通过_check_file_name_len()检测产出文件名,超长时调用_gen_random_numeric_name()生成随机数字串并通过_record_mapping()追加到mapping.csv。 - 新增
data_name字段传递原始算子名:AicErrorInfo新增data_name字段,AicoreErrorParser在解析时将其填充,确保解析侧可通过原始名在映射表中反查。


代码审查
审查完毕。总结如下:
按优先级统计
- P2: 4 条 — 测试中断言
assertIn的member与container参数顺序颠倒(2 处在test_dump_data_st.py,2 处在test_collection_st.py)。若CommonAssert基类使用标准unittest.TestCase.assertIn语义,这些断言逻辑是反转的,无法正确验证结果。 - P3: 2 条 —
_get_dump_mapping_csv_path在单次collect流程中被重复调用(性能建议);self.dump_name_mapping实例属性在Collection内部从未被读取(死状态)。
逐文件审查确认
| 文件 | 结果 |
|---|---|
src/msaicerr/ms_interface/aic_error_info.py |
无问题 — 新增 data_name 属性初始化,使用正确 |
src/msaicerr/ms_interface/aicore_error_parser.py |
无问题 — 在 set_info 中正确赋值 info.data_name |
src/msaicerr/ms_interface/collection.py |
2 条 P3 建议(重复 find 调用、死状态属性)。核心逻辑(超长文件名检测、mapping.csv 查找与解析、重命名回退)正确 |
src/msaicerr/ms_interface/constant.py |
无问题 — MAX_FILE_NAME_LEN / MAPPING_CSV_FILE 常量定义合理 |
src/msaicerr/ms_interface/dump_data_parser.py |
无问题 — 文件名超长检测与重命名、解析侧 mapping 反查逻辑正确 |
src/msaicerr/ms_interface/utils.py |
无问题 — parse_name_mapping_csv 实现正确,异常处理完善 |
test/st/msaicerr/testcase/test_collection_st.py |
2 条 P2(assertIn 参数颠倒) |
test/st/msaicerr/testcase/test_dump_data_st.py |
2 条 P2(assertIn 参数颠倒) |
整体风险评估
中低风险。核心业务逻辑(超长 dump 文件名适配的收集侧和解析侧)设计与实现正确,mapping.csv 的读写、find/grep 的 shell 命令构造、重命名回退路径均合理。主要风险在于 4 个测试断言参数顺序颠倒——如果基类未重写 assertIn,这些断言实际上不产生有效的验证,可能导致回归未被捕获。建议优先修复测试断言,其次考虑缓存 find 结果以优化大目录性能。
经过全面排查,没有发现额外的被掩盖的独立缺陷。test_utils_ut.py 中的测试用例使用了正确的断言形式(assertEqual),无问题。
审查总结
| 文件 | 审查结果 |
|---|---|
test/ut/msaicerr/testcase/test_collection_ut.py |
2 个问题:assertIn/assertNotIn 参数顺序颠倒(L594/608/609/660/670-671/746)、pytest.raises 块内断言不可达(L688-690) |
test/ut/msaicerr/testcase/test_dump_data_ut.py |
1 个问题:assertIn 参数顺序颠倒(L496/535/536) |
test/ut/msaicerr/testcase/test_utils_ut.py |
无问题 |
- P1 问题数:3
- 整体风险判断:中等风险。所有问题都集中在测试代码的断言逻辑上——断言参数颠倒导致测试验证了错误的条件,以及异常断言不可达。这些测试在运行时可能"通过"但未真正验证预期行为,存在漏测风险。建议在合入前修正所有
assertIn参数顺序和pytest.raises块结构。
| 类型 | 数量 |
|---|---|
| 🔴 阻塞 | 3 |
| 🟡 建议 | 0 |
⛔ 需要修改


Thanks for your pull-request.
The full list of commands accepted by me can be found at here。
You can get sig-info at here
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| repo-cann/oam-tools | ✅ zhuliangying, fujun19 (2/2) | ✅ zhuliangying (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
starchen_, thanks for your pull request. All authors of the commits have signed the CLA. 👍




/approve


描述
适配dump落盘文件名超长场景
关联的Issue
测试
通过UT/ST/RDV测试
新特性自验证通过
文档更新
无
类型标签