Skip to content

test: run the longest Agent Host E2E suites in two processes - #345871

Merged
Logan Ramos (lramos15) merged 4 commits into
mainfrom
test/agent-host-e2e-split-suites
Nov 3, 2026
Merged

Logan Ramos (lramos15) merged 4 commits into
mainfrom
test/agent-host-e2e-split-suites

Conversation

@lramos15

@lramos15 Logan Ramos (lramos15) commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Note

Builds on #345835 (merged), which split the Windows Agent Host E2E job into three shards. With this PR, the 10 processes split 4/3/3 across them, and this PR's CI will show whether the third shard is still worth a runner.

Part of an effort to speed up the PR checks. Agent Host E2E is the longest test step:

Platform Step time (median, last 5 days)
Linux 328s
macOS 296s
Windows 400s per shard job

The runner runs each of its six suites in its own process, so the step lasts as long as the longest suite. On Linux (run 41674329242), Copilot, Conformance and Claude each took ~230–240s and Codex ~190s; the others take well under a minute.

The runner's /proc samples show the cost of that imbalance:

Phase of the run CPU busy
First ~80s 85–95%
Next ~3 min 60–65%, while the long suites finish
Last minute ~20%

Changes

  • --testShard <i>/<n> in the Electron test runner (test/unit/electron/renderer.js, index.js): after the files load, it keeps every <n>th loaded test, starting with the <i>th. Contiguous halves were unbalanced because the slow tests sit at the end of each file (Conformance 53s vs 241s). Mocha skips suites left without tests, hooks included. It is excluded from --workers like --testSplit, and reruns of failed tests clear it so a rerun can't filter out the test it reruns.
  • Agent Host E2E runner (test/integration/agentHost/runner.ts): Copilot, Conformance, Claude and Codex run in two processes each (parts: 2). Each process runs half of the file's tests against its own Agent Host server, which the suites' lease already handles: there is per-test setup and teardown, and no assertion spans all tests.
    • Processes are queued longest suite first.
    • The default worker count counts processes (10) instead of suites (6), still capped at the CPU count.
    • --shard now distributes processes, so the two halves of a suite can run on different Windows shard jobs.
  • Updated build/lib/testAgentHostE2EStartup.test.ts, the script help, and the E2E README.

Results

Measured before #345835 merged, with two Windows shards.

🧪 Run Agent Host E2E tests (Electron), one run with every-other-test shards:

Job 5-day median (p25) This PR
Windows / Agent-Host-E2E (shard 1/2) 438s (397s) 293s
Windows / Agent-Host-E2E (shard 2/2) 374s (325s) 316s
macOS / Electron 296s (285s) 244s
Linux / Agent-Host-E2E 327s (273s) 275s

The halves are balanced now (Copilot 228s/243s, Conformance 135s/154s, Claude 204s/190s, Codex 185s/171s). On Linux, though, each half takes about as long as the whole suite took before: 10 processes on 8 cores are CPU-bound, so Linux gains little beyond noise. Windows and macOS gain 50–145s.

Validation

  • cd build && node --test lib/testAgentHostE2EStartup.test.ts lib/test/agentHostTestSelection.test.ts: 14/14 pass, after updating the expected processes and shard assignment.
  • Checked shardTests against a real mocha suite tree: shards cover each test exactly once, and suites left without tests skip their hooks.
  • eslint on the changed runner files: clean
  • CI: all checks pass.

Copilot AI balanced review requested due to automatic review settings November 3, 2026 17:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Shard filtering leaves Mocha’s exclusive-test selection intact, allowing a discarded test.only(...) to be restored and run in both shards.

1 open issue
What changed in this PR

This PR aims to shorten Agent Host E2E checks by splitting the four longest suites across two processes each, using new test-level sharding in the Electron runner.

Changes:

  • Adds --testShard to partition loaded tests, disables worker mode when supplied, and clears it for failed-test reruns.
  • Schedules ten suite processes, prioritizes longer suites, and distributes processes across CI shards.
  • Updates startup-test expectations, script help, and E2E documentation.
File Description
test/​unit/​electron/​renderer.js Partitions loaded tests into contiguous shards.
test/​unit/​electron/​index.js Parses sharding options and handles workers and reruns.
test/​integration/​agentHost/​runner.ts Splits long suites and schedules their processes.
src/​vs/​platform/​agentHost/​test/​node/​e2e/​README.md Documents split-suite execution.
scripts/​test-agent-host-e2e.sh Updates process-level sharding help for POSIX.
scripts/​test-agent-host-e2e.bat Updates process-level sharding help for Windows.
build/​lib/​testAgentHostE2EStartup.test.ts Updates expected process counts and shard assignments.

