Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions services/xihe-server/test_cases.py
Original file line number Diff line number Diff line change
Expand Up @@ -799,12 +799,12 @@ def test_jupyter_launch_and_button_state_change(self, page_fixture: Page) -> Non
solid_btn.click()
page_fixture.wait_for_timeout(5000)

# 步骤5:每分钟检查一次按钮状态,最多5次(5分钟
# 步骤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)
Comment on lines +802 to +807

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)


page_fixture.reload()
page_fixture.wait_for_timeout(3000)
Expand All @@ -820,7 +820,7 @@ def test_jupyter_launch_and_button_state_change(self, page_fixture: Page) -> Non

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}")


if "Jupyter" in current_text:
button_changed = True
Expand All @@ -833,7 +833,6 @@ def test_jupyter_launch_and_button_state_change(self, page_fixture: Page) -> Non
print(f"[Jupyter Launch] 断言成功,点击结束按钮: {end_text}")
end_btn.click()
page_fixture.wait_for_timeout(3000)
time.sleep(300000)
break

# 中间状态:继续等待,不报错
Expand Down Expand Up @@ -890,10 +889,10 @@ def test_jupyter_instance_logout_access_denied(self, page_fixture: Page, context
page_fixture.wait_for_timeout(3000)
instance_created_by_test = True

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

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.reload()
page_fixture.wait_for_timeout(3000)
_ensure_nav_visible(page_fixture)
Expand All @@ -908,7 +907,7 @@ def test_jupyter_instance_logout_access_denied(self, page_fixture: Page, context

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}")


if "Jupyter" in current_text:
instance_ready = True
Expand Down
Loading