Skip to content

test: Fix flaky is_finished checks in shared RQ integration tests#813

Merged
vdusek merged 2 commits intomasterfrom
test/fix-flaky-batch-operations-performance-shared
Feb 26, 2026
Merged

test: Fix flaky is_finished checks in shared RQ integration tests#813
vdusek merged 2 commits intomasterfrom
test/fix-flaky-batch-operations-performance-shared

Conversation

@vdusek
Copy link
Contributor

@vdusek vdusek commented Feb 25, 2026

Summary

  • Introduced a generic call_with_exp_backoff helper in tests/integration/_utils.py that retries any async callable with exponential backoff until it returns a truthy value, replacing the previous fetch_next_request_with_exp_backoff
  • Applied the helper to all is_finished() checks in shared request queue mode across 9 integration tests to handle API propagation delays
  • Renamed local variables that shadowed request: pytest.FixtureRequest to fix type checker errors

Test plan

  • Integration tests pass in CI (both single and shared RQ modes)
  • No more flaky is_finished failures in shared mode

Motivation

One of the failed run: https://github.com/apify/apify-sdk-python/actions/runs/22375456542/job/64764491226?pr=812

🤖 Generated with Claude Code

@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 Feb 25, 2026
@vdusek vdusek self-assigned this Feb 25, 2026
@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 Feb 25, 2026
@vdusek vdusek requested a review from Pijukatel February 25, 2026 08:18
@github-actions github-actions bot added this to the 135th sprint - Tooling team milestone Feb 25, 2026
@github-actions github-actions bot added the tested Temporary label used only programatically for some analytics. label Feb 25, 2026
@codecov
Copy link

codecov bot commented Feb 25, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.78%. Comparing base (9e5078f) to head (651f188).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #813      +/-   ##
==========================================
- Coverage   85.85%   85.78%   -0.08%     
==========================================
  Files          46       46              
  Lines        2765     2778      +13     
==========================================
+ Hits         2374     2383       +9     
- Misses        391      395       +4     
Flag Coverage Δ
e2e 37.07% <ø> (+0.07%) ⬆️
integration 58.60% <ø> (+0.04%) ⬆️
unit 73.32% <ø> (-0.02%) ⬇️

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.

@vdusek vdusek changed the title test: fix flaky is_finished checks in shared RQ integration tests test: Fix flaky is_finished checks in shared RQ integration tests Feb 25, 2026
In shared request queue mode, there is an API propagation delay before
handled requests are reflected. Tests checking `is_finished()` immediately
after processing could return `False` due to stale API state.

Introduce a generic `call_with_exp_backoff` helper in `tests/integration/_utils.py`
that retries any async callable with exponential backoff until it returns
a truthy value. This replaces the previous `fetch_next_request_with_exp_backoff`
and is now also used for `is_finished()` checks in shared mode across all
affected tests:

- test_add_and_fetch_requests
- test_add_requests_in_batches
- test_add_non_unique_requests_in_batch
- test_request_reclaim_functionality
- test_batch_operations_performance
- test_state_consistency
- test_large_batch_operations
- test_rq_long_url
- test_request_queue_is_finished

Failed run: https://github.com/apify/apify-sdk-python/actions/runs/22375456542/job/64764491226?pr=812

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vdusek vdusek force-pushed the test/fix-flaky-batch-operations-performance-shared branch from de4046d to 3f7145e Compare February 25, 2026 08:25
@vdusek vdusek requested a review from Pijukatel February 25, 2026 13:34
@vdusek vdusek merged commit 1ac00b2 into master Feb 26, 2026
29 checks passed
@vdusek vdusek deleted the test/fix-flaky-batch-operations-performance-shared branch February 26, 2026 09:52
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