Skip to content

sanity: run the WSL tests on WSL2 again and fix the WSL desktop launch - #342405

Merged
Martin Aeschlimann (aeschli) merged 31 commits into
mainfrom
agents/sanity-wsl2-current-wsl
Nov 2, 2026
Merged

Martin Aeschlimann (aeschli) merged 31 commits into
mainfrom
agents/sanity-wsl2-current-wsl

Conversation

@alexdima

@alexdima Alexandru Dima (alexdima) commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

Restores the Windows x64 WSL sanity tests by installing the pinned current WSL release, including its WSL2 kernel, and fixing desktop launch and connection readiness. This makes the WSL coverage in #342227 usable again, including its regression check for #341396.

Scope and Related PRs

The remaining diff is four files: the sanity pipeline template, the Windows setup script, the WSL tests, and directly related README updates.

Remaining Changes

  • Install the WSL release pinned in build/checksums/wsl.txt on Windows x64 before importing Ubuntu. ARM64 installation behavior is unchanged.
  • Cache the installer and include build/checksums in the pipeline's sparse checkout.
  • Set WSL_UTF8=1 so redirected distribution names can be read correctly.
  • Convert Ubuntu to WSL2 only when needed, using the shared bounded Invoke-WslExe helper for the new version probe. A timeout or nonzero exit code is not treated as a successful probe.
  • Fail and retry HTTP errors while downloading the Ubuntu rootfs.
  • Pass --folder-uri last when launching the WSL desktop test, avoiding Electron's refusal to accept arguments following a URL-like argument.
  • Wait for the connected WSL: ... remote indicator rather than any text containing WSL.
  • Wait for WSL2 localhost forwarding through the existing retrying /version fetch before navigating the server-web test.

Validation

Current Head

Merged origin/main at 72a22c9d71f into the PR branch. The validated PR head is 084ebfde057f18ec2436a984f75f60b48989d1e2; the diff remains limited to the four files described above.

  • pnpm --dir test/sanity exec tsc --noEmit: passed.
  • pnpm run eslint test/sanity/src/wsl.test.ts: passed.
  • git diff --cached --check: passed.
  • git diff --check: passed.
  • git commit: passed, including the required pre-commit hygiene hook.

Product build 491899 built and tested that exact PR head. All nine Windows x64 sanity tests passed, including wsl-server-x64, wsl-server-web-x64, and wsl-desktop-x64. Each WSL test executed once, without a test retry. The log confirms WSL 3.0.3.0, Ubuntu running as WSL2, the connected WSL: Ubuntu indicator, and Markdown-preview coverage.

The overall build is partially successful, not fully green: native Linux sanity attempted desktop-linux-snap-x64 and received a 404 because this validation configuration disabled the Snap build. Windows x64 sanity, Windows/Linux build stages, Web, and Publish passed. Artifact publishing was enabled with approval; VSCODE_RELEASE=false and no release stage ran.

Historical Windows Evidence

Before removing the overlap, Product Sanity Tests run 485962, against Insiders 341e0fa9, passed all nine Windows x64 tests. wsl-server-x64, wsl-server-web-x64, and wsl-desktop-x64 all passed on their first attempt.

The combined WSL2 provisioning and Markdown-preview check also caught #341396: run 485823 failed on buggy c03d2e4a with webview resource 401s, while run 485824 passed on fixed 16d22415. The preview assertion now belongs only to #342227; these are historical results, not a rerun of the simplified head.

WSL sanity tests have been silently skipped on Windows agents since the
Electron v42 update (#316661) forced WSL2: agents lack the WSL2 kernel, so
the Ubuntu import fails and the `wsl` capability is never detected.

- Fall back to importing Ubuntu with WSL1 when the default import fails
- Fail the job instead of skipping WSL tests when Ubuntu is unavailable
- Open a Markdown preview in UI sanity tests and fail on webview resource
  errors, which would have caught #341396 (401 for wsl+Ubuntu)

Co-authored-by: Copilot <[email protected]>
…e WSL on x64

The inbox wsl.exe on Windows Server 2022 exits with -1, which `if errorlevel 1`
does not detect, so the WSL1 fallback and the missing-distro check never ran
on x64 agents. ARM64 agents do not have WSL installed, so only warn there.

Co-authored-by: Copilot <[email protected]>
…1 import

A hung wsl.exe call blocked the Windows x64 sanity job until it hit the job
timeout, and the unresponsive agent dropped the step log. Run every wsl.exe
call in the setup script and the tests with a 5 minute timeout, and do not
try to convert Ubuntu to WSL2 after the import fell back to WSL1 on agents
without the WSL2 kernel.

Co-authored-by: Copilot <[email protected]>
Importing Ubuntu with WSL1 makes the Windows x64 WSL sanity tests hang, so
hold back the WSL1 fallback and the hard failure until the agents have the
WSL2 kernel. Until then, log a pipeline warning so that skipped WSL tests are
visible in the build summary instead of being skipped silently.

Co-authored-by: Copilot <[email protected]>
…iew service workers

Chromium on Debian 12 fails to register the webview service worker with
NotSupportedError, so no webview can load in that environment. Log a pipeline
warning and skip the check there instead of failing the job.

Co-authored-by: Copilot <[email protected]>
The Windows PR smoke step that provisions WSL flaked 16 times between Oct 10 and 17. Every flake happened inside the runner's WSL2 VM, never in a download: either wsl --import hung until the step timed out (9), or apt-get/containerd crashed right after the first boot (7). A re-run on a new VM passes.

Provisioning only sets up test infrastructure, so in PR CI a failure no longer fails the job. The WSL suite skips itself at runtime, so the shard split doesn't change. Lower the setup timeout from 15 to 10 minutes, since a healthy setup takes under 2. The Azure DevOps product build still requires the suite.

Co-authored-by: Copilot <[email protected]>
The Windows Server 2022 agents only have the inbox WSL (wsl.exe 10.0.20348). With the 2021 standalone WSL2 kernel (5.10.16), its utility VM intermittently hangs on import, shuts down right after boot, or crashes processes such as apt-get and containerd. Earlier fixes (#337229, #337644, #338047) worked around single symptoms.

- Install the WSL release pinned in build/checksums/wsl.txt (3.0.3) from build/azure-pipelines/common/wsl.psm1, verifying its SHA256 and Microsoft signature, and log the host CPU and WSL versions.
- Cache the installer by that pin: actions/cache, filled on main by pr-node-modules.yml, and Cache@2 in the product build. This replaces the daily kernel installer cache.
- Run every wsl.exe call with a timeout, so a hung import is retried on a fresh utility VM and diagnostics and cleanup can't hang.
- Retry downloads on all errors.

Co-authored-by: Copilot <[email protected]>
The Windows Server 2022 agents only have the inbox WSL without a WSL2 kernel, so importing Ubuntu with WSL2 failed and every wsl-* sanity test has been skipped since late May. Install the WSL release pinned in build/checksums/wsl.txt with the shared build/azure-pipelines/common/wsl.psm1 before importing Ubuntu, cache its installer, and make wsl.exe write UTF-8 so the Ubuntu checks match.

Co-authored-by: Copilot <[email protected]>
With current WSL, Ubuntu imports as WSL2, and converting it again fails with WSL_E_VM_MODE_INVALID_STATE, which logged a misleading WSL1 fallback warning.

Co-authored-by: Copilot <[email protected]>
100 of 100 probe VMs provisioned WSL successfully in 92-124 seconds.

Co-authored-by: Copilot <[email protected]>
…te test

The kernel cache day and kernel installer cache steps were replaced by a single version-keyed WSL installer cache.

Co-authored-by: Copilot <[email protected]>
On Windows, Electron exits with -1 when any argument follows a URL-like argument (its CVE-2018-1000006 mitigation). Since #319498 appended --crash-reporter-directory after --folder-uri vscode-remote://..., Code exited immediately in wsl-desktop-* and the test failed with 'Process failed to launch!'.

Co-authored-by: Copilot <[email protected]>
The WSL desktop test waited for any text matching /WSL/, which the extension install prompt already shows, so on the first attempt it raced the WSL extension installing the server and timed out at the New File input instead.

Co-authored-by: Copilot <[email protected]>
…ver-web page

Under WSL2, localhost reaches the distribution through a forwarder that can lag behind the server starting to listen, so page.goto sometimes failed with ERR_CONNECTION_REFUSED. Fetch the page with the existing retrying helper first, as the WSL server test already does for its version request.

Co-authored-by: Copilot <[email protected]>
The indicator can briefly show 'Disconnected from WSL' while the WSL extension installs the server, which also matched /WSL/.

Co-authored-by: Copilot <[email protected]>
@alexdima
Alexandru Dima (alexdima) changed the base branch from agents/wsl-ssh-tests-regression-fix to main October 18, 2026 17:52
…sion endpoint

The workbench URL with the connection token answers with a redirect that sets a cookie, which fetch does not keep, so it got 403.

Co-authored-by: Copilot <[email protected]>
Copilot AI balanced review requested due to automatic review settings October 18, 2026 18:24

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

An unbounded WSL setup probe can still stall the entire sanity job after provisioning times out.

1 open issue
What changed in this PR

Restores Windows x64 WSL sanity coverage by installing pinned, current WSL, building on the shared smoke-test installer and webview checks.

Changes:

  • Installs and caches WSL, with bounded provisioning commands.
  • Improves WSL readiness checks and adds Markdown webview validation.
  • Updates CI integration, smoke-test fallback behavior, and documentation.
File Description
test/​smoke/​wslDevContainer.ps1 Uses shared installation and bounded WSL commands.
test/​smoke/​src/​areas/​agentsWindow/​agentsWindow.test.ts Skips tests after PR provisioning failure.
test/​sanity/​src/​wsl.test.ts Improves connection readiness and launch arguments.
test/​sanity/​src/​uiTest.ts Adds Markdown preview resource checks.
test/​sanity/​src/​runWsl.ts Adds a timeout-controlled WSL wrapper.
test/​sanity/​src/​context.ts Bounds synchronous WSL calls.
test/​sanity/​scripts/​run-win32.cmd Installs current WSL and prepares Ubuntu.
test/​sanity/​README.md Documents setup and webview checks.
build/​lib/​test/​testCheckpointTemplates.test.ts Updates cache-step expectations.
build/​checksums/​wsl.txt Pins the WSL installer checksum.
build/​azure-pipelines/​win32/​steps/​product-build-win32-test.yml Updates smoke installer caching.
build/​azure-pipelines/​common/​wsl.psm1 Adds shared installation and timeout helpers.
build/​azure-pipelines/​common/​sanity-tests.yml Adds installer caching and checksum checkout.
.github/​workflows/​pr-win32-test.yml Integrates caching and provisioning fallback.
.github/​workflows/​pr-node-modules.yml Populates the shared installer cache.
.github/​skills/​smoke-tests/​SKILL.md Documents WSL provisioning and sharding behavior.
.github/​actions/​restore-wsl-installer/​action.yml Adds reusable installer cache handling.

Review effort: Balanced

Comment thread test/sanity/scripts/run-win32.cmd Resolved
@alexdima Alexandru Dima (alexdima) changed the title sanity: install current WSL on Windows x64 so the WSL tests run on WSL2 sanity: run the WSL tests on WSL2 again and fix the WSL desktop launch Oct 18, 2026
Skipping the WSL Dev Container suite after a failed setup hid real regressions in the setup or the WSL path behind a green job. It was a stopgap while setup flaked on the inbox WSL; with current WSL installed, a failed setup should fail the PR. Restore the 15-minute step timeout so the bounded import retries have room.

Co-authored-by: Copilot <[email protected]>
Take WSL runner hardening from merged #342616 and leave Markdown preview coverage to #342227. Keep #342405 focused on WSL2 provisioning, installer caching, desktop launch ordering and connection readiness.

Use the shared bounded WSL helper for the new version probe.

Co-authored-by: Copilot <[email protected]>
Preserve the current pipeline setup and webview documentation alongside the WSL2 provisioning and launch fixes.

Co-authored-by: Copilot <[email protected]>
@aeschli

Copy link
Copy Markdown
Contributor

Updated the branch with origin/main at 72a22c9; PR head is 084ebfd.

Validation: product build 491899 tested that exact PR head using the existing product pipeline. All 9 Windows x64 sanity tests passed, including wsl-server-x64, wsl-server-web-x64, and wsl-desktop-x64. Each WSL test executed once, without a test retry. The log confirms WSL 3.0.3.0 and Ubuntu running as WSL2.

Local validation passed: pnpm --dir test/sanity exec tsc --noEmit, pnpm run eslint test/sanity/src/wsl.test.ts, git diff --cached --check, git diff --check, and the commit hygiene hook.

The overall build is partially successful: Windows/Linux build stages, Web, and Publish passed, but native Linux sanity attempted desktop-linux-snap-x64 and received 404 because this validation configuration disabled the Snap build. This is a validation-scope artifact omission, not a Windows/WSL failure. Artifact publishing was enabled with approval; VSCODE_RELEASE=false and no release stage ran.

The blocked standalone validation run was cancelled, its temporary pipeline was disabled, and its temporary branch was deleted. Shared sanity pipeline 658 remains disabled.

Martin Aeschlimann (aeschli) added a commit that referenced this pull request Nov 2, 2026
<!-- Thank you for submitting a Pull Request. Please:
* Read our Pull Request guidelines:
  https://github.com/microsoft/vscode/wiki/How-to-Contribute#pull-requests
* Associate an issue with the Pull Request.
* Ensure that the code is up-to-date with the `main` branch.
* Include a description of the proposed changes and how to test them.
-->

## Summary

Exclude `desktop-linux-snap-x64` from the product pipeline's native Linux sanity job when `VSCODE_BUILD_LINUX_SNAP=false`. Keep the job and all its other sanity coverage enabled. When Snap building is enabled, preserve the existing unfiltered selection.

Add a regression test covering both flag values and document the selection behavior.

## Why

[Validation build 491899](https://dev.azure.com/monacotools/Monaco/_build/results?buildId=491899) disabled Snap building but enabled Linux x64. The native Linux sanity job still tried to download `linux-snap-x64` for that commit and failed with a 404 because no Snap artifact was built or published.

Found while validating #342405. This is a separate fix based on `main`; it does not include that PR's WSL changes.

## Validation

- Regression test against the unchanged pipeline: failed as expected because Snap remained selected with Snap building disabled.
- `node --test build/lib/test/sanityTestSelection.test.ts build/lib/test/testCheckpointTemplates.test.ts`: passed, 15 tests.
- `pnpm run eslint build/lib/test/sanityTestSelection.test.ts`: passed.
- `pnpm exec tsc --noEmit --target ES2024 --module NodeNext --strict --skipLibCheck --types node build/lib/test/sanityTestSelection.test.ts`: passed.
- `git diff --check` and `git diff --cached --check`: passed.
- Commit hygiene hook: passed.
- Azure pipeline 111 preview expansion at commit `9849d742ac1`, with `VSCODE_BUILD_LINUX=true` and each value of `VSCODE_BUILD_LINUX_SNAP`: passed. Verified that the native Linux job remains present in both expansions, the disabled-Snap command adds only the exclusion filter, and the enabled-Snap command remains unfiltered. These were preview-only requests; no product builds, publication, or releases were triggered.

A full product-build/end-to-end sanity rerun was not performed for this follow-up.
@aeschli
Martin Aeschlimann (aeschli) marked this pull request as ready for review November 2, 2026 22:06
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ladislau Szomoru (@lszomoru)

Matched files:

  • build/azure-pipelines/common/sanity-tests.yml

Dmitriy Vasyura (@dmitrivMS)

Matched files:

  • build/azure-pipelines/common/sanity-tests.yml
  • test/sanity/README.md
  • test/sanity/scripts/run-win32.cmd
  • test/sanity/src/wsl.test.ts

@aeschli
Martin Aeschlimann (aeschli) merged commit ccbfe28 into main Nov 2, 2026
55 checks passed
@aeschli
Martin Aeschlimann (aeschli) deleted the agents/sanity-wsl2-current-wsl branch November 2, 2026 22:20
@vs-code-engineering vs-code-engineering Bot added this to the 1.146.0 milestone Nov 2, 2026
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