Skip to content

Deal the Linux web e2e shards by recorded test durations - #597

Merged
yansfil merged 1 commit into
mainfrom
ci/web-e2e-shard-balance
Oct 6, 2026
Merged

yansfil merged 1 commit into
mainfrom
ci/web-e2e-shard-balance

Conversation

@yansfil

@yansfil yansfil commented Oct 6, 2026 •

Copy link
Copy Markdown
Contributor

Part of with-hide/hide-private#100

Summary

Playwright's --shard cuts the tests in file order into runs of equal count, and a test takes 1 to 60 seconds, so the four Linux shards of run 37402687007 took 6.1, 11.0, 8.7 and 10.2 minutes; the slowest shard sets the run's wall time.
A shard of a lane with more than one shard now runs the tests scripts/web-e2e-shard.py split deals it: each test weighs its recorded seconds from web/e2e/shard-durations.json, longest first into the lightest shard.

  • On the recorded durations the four shards plan 472 seconds each; Playwright's count split plans 306, 577, 485 and 522.
  • Four shards stay four. A test the table lacks weighs the table's median, so a new test never breaks the split.
  • The shard runs its tests with --test-list, so retries, the flaky report and --grep are unchanged; the nightly's macOS and Windows shards use the same table.

Review

  • 판단해 주세요: the table is committed and refreshed by hand when a shard drifts (steps in docs/TESTING.md); the alternative, reading the previous run's durations in CI, would make a shard's tests depend on another run.
  • 조심해서 볼 파일: .github/workflows/web-e2e.yml - the End-to-end step lists, splits and passes --test-list; a failed list or split fails the step, never runs none.
  • 조심해서 볼 파일: scripts/web-e2e-shard.py - the title key drops a run line's tags (@platform) so a listed test and a logged test name the same entry.

Evidence

  • 확인한 것: python3 -m unittest discover -s scripts/tests passes (149 tests); 13 new ones cover the split on a fixed list, one shard per test whatever the table knows, the median for a new test, a shard with no test failing, and the committed table dealing four shards within 5 % of each other.
  • 확인한 것: against the real suite, playwright test --list --test-list for the four shards lists 44, 47, 43 and 45 tests, 179 in all, the whole suite once.
  • 확인한 것: the table is the median of 20 recent runs' passing durations (118 shard logs, 2026-10-05 and 06), all 179 current tests present; the web lint and typecheck pass.
  • 확인한 것: this pull request's own verify (run 37405118763, all four Linux shards, all tests passed) took 9.2, 9.2, 8.9 and 9.6 minutes against 6.1, 11.0, 8.7 and 10.2 before: the slowest shard drops 1.4 minutes and the spread from 4.9 to 0.7 minutes. One run on a shared runner pool, so the gain in median wall time is not measured here.
  • 확인하지 못한 것: the table's age: it is Linux runner durations of one day; the macOS and Windows nightly shards inherit its balance, not their own.

@yansfil
yansfil merged commit 6ba17fe into main Oct 6, 2026
19 checks passed
@yansfil
yansfil deleted the ci/web-e2e-shard-balance branch October 6, 2026 03:02
yansfil added a commit that referenced this pull request Oct 6, 2026
Part of #561

## Summary

#597 deals the web e2e shards by recorded durations; its review found
that a shard could run fewer tests than planned, or none, and stay
green. This makes the step prove what it runs.

- The shard file is written as UTF-8 bytes. Through a Windows runner's
cp1252 stdout `›` was one byte Playwright read as no delimiter, so no
test matched, and Playwright counts a `--test-list` that matches nothing
as a pass.
- `web-e2e-shard.py check` runs after the split: it fails the step
unless `playwright test --list --test-list <shard file>` lists exactly
the tests `split` planned, with one line saying how many matched
nothing.
- A problem with the list, the table or the plan is one line and exit
status 1, never a traceback.
- A `grep` that leaves fewer tests than shards leaves the extra shards
an empty file and an early end, as the old `--shard` did, instead of a
failure.
- `durations --list` keeps only listed tests, takes a passing retry as
its test, and reads a Windows runner's `ok` mark, so a refresh needs no
hand pruning.
- The balance claim became a report: the plan warns (first shard only)
when listed tests are missing from the table or the heaviest shard is
over 15 % above the mean, and docs/TESTING.md and CONTRIBUTING.md say
what is dealt and what is not measured.

## Review

- **판단해 주세요**: the duration table stays a Linux recording; only the pull
request's Linux lane deals by it now that the nightly runs one shard per
system (#566), so the macOS and Windows balance claim is removed, not
measured.
- **조심해서 볼 파일**: `.github/workflows/web-e2e.yml` - the step lists twice
per shard (full, then `--test-list`) and `check` compares them; a
mismatch fails the step.
- **조심해서 볼 파일**: `scripts/web-e2e-shard.py` - `emit` writes bytes to
`stdout.buffer`, `read` decodes UTF-8 explicitly.
- **질문**: review item 6 (list once in the `build` job and hand shard
files to the shards) is not done: it saves about 2 seconds of cold
TypeScript load per shard and moves the list into an artifact, which
this change does not need.

## Evidence

- **확인한 것**: `python3 -m unittest discover -s scripts/tests` passes (160
tests); new ones run the script with `PYTHONIOENCODING=cp1252` and
assert the shard file is exactly the UTF-8 bytes, `check` passes and
fails (nothing matched, unplanned tests selected, empty shard), inputs
fail as one line without `Traceback`, and the table names only `file ›
title` keys of existing specs.
- **확인한 것**: against the real suite, `split`, `playwright --list
--test-list` and `check` pass for all four shards (44, 47, 43 and 45
tests, 179 in all); a shard file naming a test that does not exist fails
`check` with "would run 0 tests, not the 44 planned".
- **확인한 것**: a one-test `grep` over four shards gives shard 1 the test
and shards 2 to 4 an empty file.
- **확인한 것**: the committed table is unchanged by the new parser:
regenerated from the same 118 logs with `durations --list` it is
identical (179 tests).
- **확인하지 못한 것**: a Windows runner. The encoding is covered by a cp1252
run on macOS and the `ok` mark by a log line; the real Windows nightly
runs one shard per lane, so this path does not run there today.
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.

1 participant