-
Notifications
You must be signed in to change notification settings - Fork 0
fix(test): xihe-server 集成测试 900s 超时修复 #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| page_fixture.reload() | ||||||||||||||||||||||
| page_fixture.wait_for_timeout(3000) | ||||||||||||||||||||||
|
|
@@ -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}") | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if "Jupyter" in current_text: | ||||||||||||||||||||||
| button_changed = True | ||||||||||||||||||||||
|
|
@@ -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 | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # 中间状态:继续等待,不报错 | ||||||||||||||||||||||
|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 同上,将最大等待时间缩短至 60 秒(3次 × 20秒)可能会导致权限测试在实例启动时因超时而失败。建议将最大尝试次数设为 15 次(即总计 300s),以保证测试在 CI 环境中的稳定性。
Suggested change
|
||||||||||||||||||||||
| page_fixture.reload() | ||||||||||||||||||||||
| page_fixture.wait_for_timeout(3000) | ||||||||||||||||||||||
| _ensure_nav_visible(page_fixture) | ||||||||||||||||||||||
|
|
@@ -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}") | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if "Jupyter" in current_text: | ||||||||||||||||||||||
| instance_ready = True | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
将最大等待时间缩短至 60 秒(3次 × 20秒)可能会导致测试在 CI 环境中变得非常不稳定(Flaky)。在云端环境(尤其是涉及 Ascend NPU 资源调度和容器启动时),Jupyter 实例的创建和启动通常需要 1 到 3 分钟。如果仅等待 60 秒,在 CI 环境负载较高或资源紧张时,测试极易因超时而失败。
既然导致 900s 超时的主要原因是已删除的
time.sleep(300000)(300,000 秒,约 83 小时),那么在移除了该无意义等待后,超时问题已经得到根本解决。为了保证测试的稳定性,建议将最大尝试次数设为 15 次(即总计 300s),同时保持 20 秒的轮询间隔。由于代码中在检测到成功状态后会立即break退出循环,因此增加最大尝试次数并不会增加正常情况下的测试耗时,但能显著提高测试的容错率和稳定性。