Skip to content

test: poll headless Chrome every 0.1 s in the browser smoke check (nightly) - #536

Merged
haiyuan-eng-google merged 1 commit into
mainfrom
ci-flake-1020
Oct 20, 2026
Merged

haiyuan-eng-google merged 1 commit into
mainfrom
ci-flake-1020

Conversation

@caohy1988

@caohy1988 caohy1988 commented Oct 20, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

dashboard/looker_studio/tools/browser_smoke.sh starts headless Chrome in the background, then polls it in dump_dom(). Both poll loops slept a whole second between checks. The first check runs right after the launch, before Chrome has written anything, so every browser pass took at least one full second, even when Chrome was done in a few hundred milliseconds.

CI pays this wait many times per run:

  • One --self-test makes 12 browser passes: 10 real Chrome page loads, plus the stand-in browsers of fixtures 3 and 4. The main check makes 2.
  • CI runs both six times per run: in the Configurator browser smoke job, and inside each of the five required Test (Python 3.10–3.14) jobs (test_browser_smoke_negative_fixtures_are_detected and test_configurator_loads_in_a_real_browser).

Evidence

CI, the 10 most recent main runs (2026-10-12 to 2026-10-20), read from the timestamped self-test N OK lines of the Configurator browser smoke job:

  • Fixtures 5–9 each load one page in Chrome. They took 1.54–1.59 s every time (one outlier at 1.88 s). That is the server readiness poll (0.5 s) plus exactly one 1 s browser poll.
  • Fixtures 3 and 4 are bimodal, exactly 1 s apart. Whether the stand-in browser has already exited at the first check decides whether a whole second is added.
    • Fixture 3 (/bin/false as the browser): 0.56–0.57 s in 3 runs, 1.53–1.57 s in 7.
    • Fixture 4: 1.54 s once, 2.53–2.57 s in 9.
  • Main check (two page loads): 2.55–2.61 s.
  • Whole self-test: 26.63–36.85 s, median 29.56 s.

Local (macOS arm64, Chrome 155), the main check on a one-page healthy fixture, timed over many runs:

browser runs time
stand-in that prints a healthy DOM and exits at once 20 1.637–1.668 s
stand-in that takes 0.3 s 20 1.636–1.676 s
real Chrome 10 1.650–1.684 s

The browser's own speed does not show: all three sit on the same floor.

Not a flake claim. No red run was observed. This PR removes fixed waiting and claims no change in flake rate.

Root cause

  for _ in $(seq 1 45); do
    if ! kill -0 "$CHROME_PID" 2>/dev/null; then break; fi
    if [ -s "$2" ]; then break; fi
    sleep 1
  done
  # Grace window
  for _ in $(seq 1 10); do
    if ! kill -0 "$CHROME_PID" 2>/dev/null; then break; fi
    sleep 1
  done

A pass can end only on a whole-second boundary after the launch.

Fix (1 file, +7/−4)

Before / after

before (main @ e6fae8f) after (5cc6312)
local: one-page main check, stand-in browser that exits at once (20 runs) 1.637–1.668 s, median 1.653 s 0.728–0.779 s, median 0.756 s
local: same, stand-in browser that takes 0.3 s (20 runs) 1.636–1.676 s, median 1.657 s 0.970–1.226 s, median 0.996 s
local: same, real Chrome (10 runs) 1.650–1.684 s, median 1.671 s 1.069–1.212 s, median 1.094 s
local: test_browser_smoke_negative_fixtures_are_detected (3 runs) 24.33–24.44 s 17.44–18.11 s
local: test_configurator_loads_in_a_real_browser (3 runs) 2.71–2.74 s 1.54–1.60 s
local: full suite, pytest --tb=short -q 6215 passed, 83 skipped in 99.25 s 6215 passed, 83 skipped in 87.62 s
local: per-test outcomes of the 6298 tests — 0 differences
CI: whole self-test in the smoke job 26.63–36.85 s, median 29.56 s (10 runs) 27.02 s (this PR, run 39414556480). Fixture 1, the cold first Chrome start, took 10.98 s of it; across the 10 baseline runs it took 5.62–14.69 s.
CI: self-test fixtures 2–14 (everything but the cold first start) 20.66–22.26 s, median 21.58 s (10 runs) 16.04 s
CI: fixtures 5–9 in the smoke job 1.54–1.59 s (one 1.88 s) 1.10–1.11 s
CI: main check in the smoke job 2.55–2.61 s (10 runs) 1.75 s
CI: the -q progress line holding both browser gates, per Test job 27.65–59.23 s, median 36.70 s (50 jobs in those 10 runs) 24.85–30.88 s, median 28.45 s (5 jobs). This line is noisy across runners, so the smoke-job timestamps are the direct measure.
CI test counts (all five Test jobs) 6216 passed / 82 skipped (3.10); 6217 / 81 (3.11–3.14) identical: 6216 / 82 (3.10); 6217 / 81 (3.11–3.14)

Other CI fixtures in this PR's smoke job: fixture 4 took 1.58 s (before: 1.54 s once, 2.53–2.57 s otherwise); fixture 10 took 2.39 s (before: 3.08–3.16 s); fixture 14 took 1.68 s (before: 2.57–2.65 s). Fixtures 2 and 11–13 kept their times (1.57, 0.06, 0.57 and 2.09 s). Fixture 3 took 0.57 s, the low end of its before range.

Baseline CI runs (main, newest first): 39379992440, 39316965669, 39287644332, 39210807323, 39171416943, 38806126365, 38642206430, 38516803828, 38514851642, 38283088580. The per-fixture numbers come from each run's Configurator browser smoke job log.

Local per-fixture times of one --self-test run (seconds; same command on each tree):

fixture before after
1 1.69 1.22
2 1.67 1.69
3 0.63 0.64
4 2.65 1.99
5 1.66 1.11
6 1.65 1.11
7 1.68 1.09
8 1.68 1.07
9 1.68 1.07
10 3.38 2.29
11 0.19 0.19
12 0.71 0.69
13 2.29 2.27
14 2.77 1.62
total 24.35 18.04

Fixtures 2, 3 and 11–13 never get as far as a browser page load, and they are unchanged.

Failure paths still behave the same

  • Self-test. All 14 fixtures keep their required outcome: every negative fixture fails, and the bind-collision retry passes.

  • Grace window. A stand-in browser that writes a healthy DOM and then stays alive is still killed only after the grace window. The run passes, as before.

    • Before: 11.80 s. After: 12.13 s (2 runs each).
  • Output deadline. A stand-in browser that never writes output still fails with the same instrumentation marker missing — the page never finished loading.

    • Before: 56.4 s. After: 63.1 s.
    • On macOS each sleep 0.1 costs about 14 ms of process start, so 550 polls stretch this failure-only path by about 7 s. A healthy run never reaches it.
  • Moderate CPU load (8 busy loops on 14 cores):

    • Main check with real Chrome: 20/20 passed before (median 1.659 s) and 20/20 after (median 1.234 s).
    • --self-test: 3/3 passed before (24–25 s) and 3/3 after (19–22 s).
  • Saturated CPU (14 or 20 busy loops): local Chrome 155 itself exits with status 2 about 10 s after writing the DOM. The check then fails the same way on main and on this branch.

    • Main check: 0/20 on each, at both loads.
    • --self-test at 20: fixture 10 fails on each, because its healthy run needs Chrome to exit 0.

    This is a limit of the local Chrome, not of this change.

Test results

  • Local, full suite (pytest --tb=short -q): 6215 passed, 83 skipped on both trees, with 0 per-test outcome differences across the 6298 tests.
  • Local, browser gates: both passed 3/3 on each tree.
  • Local, format gate: autoformat.sh at CI's pins leaves 387 files unchanged, and CI's git diff --exit-code is clean.
  • Local, script checks: bash -n and shellcheck are clean.
  • CI on this PR (run 39414556480, attempt 1):
    • Pass: Test (Python 3.10–3.14), Format check, Build package, Configurator browser smoke, cla/google, scan-pr, check-changes.
    • The zizmor jobs were skipped.

Commands

# per-fixture timing of the self-test (before on main, after on this branch)
cd dashboard/looker_studio
bash tools/browser_smoke.sh --self-test < /dev/null 2>&1 \
  | perl -MTime::HiRes=time -ne 'BEGIN{$t0=time} $|=1; printf "%7.3f %s", time-$t0, $_'

# the two browser gates, 3 runs on each tree
pytest tests/test_looker_studio_dashboard.py \
  -k "loads_in_a_real_browser or negative_fixtures_are_detected" \
  -q --durations=0 --durations-min=0.5

# one-page main check: SMOKE_DOCS_DIR points at a directory holding only a
# healthy index.html (no bqca/, so exactly one browser pass). CHROME_BIN is
# a stand-in that prints the healthy instrumented DOM of self-test fixture 4,
# sleeps S (0 or 0.3), and exits 0; or it is unset for real Chrome. Each run
# of `bash tools/browser_smoke.sh` is timed with time.monotonic().
# For the failure paths: S=30 (alive after a healthy DOM), and a stand-in
# that prints nothing and sleeps 120.

# full suite as CI runs it, plus junit for a per-test outcome diff
pytest --tb=short -q --durations=25 --junitxml=after.xml   # 6215 passed, 83 skipped

# format gate at CI's pins (pyink 25.12.0, isort 9.0.2), then CI's diff check
bash autoformat.sh && git diff --exit-code src/ tests/ examples/ scripts/ dashboards/   # 387 files unchanged
bash -n dashboard/looker_studio/tools/browser_smoke.sh      # clean under /bin/bash 3.2.57
shellcheck dashboard/looker_studio/tools/browser_smoke.sh   # 0.11.0, clean on both trees

Audit scope (nightly CI flake/slow pass, 2026-10-20)

This does not revisit #497 (port retry), #505 (offline deploy-script test), #513 (fixture 13 readiness budget) or #525 (ADC lookup in the self-evolving demo).

candidate evidence verdict
browser poll in dump_dom() fixed 1 s floor per browser pass; CI fixtures 5–9 at 1.54–1.59 s in 10 of 10 runs; fixtures 3 and 4 bimodal 1 s apart slow: fixed here
CI reds since 2026-10-05 (300 runs, all branches) All 18 CI runs among the 30 most recent main runs passed on attempt 1. All 15 attempt-2 runs (any workflow) were fork PRs' action_required approvals. 14 CI failures were fork-PR startup failures with no jobs. The real failures were Format on one branch and producers hash-lock drift; attestation staleness fails by design. keep: no red-then-green flake on one tree
local flake loops full suite in default and in random order (pytest-randomly): 6215 passed, 83 skipped each. Seven timing-sensitive tests × 40 repeats under 20 busy loops: 280/280 passed. none found
test_concurrent_launches_yield_exactly_one_owner (1.58 s) deliberate 1.5 s lock hold that widens the race window keep
TestCompileExtractor (~1.5 s each) per-test subprocess compile and smoke keep, as in #505
test_skill_evo_job_publication_regressions.py (12 tests, 10.6 s locally) real git; its CI line takes about 1.9 s macOS-only cost: keep
test_no_v2_as_default_in_source (1.0 s locally) ROOT.rglob("*.py") also reads a local .venv (8,362 of 8,852 files); a CI checkout has none local-only: not changed
CI line near 90% (test_terraform_fmt_clean) 1.2–5.8 s in CI vs 0.32 s locally unsure, as in #513: needs per-test CI timing
time to the first progress line 11–20 s in CI vs 5.0 s cold / 1.4 s warm collection locally (130k lines of tests compiled cold) keep: real work
fixture 2's sleep 1 before using its decoy server; the readiness loop's 0.5 s poll 1 s per self-test; up to 0.5 s per server start follow-up: the readiness interval is tied to the SMOKE_READY_POLLS budget from #513
…ghtly)

dump_dom() in dashboard/looker_studio/tools/browser_smoke.sh checked the
background browser once per second. Its first check runs right after the
launch, before Chrome has written anything, so every browser pass slept
a full second even when Chrome finished in a few hundred milliseconds.
One self-test makes 12 browser passes (10 real Chrome page loads plus two
stand-in browsers) and the main check makes 2. CI runs both in the smoke
job and in each of the five Test jobs, so the fixed wait recurs on every
CI run.

Poll every 0.1 s instead. The loops get 450 and 100 polls, so the 45 s of
sleep behind the output deadline and the 10 s grace window are the same.
Exit-status reaping, the deadline kill, the readiness loop
(SMOKE_READY_POLLS) and every fixture are unchanged.

Local before/after (macOS arm64, Chrome 155):
- one-page main check, stand-in browser that writes its DOM and exits at
  once, 20 runs: median 1.653 s -> 0.756 s
- same check with real Chrome, 10 runs: median 1.671 s -> 1.094 s
- test_browser_smoke_negative_fixtures_are_detected: 24.33-24.44 s ->
  17.44-18.11 s (3 runs each)
- test_configurator_loads_in_a_real_browser: 2.71-2.74 s -> 1.54-1.60 s
@haiyuan-eng-google
haiyuan-eng-google merged commit 3b6f4e5 into main Oct 20, 2026
15 checks passed
caohy1988 added a commit that referenced this pull request Oct 20, 2026
haiyuan-eng-google added a commit that referenced this pull request Oct 20, 2026
* release: 0.6.1

* release: add #536 to the 0.6.1 changelog

---------

Co-authored-by: Haiyuan Cao <haiyuan@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants