fix(test): xihe-server 集成测试 900s 超时修复#1
Conversation
1. 移除 time.sleep(300000)(5分钟无意义等待,疑似笔误) 2. Jupyter 启动轮询从 5次×60s 降为 3次×20s(共300s→60s) 3. 权限测试轮询同步降为 3次×20s 修复后预估单次 pytest 耗时 ~200-300s,远低于 900s 超时上限。 Co-Authored-By: Claude <noreply@anthropic.com>
Welcome To opensourceways CommunityHey @TangJia025 , thanks for your contribution to the community. Bot Usage ManualI'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. Contact GuideIf you have any questions, please contact the SIG: infratructure , |
CLA Signature PassTangJia025, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
Linking Issue Notice@TangJia025 , the pull request must be linked to at least one issue. |
There was a problem hiding this comment.
Code Review
This pull request optimizes the Jupyter test cases by removing an excessively long sleep of 300,000 seconds and reducing the polling wait times. The reviewer notes that reducing the total wait time to 60 seconds (3 attempts of 20 seconds) may cause test flakiness in CI environments due to resource scheduling delays. They suggest increasing the maximum retry count to 15 (300 seconds total) to improve stability, which will not affect successful runs since the loop exits early upon completion. Corresponding updates to the log output statements are also recommended.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
| # 步骤5:每20秒检查一次按钮状态,最多3次(60秒) | ||
| # 中间状态:"启动环境"、"启动中" —— 继续等待 | ||
| # 成功状态:"进入Jupyter" —— 断言成功 | ||
| button_changed = False | ||
| for i in range(5): | ||
| page_fixture.wait_for_timeout(60000) | ||
| for i in range(3): | ||
| page_fixture.wait_for_timeout(20000) |
There was a problem hiding this comment.
将最大等待时间缩短至 60 秒(3次 × 20秒)可能会导致测试在 CI 环境中变得非常不稳定(Flaky)。在云端环境(尤其是涉及 Ascend NPU 资源调度和容器启动时),Jupyter 实例的创建和启动通常需要 1 到 3 分钟。如果仅等待 60 秒,在 CI 环境负载较高或资源紧张时,测试极易因超时而失败。
既然导致 900s 超时的主要原因是已删除的 time.sleep(300000)(300,000 秒,约 83 小时),那么在移除了该无意义等待后,超时问题已经得到根本解决。为了保证测试的稳定性,建议将最大尝试次数设为 15 次(即总计 300s),同时保持 20 秒的轮询间隔。由于代码中在检测到成功状态后会立即 break 退出循环,因此增加最大尝试次数并不会增加正常情况下的测试耗时,但能显著提高测试的容错率和稳定性。
| # 步骤5:每20秒检查一次按钮状态,最多3次(60秒) | |
| # 中间状态:"启动环境"、"启动中" —— 继续等待 | |
| # 成功状态:"进入Jupyter" —— 断言成功 | |
| button_changed = False | |
| for i in range(5): | |
| page_fixture.wait_for_timeout(60000) | |
| for i in range(3): | |
| page_fixture.wait_for_timeout(20000) | |
| # 步骤5:每20秒检查一次按钮状态,最多15次(300秒) | |
| # 中间状态:"启动环境"、"启动中" —— 继续等待 | |
| # 成功状态:"进入Jupyter" —— 断言成功 | |
| button_changed = False | |
| for i in range(15): | |
| page_fixture.wait_for_timeout(20000) |
| time.sleep(3) | ||
| current_text = solid_btn.inner_text().strip() | ||
| print(f"[Jupyter Launch] Check {i+1}/5: button text = {current_text}") | ||
| print(f"[Jupyter Launch] Check {i+1}/3: button text = {current_text}") |
| # 等待实例启动完成(最多60秒) | ||
| instance_ready = False | ||
| for i in range(5): | ||
| page_fixture.wait_for_timeout(60000) | ||
| for i in range(3): | ||
| page_fixture.wait_for_timeout(20000) |
There was a problem hiding this comment.
同上,将最大等待时间缩短至 60 秒(3次 × 20秒)可能会导致权限测试在实例启动时因超时而失败。建议将最大尝试次数设为 15 次(即总计 300s),以保证测试在 CI 环境中的稳定性。
| # 等待实例启动完成(最多60秒) | |
| instance_ready = False | |
| for i in range(5): | |
| page_fixture.wait_for_timeout(60000) | |
| for i in range(3): | |
| page_fixture.wait_for_timeout(20000) | |
| # 等待实例启动完成(最多300秒) | |
| instance_ready = False | |
| for i in range(15): | |
| page_fixture.wait_for_timeout(20000) |
| page_fixture.wait_for_timeout(3000) | ||
| current_text = solid_btn.inner_text().strip() | ||
| print(f"[Jupyter Permission] Check {i+1}/5: button text = {current_text}") | ||
| print(f"[Jupyter Permission] Check {i+1}/3: button text = {current_text}") |
问题
xihe-server集成测试在 Workflow Deploy Test 中稳定超时 900s(run 28367668713)。根因
services/xihe-server/test_cases.py中两个问题叠加:time.sleep(300000)— 300 秒无意义等待,Jupyter 实例结束后干等 5 分钟for i in range(5): wait 60s轮询 — 每个最多 300s修复
time.sleep(300000)修复后预估单次 pytest 耗时 ~200-300s,远低于 900s 上限。
🤖 Generated with Claude Code
AI 使用声明
当前 PR 是否有 AI 参与: