Skip to content

Commit 598dc48

Browse files
committed
test(haos): bound Node-RED readiness retries
1 parent cb6a6d5 commit 598dc48

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

tests/src/e2e/haos_only/test_zz_manage_app_tls.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,10 @@ async def _flows_request(
7676
}
7777
if port is not None:
7878
request["port"] = port
79-
while True:
79+
first_request = True
80+
payload: dict[str, Any] = {}
81+
while first_request or time.monotonic() < deadline:
82+
first_request = False
8083
payload = await safe_call_tool(
8184
mcp,
8285
"ha_manage_app",
@@ -89,19 +92,21 @@ async def _flows_request(
8992
503,
9093
504,
9194
)
92-
if not transient or time.monotonic() >= deadline:
95+
remaining = deadline - time.monotonic()
96+
if not transient or remaining <= 0:
9397
return payload
94-
await asyncio.sleep(3)
98+
await asyncio.sleep(min(3.0, remaining))
99+
return payload
95100

96101

97102
async def _direct_flows_request(mcp: Client, slug: str) -> dict[str, Any]:
98103
"""Call Node-RED's direct port after its HTTP stack is ready."""
99104
return await _flows_request(mcp, slug, port=1880)
100105

101106

102-
async def _ingress_flows_request(mcp: Client, slug: str) -> dict[str, Any]:
103-
"""Call Node-RED through Core Ingress after its HTTP stack is ready."""
104-
return await _flows_request(mcp, slug)
107+
async def _wait_ingress_flows_ready(mcp: Client, slug: str) -> None:
108+
"""Wait for Node-RED's HTTP stack to settle behind Core Ingress."""
109+
await _flows_request(mcp, slug)
105110

106111

107112
async def _set_front_door(
@@ -238,8 +243,11 @@ async def test_manage_app_reproduces_legacy_tls_failure_then_uses_fix(
238243
assert "IP address mismatch" in mismatch, mismatch
239244
assert "127.0.0.1" in mismatch, mismatch
240245

241-
fixed_ingress = await _ingress_flows_request(mcp, slug)
242-
assert fixed_ingress.get("success") is True, fixed_ingress
246+
await _wait_ingress_flows_ready(mcp, slug)
247+
fixed_ingress = await assertions.call_tool_success(
248+
"ha_manage_app",
249+
{"slug": slug, "path": "/flows", "method": "GET"},
250+
)
243251
assert fixed_ingress.get("status_code") == 200, fixed_ingress
244252
assert isinstance(fixed_ingress.get("response"), list), fixed_ingress
245253

0 commit comments

Comments
 (0)