Fix flaky remote-desktop socket tests (handshake timeout deadlock)#213
Merged
Conversation
RemoteDesktopViewer.connect floored the auth-handshake socket timeout at max(60s, timeout), so an explicit short timeout (e.g. 2s) was ignored. When a plain viewer hit a TLS host (or a plain viewer hit a WS host) the two sides each blocked for 60s on a handshake that never completed — racing the 60s test timeout and intermittently hanging the suite. Bound the handshake by the caller's timeout instead (the handshake is a tiny HMAC exchange, so the connect budget is ample; callers needing longer pass a larger timeout). Drop the now-unused auth-timeout constant and tighten the WebSocket rejection test to a 2s budget so both mismatch tests fail fast and deterministically.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 1 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Problem
Two tests intermittently hung the whole headless suite (pytest-timeout
hard-kills the process, so a single hang fails the run):
test_remote_desktop_tls.py::test_plain_viewer_against_tls_host_failstest_remote_desktop_websocket.py::test_plain_tcp_viewer_against_ws_host_is_rejectedRoot cause
RemoteDesktopViewer.connect(timeout=...)set the auth-handshake sockettimeout to
max(_DEFAULT_AUTH_TIMEOUT_S=60, timeout), so an explicitshort timeout (the tests pass 2s / 30s to detect a protocol mismatch) was
floored to 60s. A plain viewer connecting to a TLS/WS host then blocked
~60s on a handshake that never completes — the same 60s as the test
timeout, so it raced and intermittently hung.
Fix
timeout(the handshake is a tinyHMAC exchange; the connect budget is ample, and callers needing more
pass a larger timeout). Removes the unused auth-timeout constant.
Both mismatch tests now fail fast and deterministically (~2s each, was a
60s race). Full
test_remote_desktop_tls.py+test_remote_desktop_websocket.pypass in ~6s.