Skip to content

test: fix flaky request-reclaim tests with poll_until_condition#919

Merged
vdusek merged 2 commits into
masterfrom
test/fix-flaky-request-reclaim
May 29, 2026
Merged

test: fix flaky request-reclaim tests with poll_until_condition#919
vdusek merged 2 commits into
masterfrom
test/fix-flaky-request-reclaim

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented May 29, 2026

Fixes flaky integration tests caused by the eventually-consistent request queue API behavior after reclaim_request.

The race

After reclaim_request, an immediate fetch_next_request could return None: a reclaimed request takes a moment to reappear at the queue head (eventually-consistent API state), and in single mode call_with_exp_backoff calls the function exactly once with no retry. This caused intermittent assert None is not None failures.

Fixes

Two tests share this exact shape — reclaim_request followed by an immediate fetch-and-assert. Both now use the mode-agnostic poll_until_condition helper, which polls fetch_next_request until it returns a request (or times out), covering both single and shared modes:

  • 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

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.
@vdusek vdusek added adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. labels May 29, 2026
@vdusek vdusek self-assigned this May 29, 2026
@github-actions github-actions Bot added this to the 141st sprint - Tooling team milestone May 29, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label May 29, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 29, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.00%. Comparing base (94bdd37) to head (a2eeef2).
⚠️ Report is 2 commits behind head on master.

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           
Flag Coverage Δ
e2e 37.58% <ø> (ø)
integration 58.89% <ø> (ø)
unit 75.81% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.
@vdusek vdusek changed the title test: fix flaky test_request_reclaim_functionality[single] test: fix flaky request-reclaim tests with poll_until_condition May 29, 2026
@vdusek vdusek merged commit edd23e6 into master May 29, 2026
26 checks passed
@vdusek vdusek deleted the test/fix-flaky-request-reclaim branch May 29, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

adhoc Ad-hoc unplanned task added during the sprint. t-tooling Issues with this label are in the ownership of the tooling team. tested Temporary label used only programatically for some analytics.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants