Skip to content

test: Deflake adaptive crawler routing tests against request retries - #2198

Open
vdusek wants to merge 2 commits into
masterfrom
test/deflake-adaptive-crawling
Open

test: Deflake adaptive crawler routing tests against request retries#2198
vdusek wants to merge 2 commits into
masterfrom
test/deflake-adaptive-crawling

Conversation

@vdusek

@vdusek vdusek commented Aug 27, 2026

Copy link
Copy Markdown
Collaborator

test_adaptive_crawling[Enforced rendering type detection] fails intermittently on Windows CI with
assert 4 == 2 (example run).
When the Playwright sub-crawl stalls and times out, BasicCrawler retries the whole request - which is correct
behavior - but the test counts every hook and handler invocation and pulls each rendering type from a shared
cycle(). The retry therefore fires the pre-navigation hook a second time for the same URL and advances the cycle,
so the expected 2 becomes 4.

The fix makes the assertions insensitive to retries instead of tolerating them:

  • test_adaptive_crawling and test_adaptive_crawling_parsel assert the set of URLs routed to each sub crawler
    rather than raw invocation counters.
  • _SimpleRenderingTypePredictor memoizes its prediction per URL, so a retried request keeps the rendering type it
    was first assigned.

Verified with deterministic fault injection - patching PlaywrightCrawler._navigate to fail the first navigation
per URL, which runs after the pre-navigation hooks and so reproduces the CI sequence exactly. Before the change 4
of the 5 affected cases fail, including the exact assert 4 == 2; after it all pass, plus 0/100 failures under a
repeated parallel run.

No production code is touched, and the routing property under test is unchanged: wrong routing, a missing
pre-navigation hook, or a URL reaching both sub crawlers all still fail.

✍️ Drafted by Claude Code

@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 Aug 27, 2026
@vdusek vdusek self-assigned this Aug 27, 2026
@github-actions github-actions Bot added this to the 148th sprint - Tooling team milestone Aug 27, 2026
@github-actions github-actions Bot added the tested Temporary label used only programatically for some analytics. label Aug 27, 2026
@codecov

codecov Bot commented Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.72%. Comparing base (6deabad) to head (d3d4524).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2198      +/-   ##
==========================================
+ Coverage   93.61%   93.72%   +0.10%     
==========================================
  Files         181      181              
  Lines       12825    12825              
==========================================
+ Hits        12006    12020      +14     
+ Misses        819      805      -14     
Flag Coverage Δ
unit 93.72% <ø> (+0.10%) ⬆️

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 requested a review from Pijukatel August 27, 2026 10:00
@vdusek
vdusek marked this pull request as ready for review August 27, 2026 10:00
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