Skip to content

test: unify polling waits behind a single poll_until_condition helper#1926

Merged
vdusek merged 1 commit into
masterfrom
test/unify-polling-helpers
Jun 4, 2026
Merged

test: unify polling waits behind a single poll_until_condition helper#1926
vdusek merged 1 commit into
masterfrom
test/unify-polling-helpers

Conversation

@vdusek
Copy link
Copy Markdown
Collaborator

@vdusek vdusek commented May 29, 2026

Unifies eventually-consistent / settling waits across the test suite behind a single poll_until_condition helper, matching the form shared with apify/apify-client-python#844.

Changes

  • Single helper. Replace wait_for_condition with poll_until_condition (tests/_utils.py): it polls a sync-or-async callable until an optional condition holds (default: truthy) or a wall-clock timeout expires, then returns the last result so the caller asserts explicitly. Exponential backoff is folded into a backoff_factor argument instead of a separate call_with_exp_backoff.
  • Shared location + relative imports. Move the helper from tests/unit/utils.py to the shared tests/_utils.py and import it relatively. This requires the test tree to be a proper package, so add __init__.py to the tests/unit and tests/e2e subpackages that lacked one (and allow TID252 in tests).
  • Migrate hand-rolled waits. Replace fixed sleeps and for/while polling loops with the helper:
    • 5 autoscaling waits — test_autoscaled_pool.py
    • statistics-initialization loop — test_basic_crawler.py
    • 2 sitemap-loader waits — test_sitemap_request_loader.py
    • 2 request-queue background-task waits — test_request_queue.py

Lint, type-check, and the full unit suite (1883 passed) pass.

@vdusek vdusek added t-tooling Issues with this label are in the ownership of the tooling team. adhoc Ad-hoc unplanned task added during the sprint. 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 92.99%. Comparing base (7db517a) to head (45dd1a7).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1926      +/-   ##
==========================================
+ Coverage   92.93%   92.99%   +0.05%     
==========================================
  Files         167      167              
  Lines       11708    11708              
==========================================
+ Hits        10881    10888       +7     
+ Misses        827      820       -7     
Flag Coverage Δ
unit 92.99% <ø> (+0.05%) ⬆️

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

☔ View full report in Codecov by Harness.
📢 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 marked this pull request as draft May 29, 2026 17:04
Replace the bespoke wait_for_condition with poll_until_condition, matching the
shared helper form in apify-client-python: it polls a sync-or-async callable until
an optional condition holds (default: truthy) or a wall-clock timeout expires, then
returns the last result so the caller asserts explicitly. Exponential backoff is
folded into a single backoff_factor parameter rather than a separate helper.

Migrate every suitable hand-rolled wait to it: the five autoscaling waits, the
statistics-initialization loop in the basic crawler tests, two sitemap-loader waits,
and two request-queue background-task waits (fixed sleeps and range/while loops).
@vdusek vdusek force-pushed the test/unify-polling-helpers branch from 1952df5 to 45dd1a7 Compare June 4, 2026 11:03
@vdusek vdusek marked this pull request as ready for review June 4, 2026 11:09
@vdusek vdusek requested a review from janbuchar June 4, 2026 11:25
@vdusek vdusek changed the title test: unify polling helpers with apify-sdk-python test: unify polling waits behind a single poll_until_condition helper Jun 4, 2026
@vdusek vdusek merged commit 939e91a into master Jun 4, 2026
33 checks passed
@vdusek vdusek deleted the test/unify-polling-helpers branch June 4, 2026 12:08
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