Skip to content

Commit fbd3b25

Browse files
committed
Fix two CI flakes surfaced by GitHub Windows runners
1. test_watcher_reloads_after_mtime_change: the test's `_write` helper set mtime to time.time() after each write, but two back-to-back writes of the same file on the GitHub-runner Windows filesystem could land with identical mtimes — defeating the watcher's mtime-based reload detection. Force mtime forward past the previous value: `now = max(time.time(), previous + 1.0)`. 2. test_ws_viewer_input_reaches_host_dispatcher (and the related _authenticates_and_receives_frames / _wrong_token tests): the socket-level auth-handshake timeouts were hardcoded at 5 s on both the viewer (`_DEFAULT_AUTH_TIMEOUT_S`) and host (`_AUTH_TIMEOUT_S` in host.py + `_HANDSHAKE_TIMEOUT_S` in ws_host.py). On a slow GitHub Windows runner the handshake recvs exceeded that budget — even though the test asked for a 10 s connect timeout, the per-socket timeout never honored it. Bump all three to 15 s, AND make viewer.py honor the caller's explicit `connect(timeout=...)` argument: `raw_sock.settimeout(max(_DEFAULT_AUTH_TIMEOUT_S, float(timeout)))`. Both are real defects that would also bite production users on high-latency / loaded networks; the test failures just gave them visibility on CI. Verified: full headless suite 605 passed / 7 skipped / 0 failed locally after the change.
1 parent 5916e50 commit fbd3b25

4 files changed

Lines changed: 16 additions & 7 deletions

File tree

je_auto_control/utils/remote_desktop/host.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
FrameProvider = Callable[[], bytes]
3838
InputDispatcher = Callable[[Mapping[str, Any]], Any]
3939

40-
_AUTH_TIMEOUT_S = 5.0
40+
_AUTH_TIMEOUT_S = 15.0
4141
_DEFAULT_QUALITY = 70
4242

4343

je_auto_control/utils/remote_desktop/viewer.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
ClipboardCallback = Callable[[str, Any], None]
2727
ErrorCallback = Callable[[Exception], None]
2828

29-
_DEFAULT_AUTH_TIMEOUT_S = 5.0
29+
_DEFAULT_AUTH_TIMEOUT_S = 15.0
3030
_DEFAULT_CONNECT_TIMEOUT_S = 5.0
3131
_NOT_CONNECTED_MESSAGE = "viewer is not connected"
3232

@@ -103,7 +103,11 @@ def connect(self, timeout: float = _DEFAULT_CONNECT_TIMEOUT_S) -> None:
103103
raw_sock = socket.create_connection(
104104
(self._host, self._port), timeout=timeout,
105105
)
106-
raw_sock.settimeout(_DEFAULT_AUTH_TIMEOUT_S)
106+
# If the caller explicitly asked for a longer connect budget,
107+
# honor it for the handshake too — otherwise a slow remote (CI
108+
# runners, high-latency links) trips the 5 s default before the
109+
# caller's window expires.
110+
raw_sock.settimeout(max(_DEFAULT_AUTH_TIMEOUT_S, float(timeout)))
107111
try:
108112
sock = self._maybe_wrap_tls(raw_sock)
109113
channel = self._build_channel(sock)

je_auto_control/utils/remote_desktop/ws_host.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
WsProtocolError, server_handshake,
1818
)
1919

20-
_HANDSHAKE_TIMEOUT_S = 5.0
20+
_HANDSHAKE_TIMEOUT_S = 15.0
2121

2222

2323
class WebSocketDesktopHost(RemoteDesktopHost):

test/unit_test/headless/test_mcp_plugin_watcher.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,15 @@
66

77

88
def _write(path, body):
9-
path.write_text(body, encoding="utf-8")
10-
# Bump mtime to ensure the watcher picks it up even on coarse FSes.
11-
now = time.time()
129
import os
10+
# On Windows + GitHub-runner filesystems, mtime resolution can be
11+
# coarser than back-to-back test writes — the second write of the
12+
# same file can land with the same mtime as the first, defeating
13+
# mtime-based reload detection. Always force mtime forward past
14+
# any previous value on this path.
15+
previous = path.stat().st_mtime if path.exists() else 0.0
16+
path.write_text(body, encoding="utf-8")
17+
now = max(time.time(), previous + 1.0)
1318
os.utime(path, (now, now))
1419

1520

0 commit comments

Comments
 (0)