Repository navigation
Labels
in: waterflowIssues in Waterflow modulesIssues in Waterflow modulestype: bugA general bugA general bug
Milestone
Description
问题摘要 / Issue Summary
WaterFlowsTest.test_map_with_preserved_order 测试用例偶现失败,期望 sessionId 为具体值但实际为 null
版本信息 / Version Information
其他 (请在下方说明) / Other: v3.5.4-SNAPSHOT
浏览器 / Browser
不适用 - 这是后端测试问题
操作系统 / Operating System
macOS (Apple Silicon)
发生了什么?/ What happened?
在本地编译运行 waterflow-core 模块的测试时,test_map_with_preserved_order 测试用例偶现失败。
测试失败信息:
[ERROR] Tests run: 43, Failures: 1, Errors: 0, Skipped: 5, Time elapsed: 18.00 s <<< FAILURE! -- in modelengine.fit.waterflow.domain.WaterFlowsTest$WaterFlowBaseLineTest
[ERROR] modelengine.fit.waterflow.domain.WaterFlowsTest$WaterFlowBaseLineTest.test_map_with_preserved_order -- Time elapsed: 0.339 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <4aff210b-4ba9-4826-ae46-e73442201969> but was: <null>
at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145)
at modelengine.fit.waterflow.domain.WaterFlowsTest$WaterFlowBaseLineTest.test_map_with_preserved_order(WaterFlowsTest.java:170)
具体失败在第 170 行:
assertEquals(session.getId(), sessionId.get());期望 sessionId.get() 应该返回 session 的 ID(例如 4aff210b-4ba9-4826-ae46-e73442201969),但实际返回的是 null。
期望的行为 / Expected Behavior
测试应该稳定通过。在测试中:
- 创建一个带有 preserved order 的 FlowSession
- 通过 flow 处理 5 个数据项
- 在 window.complete() 后,onComplete 回调应该被调用并设置 sessionId
- sessionId.get() 应该返回实际的 session ID 而不是 null
重现步骤 / Steps to Reproduce
- 进入
framework/waterflow/java/waterflow-core目录 - 执行
mvn clean test - 观察测试结果 - 问题偶现,可能需要多次运行才能复现
相关日志 / Relevant Logs
完整的测试输出日志:
[INFO] Running modelengine.fit.waterflow.domain.WaterFlowsTest$WaterFlowBaseLineTest
reduce value=10, acc=10
reduce value=11, acc=1011
reduce value=20, acc=101120
reduce value=21, acc=10112021
reduce value=30, acc=1011202130
reduce value=31, acc=101120213031
reduce value=10, acc=10
reduce value=11, acc=21
reduce value=20, acc=41
reduce value=21, acc=62
value=62
[ERROR] Tests run: 43, Failures: 1, Errors: 0, Skipped: 5, Time elapsed: 18.00 s <<< FAILURE! -- in modelengine.fit.waterflow.domain.WaterFlowsTest$WaterFlowBaseLineTest
[ERROR] modelengine.fit.waterflow.domain.WaterFlowsTest$WaterFlowBaseLineTest.test_map_with_preserved_order -- Time elapsed: 0.339 s <<< FAILURE!
org.opentest4j.AssertionFailedError: expected: <4aff210b-4ba9-4826-ae46-e73442201969> but was: <null>
at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
at org.junit.jupiter.api.AssertEquals.failNotEqual(AssertEquals.java:197)
at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:182)
at org.junit.jupiter.api.AssertEquals.assertEquals(AssertEquals.java:177)
at org.junit.jupiter.api.Assertions.assertEquals(Assertions.java:1145)
at modelengine.fit.waterflow.domain.WaterFlowsTest$WaterFlowBaseLineTest.test_map_with_preserved_order(WaterFlowsTest.java:170)
测试代码位置: framework/waterflow/java/waterflow-core/src/test/java/modelengine/fit/waterflow/domain/WaterFlowsTest.java:148-176
额外信息 / Additional Context
- 这是一个偶现问题,不是每次都会失败
- 涉及到 preserved order (顺序保证) 和异步回调机制
- 可能与时序/竞态条件有关,因为测试中使用了 SleepUtil.sleep() 来控制时序
- onComplete 回调可能在某些情况下没有被正确触发,或者在断言执行之前没有完成
分支: fit-enhancement-zip
模块: framework/waterflow/java/waterflow-core
✅ 我已经搜索了现有的issues,确认这不是重复问题
✅ 我已经阅读了项目文档和 FAQ
✅ 我提供的信息准确完整
✅ 我愿意协助测试问题修复
Metadata
Metadata
Assignees
Labels
in: waterflowIssues in Waterflow modulesIssues in Waterflow modulestype: bugA general bugA general bug
Activity
loveTsong commentedon Oct 17, 2025
看起来是测试代码本身编写的存在时序问题:
测试中等待的是数据:
但是onComplete是在数据执行完成后会执行:
所以可能会出现等待数据结束,但是sessionId还未设置的情况导致报错。
修复方案:
调整为等待sessionId被设置值。
BornInAdversity commentedon Oct 18, 2025
应该是竞态时序调用问题,已经提交pr,可以帮check下~
CodeCasterX commentedon Oct 19, 2025
已按照测试用例方向进行了修改,目前重复执行100次编译构建,失败率已经从修改前的6%下降到0%了,可以得出结论,修复成功。PR:#346
CodeCasterX commentedon Oct 19, 2025
我和 @loveTsong 讨论过,这个地方从测试用例看的确是测试用例的问题,等待完成的内容出错了,我修改完之后已经验证成功了