Review effort: Balanced

Comment thread test/unit/electron/renderer.js Resolved
@github-actions

github-actions Bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Base: 25e405b1 Current: c9fc0dcd

No screenshot changes.

The Agent Host E2E runner runs each suite in one process, and the Copilot, Conformance and Claude suites take about 240s each on Linux, twice as long as the others. The machine is busy for the first 80s, then idles at 20-65% while those suites finish. The Electron test runner's new --testShard <i>/<n> keeps one contiguous part of the loaded tests, so that the runner can run the Copilot, Conformance, Claude and Codex suites in two processes each, longest first, each with its own Agent Host server. --shard now distributes these processes. Reruns of failed tests ignore --testShard.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
…us halves

The slow tests sit at the end of each file, so the second contiguous half of each suite took 3-5 times as long as the first (Conformance 53s vs 241s), and the longest process was as long as the whole suite before.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mocha restores the tests selected with .only() before running, so each shard ran them all. Errors thrown before the run were also reported as {}, because JSON.stringify drops an Error's message.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@lramos15
Logan Ramos (lramos15) force-pushed the test/agent-host-e2e-split-suites branch from bed7491 to 08a325c Compare November 3, 2026 20:48
@lramos15
Logan Ramos (lramos15) merged commit 2eeaf59 into main Nov 3, 2026
59 checks passed
@lramos15
Logan Ramos (lramos15) deleted the test/agent-host-e2e-split-suites branch November 3, 2026 22:29
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 3, 2026
@bryanchen-d

Copy link
Copy Markdown
Collaborator

Logan Ramos (@lramos15) FYI: since this merged, Windows x64 Agent Host E2E fails in main CI (492607). All 8 two-process suites exit 255 right away with full was unexpected at this time., and the single-process suites run normally.

The cause is a latent bug in scripts\test-integration.bat that this PR exposed. Its argument loop uses shift, which shifts %0 too, so after the loop %~nx0 is the last argument. In ADO that's the --tfs value, which is now Integration Tests Copilot (1/2) full, so %~nx0 becomes 2) full. cmd parses the if defined SHOW_HELP ( ... echo Usage: %~nx0 ... ) block even when it doesn't run it, and that ) closes the block early. GitHub PR CI doesn't pass --tfs, so it never hit this. I reproduced it locally with the real script.

I'm preparing a small fix that saves the script name before the loop, as a draft with a Windows proof run. I'll link it here.

Co-authored with Copilot

Bryan Chen (bryanchen-d) added a commit that referenced this pull request Nov 4, 2026
shift also shifts %0, so after the argument loop %~nx0 is the last argument.
Since #345871 the Agent Host E2E runner passes --tfs values such as
"Integration Tests Copilot (1/2) full", which made %~nx0 "2) full". cmd
parses the whole help block even when it does not run it, so the ")" ended
the block and every two-process suite failed with "full was unexpected at
this time." on Windows. Save the script name before parsing instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Aaron Munger (amunger) pushed a commit that referenced this pull request Nov 4, 2026
…ck (#345947)

shift also shifts %0, so after the argument loop %~nx0 is the last argument.
Since #345871 the Agent Host E2E runner passes --tfs values such as
"Integration Tests Copilot (1/2) full", which made %~nx0 "2) full". cmd
parses the whole help block even when it does not run it, so the ")" ended
the block and every two-process suite failed with "full was unexpected at
this time." on Windows. Save the script name before parsing instead.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bryan Chen (bryanchen-d) added a commit that referenced this pull request Nov 4, 2026
…ct builds

Product builds pass --tfs last, so the --tfs value, with the suite label the
runner appends, is the last argument that reaches test-integration.bat. PR CI
passed --rerun-failed-files 2 after it, so the #345871 break in that script,
which depended on the last argument, passed PR CI and failed product builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Bryan Chen (bryanchen-d) added a commit that referenced this pull request Nov 4, 2026
…ct builds (#345957)

* ci: end the Windows PR Agent Host E2E arguments with --tfs like product builds

Product builds pass --tfs last, so the --tfs value, with the suite label the
runner appends, is the last argument that reaches test-integration.bat. PR CI
passed --rerun-failed-files 2 after it, so the #345871 break in that script,
which depended on the last argument, passed PR CI and failed product builds.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* ci: keep --runList last and pair the node.js integration step

The Agent Host E2E runner consumes --runList and --shard, so --tfs before
--runList still makes the --tfs value the last forwarded argument. The paired
node.js integration step takes the same order, as agentHostTestSelection.test.ts
requires.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

4 participants