From 2dc081e6064859257e9f0fe9978ac155d5786d5c Mon Sep 17 00:00:00 2001 From: DandreYang <13072547+Dandre126@users.noreply.github.com> Date: Sun, 15 Nov 2026 09:56:49 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E9=9A=94=E7=A6=BB=E5=B7=A1=E6=A3=80?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E8=B7=AF=E5=BE=84=E7=94=A8=E4=BE=8B=E6=88=AA?= =?UTF-8?q?=E6=AD=A2=E6=94=BE=E5=AE=BD=E5=88=B0=2010=20=E7=A7=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 16 个成功路径用例原先用 5 秒截止,低于生产默认的 8 秒; 高负载下冷启动隔离子进程即可超过 5 秒,偶发 OVERVIEW_TIMEOUT。 改用服务允许的上限 10 秒,生产代码不变。 --- tests/test_console_inspection.py | 36 ++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 16 deletions(-) diff --git a/tests/test_console_inspection.py b/tests/test_console_inspection.py index e47a1ca..137d6a4 100644 --- a/tests/test_console_inspection.py +++ b/tests/test_console_inspection.py @@ -28,6 +28,10 @@ from .support import WorkspaceCase +# 成功路径要冷启动一个隔离子进程,高负载下会超过 5 秒。 +# 用 IsolatedOverviewService 允许的上限,避免误报 OVERVIEW_TIMEOUT。 +_SUCCESS_TIMEOUT_SECONDS = 10 + def _read_hung_descendant(marker: Path) -> tuple[int, int] | None: """Return ``(pid, pgid)`` only after an atomic publish is complete.""" @@ -60,7 +64,7 @@ def tearDown(self) -> None: def test_exec_worker_returns_overview_and_single_workspace_without_root_disclosure(self) -> None: service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) @@ -124,7 +128,7 @@ def test_events_after_cursor_and_one_level_family_survive_a_new_worker(self) -> spawn_line(config, "core_pay", "fix") service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) @@ -165,7 +169,7 @@ def test_events_after_cursor_and_one_level_family_survive_a_new_worker(self) -> self.assertEqual(raised.exception.code, "FAMILY_POST_FORBIDDEN") reader = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) page = reader.channel("demo", "core") @@ -242,7 +246,7 @@ def join(self, *, timeout: float) -> None: def test_temporary_root_is_read_without_registering_it_globally(self) -> None: service = IsolatedOverviewService( registry_state_home=self.root / "unrelated-state", - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, target_root=self.root, ) @@ -280,7 +284,7 @@ def test_root_scope_hides_global_ghost_registry_rows(self) -> None: ) service = IsolatedOverviewService( registry_state_home=home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, target_root=self.root, ) @@ -325,7 +329,7 @@ def test_vanished_test_workspace_does_not_win_unscoped_overview(self) -> None: ) service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) @@ -537,7 +541,7 @@ def test_parent_rejects_a_digest_consistent_but_unwhitelisted_ipc_payload(self) def test_parent_rejects_inspect_payload_with_procedure_or_paths(self) -> None: service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) valid = service.inspect_proofs("demo") @@ -559,7 +563,7 @@ def test_parent_rejects_inspect_payload_with_procedure_or_paths(self) -> None: def test_parent_rejects_an_inspected_summary_card(self) -> None: service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) valid = service.workspace("demo") @@ -581,7 +585,7 @@ def test_parent_rejects_an_inspected_summary_card(self) -> None: def test_parent_rejects_twin_plan_or_running_unbound_from_inventory(self) -> None: service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) valid = service.workspace("demo") @@ -663,7 +667,7 @@ def resign(payload: dict[str, object]) -> bytes: def test_parent_rejects_workspace_inventory_that_leaks_inspect(self) -> None: service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) valid = service.workspace("demo") @@ -735,7 +739,7 @@ def test_parent_rejects_workspace_inventory_that_leaks_inspect(self) -> None: def test_parent_rejects_system_tool_probe_leak(self) -> None: service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) valid = service.system() @@ -763,7 +767,7 @@ def test_parent_rejects_system_tool_probe_leak(self) -> None: def test_parent_rejects_digest_consistent_events_with_path_in_facts(self) -> None: service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) valid = service.events("demo") @@ -828,7 +832,7 @@ def test_missing_origin_warn_is_not_fail_and_not_a_bare_workspace_command(self) ) service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) @@ -879,7 +883,7 @@ def test_fold_twin_cards_do_not_advertise_fail_closed_workspace_selector(self) - create_line(load(self.root), line_id="core", branch="feat/core", base="main") service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) @@ -923,7 +927,7 @@ def test_isolated_root_console_does_not_advertise_other_root_fold_match( self.anchor.rename(self.root / "api-missing") service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, target_root=self.root, ) @@ -986,7 +990,7 @@ def test_worker_cannot_serve_or_write_artifacts_via_a_mutation_op(self) -> None: ) service = IsolatedOverviewService( registry_state_home=self.home, - timeout_seconds=5, + timeout_seconds=_SUCCESS_TIMEOUT_SECONDS, cursor_secret=b"q" * 32, ) with patch.object(service, "_run_worker", side_effect=AssertionError("worker")):