test: deflake integration tests by polling instead of fixed sleeps#844
Open
vdusek wants to merge 6 commits into
Open
test: deflake integration tests by polling instead of fixed sleeps#844vdusek wants to merge 6 commits into
vdusek wants to merge 6 commits into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #844 +/- ##
==========================================
+ Coverage 94.68% 94.82% +0.13%
==========================================
Files 48 48
Lines 5045 5045
==========================================
+ Hits 4777 4784 +7
+ Misses 268 261 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
44e03e0 to
ad43eec
Compare
Add a wall-clock-deadline `poll_until_condition` helper, generalize `maybe_await` to any awaitable, and refactor `collect_iterate_until_present` to reuse a shared drain step.
Lock writes propagate asynchronously after `list_and_lock_head` returns, so unlocking immediately could see fewer locks than acquired; poll `list_head` until the locked IDs disappear from the queue head before unlocking.
1cb554e to
e23e54d
Compare
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
Started as a fix for this flaky CI run of
test_request_queue_unlock_requests[sync](assert 2 == 3onunlocked_count, caused by replication lag betweenlist_and_lock_headandunlock_requests), and grew into deflaking the integration test suite as a whole.Changes:
poll_until_conditionhelper totests/integration/_utils.py: polls a sync-or-async callable at a constant interval until a condition holds or a wall-clock timeout expires. An optionalbackoff_factormultiplies the interval after each poll, for highly variable waits (e.g. Actor run container startup) where a growing delay covers a long timeout with few calls.list_headuntil the locked IDs disappear from the queue head before unlocking.for _ in range(5): sleep(1); read; breakpolling loops (10×) and single fixedsleep(1)waits (26×) across the request queue, dataset, key-value store, and run integration tests withpoll_until_condition. This makes the tests both faster on the happy path (no unconditional sleep) and more robust under load (polls until the timeout instead of hoping 1 s is enough).maybe_awaitto accept any awaitable.The three
iterate_keyssleeps in the KVS tests are intentionally left as-is: draining an iterator per attempt wants attempt-count semantics (likecollect_iterate_until_present), not a wall-clock deadline.Follow-up to #786.