Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

test: prove two Windows-flaky checks by rendezvous and hang guards (#449)

Ruben Lütkee287737e78a9
diff --git a/tests/integration/memory/wiki/test_realtime_to_vault_e2e.py b/tests/integration/memory/wiki/test_realtime_to_vault_e2e.py
index f59e3a2864..61bf7aef1b 100644
--- a/tests/integration/memory/wiki/test_realtime_to_vault_e2e.py
+++ b/tests/integration/memory/wiki/test_realtime_to_vault_e2e.py
@@ -157,7 +157,14 @@ def _turn(
)
-async def _wait_for_page(path: Path, timeout_s: float = 3.0) -> None:
+# Hang guard, not a latency budget: each wait ends as soon as its condition
+# holds (about half a second on a desktop), but a loaded Windows CI runner
+# took longer than the former 3 s to carry one turn through the extractor,
+# judge and writer into the vault.
+_HANG_GUARD_S = 60.0
+
+
+async def _wait_for_page(path: Path, timeout_s: float = _HANG_GUARD_S) -> None:
deadline = time.monotonic() + timeout_s
while time.monotonic() < deadline: # noqa: ASYNC110 -- bounded test polling
if path.is_file(): # noqa: ASYNC240 -- bounded integration-test probe
@@ -171,7 +178,7 @@ async def _wait_for_idle(
journal: CandidateJournal,
*,
calls: int,
- timeout_s: float = 3.0,
+ timeout_s: float = _HANG_GUARD_S,
) -> None:
deadline = time.monotonic() + timeout_s
while time.monotonic() < deadline: # noqa: ASYNC110 -- bounded test polling
diff --git a/tests/unit/ui/web/test_local_models_routes.py b/tests/unit/ui/web/test_local_models_routes.py
index 916742e3d6..dbe9a77d8c 100644
--- a/tests/unit/ui/web/test_local_models_routes.py
+++ b/tests/unit/ui/web/test_local_models_routes.py
@@ -711,31 +711,34 @@ def test_roles_carry_the_voice_brains_context(server: WebServer, fake, monkeypat
async def test_server_and_inventory_overlap_instead_of_queueing(server, fake, monkeypatch) -> None:
"""The runtime probe is synchronous (urllib, up to 1.5 s when Ollama is
down); it used to run ON the loop, so ``/inventory`` waited behind it.
- Off the loop, the two requests take about the slowest one, not the sum."""
- import asyncio
- import time
- def _slow_status() -> dict:
- time.sleep(0.4)
- return _status(False)
+ Proven by a rendezvous instead of elapsed time: the probe blocks until
+ ``/inventory`` has answered. Off the loop ``/inventory`` answers while the
+ probe waits; on the loop the probe would starve it until the guard fired.
+ """
+ import asyncio
+ import threading
- monkeypatch.setattr(ollama_runtime, "runtime_status", _slow_status)
+ probe_started = threading.Event()
+ inventory_answered = threading.Event()
- async def _slow_inventory(root: str, **_kw) -> list:
- await asyncio.sleep(0.4)
- return []
+ def _blocking_status() -> dict:
+ probe_started.set()
+ assert inventory_answered.wait(30), "/inventory could not answer during the probe"
+ return _status(False)
- monkeypatch.setattr(ollama_inventory, "list_models", _slow_inventory)
+ monkeypatch.setattr(ollama_runtime, "runtime_status", _blocking_status)
# Loopback peer + loopback Host, so the surface guard serves it like the app.
transport = httpx.ASGITransport(app=server.app, client=("127.0.0.1", 1))
async with httpx.AsyncClient(transport=transport, base_url="http://127.0.0.1") as client:
- started = time.perf_counter()
- first, second = await asyncio.gather(
- client.get(f"{BASE}/server"), client.get(f"{BASE}/inventory")
- )
- elapsed = time.perf_counter() - started
+ status_request = asyncio.ensure_future(client.get(f"{BASE}/server"))
+ try:
+ assert await asyncio.to_thread(probe_started.wait, 30), "the probe never started"
+ second = await asyncio.wait_for(client.get(f"{BASE}/inventory"), 30)
+ finally:
+ inventory_answered.set()
+ first = await asyncio.wait_for(status_request, 30)
assert first.status_code == 200 and second.status_code == 200
- assert elapsed < 0.7, f"the two requests queued: {elapsed:.2f}s"
def test_one_paint_costs_one_sweep(server, fake, shortlist, monkeypatch) -> None: