fix(tests): make the sim backoff test deterministic across platforms - #177
Open
dieterolson wants to merge 1 commit into
Open
fix(tests): make the sim backoff test deterministic across platforms#177dieterolson wants to merge 1 commit into
dieterolson wants to merge 1 commit into
Conversation
test_backoff_progression_capped dialed 127.0.0.1:1 and slept a fixed 0.5 s; how fast the OS refuses that connect is platform-dependent (slow enough on Windows to capture fewer than two retries). The socket is now monkeypatched to refuse instantly and the test polls for the retries it asserts on, so it exercises the backoff schedule rather than the platform's TCP stack. Also applies ruff's mechanical import-block fix to this file (pre-existing I001/F401 that the pre-commit hook enforces on touch; CI does not run ruff).
Open
10 tasks
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.
What does this PR do?
Makes
test_backoff_progression_cappeddeterministic: the socket inopenflight.sim.transportis monkeypatched to refuse connections instantly, and the test polls for the retries it asserts on instead of sleeping a fixed 0.5 s. Also applies ruff's mechanical import-block fix to this file (pre-existingI001/F401that the pre-commit hook enforces on any touch).Why was this required?
The test dialed a real socket at
127.0.0.1:1and slept 0.5 s, then asserted at least two retries had happened. How fast the OS refuses that connect is platform-dependent — on Windows it's slow enough that fewer than two retries land inside the window, so the test fails on every stock Windows checkout (and is timing-sensitive everywhere). The subject under test is the client's backoff schedule, not the platform's TCP stack; the fake socket exercises the same_try_connectfailure path (settimeout→connectraisesOSErrorsubclass →close) without the platform dependence.Automated tests
Test-only change:
tests/test_sim_transport.py22/22 on Windows (previously 21/1). The poll loop bounds the wait at 3 s but typically completes in well under half a second.Manual (human) testing
_try_connectuses so the production failure path (log +close+ backoff) still executes.Checklist
uv run pytest tests/ -v)uv run pylint src/openflight/ --fail-under=9)uv run ruff check src/openflight/)cd ui && npm run build) — not applicable, no UI changescd ui && npm run lint) — not applicable, no UI changes