Skip to content

test: replace fixed sleep with polling for RQ stats assertions#864

Merged
vdusek merged 1 commit intomasterfrom
fix/flaky-rq-stats-tests
Apr 16, 2026
Merged

test: replace fixed sleep with polling for RQ stats assertions#864
vdusek merged 1 commit intomasterfrom
fix/flaky-rq-stats-tests

Conversation

@vdusek
Copy link
Copy Markdown
Contributor

@vdusek vdusek commented Apr 16, 2026

Summary

  • Added poll_until_condition() helper to tests/integration/_utils.py — polls an async callable until a condition is met or a 60-second timeout expires (5-second intervals).
  • Replaced await asyncio.sleep(10) + single-fetch patterns in 7 request queue integration tests with poll_until_condition, fixing intermittent failures where 10 s was not enough for Apify's eventually-consistent stats API to propagate.

The following tests were intermittently failing in CI due to this timing issue:

  • test_request_queue_metadata_another_client[single]
  • test_crawler_run_request_queue_variant_stats[Full rq client]
  • test_request_queue_has_stats[shared]
  • test_request_queue_deduplication_unprocessed_requests[shared]
  • test_request_queue_deduplication_use_extended_unique_key[single]

Failed CI runs that triggered this fix:

The Apify platform's request queue stats are eventually consistent and a
fixed 10-second sleep was sometimes not enough for them to propagate,
causing intermittent failures. Added a `poll_until_condition` helper that
retries up to 60 s (in 5 s intervals) and updated all stats-checking
assertions to use it.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@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 Apr 16, 2026
@vdusek vdusek self-assigned this Apr 16, 2026
@vdusek vdusek requested a review from Pijukatel April 16, 2026 12:17
@github-actions github-actions bot added this to the 138th sprint - Tooling team milestone Apr 16, 2026
@github-actions github-actions bot added the tested Temporary label used only programatically for some analytics. label Apr 16, 2026
@codecov
Copy link
Copy Markdown

codecov bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.57%. Comparing base (390ccaf) to head (049a6d4).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #864   +/-   ##
=======================================
  Coverage   86.57%   86.57%           
=======================================
  Files          48       48           
  Lines        2920     2920           
=======================================
  Hits         2528     2528           
  Misses        392      392           
Flag Coverage Δ
e2e 37.87% <ø> (ø)
integration 59.28% <ø> (ø)
unit 74.62% <ø> (ø)

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 merged commit bd7a715 into master Apr 16, 2026
31 checks passed
@vdusek vdusek deleted the fix/flaky-rq-stats-tests branch April 16, 2026 12:26
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.

3 participants