Repository navigation
Fix flaky test_elf_upload_timeout in HDAWG tests - #242
Merged
Merged
Conversation
The test relied on real wall-clock timing via time.sleep(), combined with a mocked upload progress sequence, to land on exactly two poll iterations before the upload timeout tripped. Under CI scheduling jitter, the real elapsed time could exceed the timeout one iteration earlier than intended, reporting 0.0% progress instead of the expected 50.0%. Mock time.monotonic() (and time.sleep()) so the timeout trip point is deterministic and independent of actual elapsed wall-clock time. Fixes #239 Co-authored-by: heevasti <87366176+heevasti@users.noreply.github.com> Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Closed
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.
Summary
Fixes a flaky unit test reported in #239.
test_elf_upload_timeoutintests/instruments/zurich_instruments/test_hdawg.pyrelied on real wall-clock timing viatime.sleep(), combined with a mocked upload progress sequence (getDouble.side_effect = [0.0, 0.5]), to land on exactly two poll iterations before the upload timeout tripped. Under CI scheduling jitter, the real elapsed time could exceed the timeout one poll iteration earlier than intended, causing the test to see0.0%progress in the timeout message instead of the expected50.0%:Changes
tests/instruments/zurich_instruments/test_hdawg.py: mocktime.monotonic()(andtime.sleep(), to keep the test fast) insidetest_elf_upload_timeout, so the timeout trip point is fully deterministic and no longer depends on actual elapsed wall-clock time or CI scheduling.CHANGELOG.md: documented the fix under "Fixed" in the Unreleased section.No production code (
qmi/instruments/zurich_instruments/hdawg.py) was changed — this is purely a test-determinism fix.Test plan
test_elf_upload_timeoutpasses consistently (ran 20x in a loop, all green; runtime dropped from ~2s to ~0.006s since it no longer sleeps for real)tests/instruments/zurich_instruments/test_hdawg.pysuite passes (97 tests)uv run coverage run --branch -m unittest discover --start-directory="tests" --pattern="test_*.py", 3185 tests, OK)uv run ruff check --fix --output-format pylintcleanuv run mypy qmi --namespace-package --explicit-package-bases— no issues (pre-existing, unrelated errors inexamples/and missingjsonschemastubs intests/are untouched by this change)🤖 Generated with Claude Code