Skip to content

fix(test): xihe-server 集成测试 900s 超时修复#1

Merged
TangJia025 merged 1 commit into
mainfrom
fix/xihe-server-test-timeout
Jun 29, 2026
Merged

fix(test): xihe-server 集成测试 900s 超时修复#1
TangJia025 merged 1 commit into
mainfrom
fix/xihe-server-test-timeout

Conversation

@TangJia025

Copy link
Copy Markdown
Contributor

问题

xihe-server 集成测试在 Workflow Deploy Test 中稳定超时 900s(run 28367668713)。

根因

services/xihe-server/test_cases.py 中两个问题叠加:

  1. Bug: time.sleep(300000) — 300 秒无意义等待,Jupyter 实例结束后干等 5 分钟
  2. 轮询过久: 两个测试各有 for i in range(5): wait 60s 轮询 — 每个最多 300s

修复

改动 修复前 修复后
删除无意义 sleep time.sleep(300000) 移除
Jupyter 启动轮询 5次 × 60s = 300s 3次 × 20s = 60s
权限测试轮询 5次 × 60s = 300s 3次 × 20s = 60s

修复后预估单次 pytest 耗时 ~200-300s,远低于 900s 上限。

🤖 Generated with Claude Code

AI 使用声明

当前 PR 是否有 AI 参与:

    1. AI Agent 平台:Claude Code
    2. AI 模型:deepseek-v4-pro
    3. Prompt 上下文:/fix/issue-3-release-service-md-lookup-order 分支,分析 CI run 28367668713 超时原因并修复

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>
@opensourceways-bot

Copy link
Copy Markdown

Welcome To opensourceways Community

Hey @TangJia025 , thanks for your contribution to the community.

Bot Usage Manual

I'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 Guide

If you have any questions, please contact the SIG: infratructure ,
and any of the maintainers: @GeorgeCao-hw, @TangJia025, @pkking, @zhongjun2 ,
and any of the committers: @guoxiaozhen0304 .

@opensourceways-bot

Copy link
Copy Markdown

CLA Signature Pass

TangJia025, thanks for your pull request. All authors of the commits have signed the CLA. 👍

@opensourceways-bot

Copy link
Copy Markdown

Linking Issue Notice

@TangJia025 , the pull request must be linked to at least one issue.
If an issue has already been linked, but the needs-issue label remains, you can remove the label by commenting /check-issue .

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Comment on lines +802 to +807
# 步骤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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

将最大等待时间缩短至 60 秒(3次 × 20秒)可能会导致测试在 CI 环境中变得非常不稳定(Flaky)。在云端环境(尤其是涉及 Ascend NPU 资源调度和容器启动时),Jupyter 实例的创建和启动通常需要 1 到 3 分钟。如果仅等待 60 秒,在 CI 环境负载较高或资源紧张时,测试极易因超时而失败。

既然导致 900s 超时的主要原因是已删除的 time.sleep(300000)(300,000 秒,约 83 小时),那么在移除了该无意义等待后,超时问题已经得到根本解决。为了保证测试的稳定性,建议将最大尝试次数设为 15 次(即总计 300s),同时保持 20 秒的轮询间隔。由于代码中在检测到成功状态后会立即 break 退出循环,因此增加最大尝试次数并不会增加正常情况下的测试耗时,但能显著提高测试的容错率和稳定性。

Suggested change
# 步骤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}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

配合最大尝试次数的调整,建议将日志输出中的最大次数也同步修改为 15。

Suggested change
print(f"[Jupyter Launch] Check {i+1}/3: button text = {current_text}")
print(f"[Jupyter Launch] Check {i+1}/15: button text = {current_text}")

Comment on lines +892 to +895
# 等待实例启动完成(最多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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

同上,将最大等待时间缩短至 60 秒(3次 × 20秒)可能会导致权限测试在实例启动时因超时而失败。建议将最大尝试次数设为 15 次(即总计 300s),以保证测试在 CI 环境中的稳定性。

Suggested change
# 等待实例启动完成(最多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}")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

配合最大尝试次数的调整,建议将日志输出中的最大次数也同步修改为 15。

Suggested change
print(f"[Jupyter Permission] Check {i+1}/3: button text = {current_text}")
print(f"[Jupyter Permission] Check {i+1}/15: button text = {current_text}")

@TangJia025 TangJia025 merged commit edac380 into main Jun 29, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants