Skip to content

fix(test): make test_browser_profile_coverage deterministic via DNS instrumentation#1183

Open
vringar wants to merge 2 commits into
masterfrom
fix/profile-coverage-deterministic-dns
Open

fix(test): make test_browser_profile_coverage deterministic via DNS instrumentation#1183
vringar wants to merge 2 commits into
masterfrom
fix/profile-coverage-deterministic-dns

Conversation

@vringar

@vringar vringar commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

Fixes #1163test_browser_profile_coverage flaked intermittently when Firefox contacted an unexpected domain (e.g. a search partner such as baidu.com) during startup. The old assertion compared the set of requested domains against the Firefox profile, which is inherently network-dependent.

This restructures the test to be deterministic regardless of network conditions by keying every assertion off the DNS instrumentation (dns_responses table, merged via #1158/#1159).

What changed

The test now enables dns_instrument on the crawl and, for each site in TEST_SITES:

  1. Asserts a dns_responses row exists — proving the browser attempted to resolve it.
  2. If DNS succeeded (a row with non-null addresses) → asserts the corresponding http_requests and places.sqlite (moz_places) entries exist.
  3. If DNS only ever failed (rows with non-null error and null addresses) → skips the HTTP/profile assertions for that domain. A timeout/NXDOMAIN is now a valid test path, not a failure.

A final sanity check asserts that at least one entered site resolved successfully, guarding against the per-site loop silently doing nothing.

The previous network-dependent set-difference check (and its now-unused json/crawl_history handling) is removed.

Why this is deterministic

baidu.com (or any TEST_SITE) timing out no longer makes the test fail — it becomes a skipped branch. The only things asserted are invariants the crawl pipeline must uphold when DNS actually resolved: a resolved domain must have produced an HTTP request and must appear in the browser profile.

Verification

Ran test_browser_profile_coverage against Firefox 150 multiple times locally; all runs passed.

Copilot AI review requested due to automatic review settings June 14, 2026 22:42

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes intermittent CI flakes in test_browser_profile_coverage by making the assertions depend on the crawl’s DNS instrumentation results (dns_responses) rather than on network-dependent domain set comparisons, so unexpected/failed resolutions no longer fail the test.

Changes:

  • Enable dns_instrument for the crawl used by test_browser_profile_coverage.
  • Rework assertions to:
    • require a dns_responses row for each entered site (attempted resolution),
    • only require http_requests + moz_places coverage when dns_responses.addresses is present,
    • treat “only failures” (no addresses) as a valid/skip path.
  • Add a sanity check that at least one entered site resolved successfully to ensure the test still exercises the positive path.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov

codecov Bot commented Jun 14, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.12%. Comparing base (315e667) to head (b47faa4).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1183      +/-   ##
==========================================
- Coverage   62.14%   62.12%   -0.03%     
==========================================
  Files          40       40              
  Lines        3918     3918              
==========================================
- Hits         2435     2434       -1     
- Misses       1483     1484       +1     

☔ 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.

@vringar vringar force-pushed the fix/profile-coverage-deterministic-dns branch 4 times, most recently from 9215b5b to 5646bee Compare June 15, 2026 22:11
vringar added 2 commits June 19, 2026 23:18
…nstrumentation

Reworks the profile-coverage check so it can no longer flake on network
conditions and no longer passes vacuously.

- Anchors each per-site profile assertion on the host Firefox actually
  resolved and received a response from (the dns_responses hostname),
  not the eTLD+1 of the URL we typed. This fixes the blogspot.com case,
  where the entered eTLD+1 is the degenerate '.blogspot.com' while the
  resolved host (www.blogspot.com) maps to a different registrable
  domain, and it tolerates redirects to a different eTLD+1.
- Drops the tautological 'request was made' assertion. A dns_responses
  row with addresses comes from onHeadersReceived, which only fires
  after a response arrived, so the matching http_requests row is
  implied. The independent signal is profile coverage (moz_places),
  written by Firefox itself.
- Strengthens the floor: requires a clear majority of TEST_SITES to
  both resolve and appear in the profile, so a broken crawl with a lost
  profile fails instead of degrading to 'at least one site resolved'.
- Treats an empty addresses string as not-resolved (truthiness check).
- Docstring/comments now describe what is actually guaranteed.
Also correct the docstring's description of the blogspot/public-suffix
mechanism: the test does not rely on get_ps_plus_1 mapping
www.blogspot.com to a real eTLD+1, but on applying the same
get_ps_plus_1 to both the resolved host and the profile URLs.
@vringar vringar force-pushed the fix/profile-coverage-deterministic-dns branch from 5646bee to b47faa4 Compare June 19, 2026 23:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Flaky test: test_browser_profile_coverage finds unexpected baidu.com domain

2 participants