test: fix flaky request-reclaim tests with poll_until_condition#919
Merged
Conversation
After reclaim_request, the immediate fetch_next_request could return None because a reclaimed request takes a moment to reappear at the queue head (eventually-consistent API), and in single mode call_with_exp_backoff does not retry. Poll until the request reappears instead.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #919 +/- ##
=======================================
Coverage 87.00% 87.00%
=======================================
Files 48 48
Lines 2956 2956
=======================================
Hits 2572 2572
Misses 384 384
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:
|
This test has the same shape as test_request_reclaim_functionality: reclaim_request followed by an immediate fetch_next_request that asserts a request is returned. A reclaimed request takes a moment to reappear at the queue head (eventually-consistent API), and in single mode call_with_exp_backoff does not retry. Poll until it reappears instead.
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.
Fixes flaky integration tests caused by the eventually-consistent request queue API behavior after
reclaim_request.The race
After
reclaim_request, an immediatefetch_next_requestcould returnNone: a reclaimed request takes a moment to reappear at the queue head (eventually-consistent API state), and insinglemodecall_with_exp_backoffcalls the function exactly once with no retry. This caused intermittentassert None is not Nonefailures.Fixes
Two tests share this exact shape —
reclaim_requestfollowed by an immediate fetch-and-assert. Both now use the mode-agnosticpoll_until_conditionhelper, which pollsfetch_next_requestuntil it returns a request (or times out), covering bothsingleandsharedmodes:test_request_reclaim_functionality— the originally observed flake.test_request_reclaim_with_forefront— the same latent flake, found by sweeping the test suite for the same pattern.Observed failure: https://github.com/apify/apify-sdk-python/actions/runs/26645106359/job/78528385633