Skip to content

[WSLC] Add live-host state-aware provision tests to the Rust and .NET SDKs - #1321

Closed
Soham Das (SohamDas2021) wants to merge 1 commit into
sohamdas2021-wslc-image-prepullfrom
sohamdas2021-sdk-wslc-provision-tests
Closed

Soham Das (SohamDas2021) wants to merge 1 commit into
sohamdas2021-wslc-image-prepullfrom
sohamdas2021-sdk-wslc-provision-tests

Conversation

@SohamDas2021

@SohamDas2021 Soham Das (SohamDas2021) commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #1318 — base is sohamdas2021-wslc-image-prepull, not main. No file from that PR is touched.

What was missing

Neither the Rust (mxc-sdk) nor the .NET SDK had a test that provisioned a WSLC sandbox. Their WSLC coverage stopped at request and envelope construction, so only the Node SDK exercised the real in-process path. A binding could have broken end to end and every suite would still have been green.

The staging problem this fixes

A Rust test binary built with --features wslc could not see the WSLC backend at all.

Cargo stages wslcsdk.dll and wxc-wslc-daemon.exe into target/<profile>/, but an integration test runs from target/<profile>/deps/, and both the DLL loader and the daemon lookup search beside the running binary. So available_backends() reported:

["processcontainer"]          <- wslc missing

and after copying the two units into deps/:

["processcontainer", "wslc"]  <- visible

Left alone, a skip-if-unavailable gate would have skipped forever on a host that runs WSLC perfectly well, and the suite would have reported green while testing nothing. The suite now copies both units beside its own binary before the first probe.

That copy compares content, not timestamps: every rebuild re-copies a byte-identical wslcsdk.dll into the profile directory with a fresh mtime, and re-staging a DLL a live daemon already has loaded fails with a sharing violation. An mtime check turned an ordinary rebuild-then-test cycle into five hard failures — caught while validating, and the reason the check reads bytes.

.NET does not have this problem: Microsoft.Mxc.Sdk.csproj already builds -p wxc_wslc_daemon under -p:MxcWithWslc=true and stages the whole native unit into the referencing test project's output.

Covered

Both SDKs drive provision → start → exec → stop → deprovision through their own binding:

  • provision returns a usable sandbox id (wslc: prefix, and the later phases accept it)
  • start plus exec returns the workload's stdout and a zero exit code
  • a non-zero exit propagates unchanged
  • deprovision retires the id, and reusing it is refused with not_provisioned
  • (Rust only) available_backends() reports wslc to a test binary — the named regression test for the staging fix

Every provisioned sandbox is deprovisioned on the unwind path, so a mid-test assertion failure cannot leak a container. Runs are serialized: the .NET class joins the existing MxcLiveHost collection, so it never runs alongside the isolation-session suite either, and the Rust tests take a process-wide lock. Neither touches C:\mxc_wslc_cold_cache_test; they use the default image store.

Skips are loud and convertible: MXC_WSLC_TESTS_REQUIRED=1 turns every skip into a failure, mirroring MXC_ISO_TESTS_REQUIRED. MXC_WSLC_TEST_IMAGE selects the image.

Not covered

  • Pulling. These assume a warm cache; a cache miss is the WSLC executor E2E suite's job, and [WSLC] Pull a missing image instead of failing the run #1318 owns that behaviour.
  • Filesystem, networking, and proxy policy. Provision uses the default isolated posture with no volumes. The policy honour matrix is exercised by the executor fixtures.
  • Streaming, timeout, and cancellation shapes. The Node suite already covers incremental delivery, timedOut, and AbortSignal; this layer proves binding reachability rather than re-testing daemon semantics.
  • Concurrent sandboxes. Concurrent WSLC sessions sharing an image store fail at WslcListSessionImages with ERROR_SHARING_VIOLATION. That is pre-existing and deliberately avoided here, not fixed.

Validation

All run on a live WSLC host; nothing skipped.

cargo fmt --all -- --check                                    clean
cargo clippy --workspace --all-targets --features wslc -D warnings   clean
cargo test -p mxc-sdk --features wslc                         5 passed in 38.5s (wslc_state_aware)
                                                              45 passed overall, 0 failed
Microsoft.Mxc.Sdk.Tests.exe -class MxcWslcLifecycleE2ETests    4 passed, 0 skipped, 46.4s

The Rust suite was also re-run with target/debug/deps/ emptied of both units, to prove the staging helper restores them from cold: 5 passed.

Microsoft Reviewers: Open in CodeFlow

@SohamDas2021
Soham Das (SohamDas2021) requested a review from a team as a code owner September 29, 2026 16:49
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@SohamDas2021
Soham Das (SohamDas2021) added this pull request to stack #1322 September 29, 2026 16:51
… SDKs

Neither the Rust nor the .NET SDK had a test that provisioned a WSLC
sandbox; their coverage stopped at request and envelope construction, so
only the Node SDK exercised the real in-process path.

Rust gets `src/core/mxc-sdk/tests/wslc_state_aware.rs` and .NET gets
`MxcWslcLifecycleE2ETests` with a `WslcHost` gate modelled on the
isolation-session suites. Both drive provision, start, exec, stop, and
deprovision through their own binding, assert the minted id, the
workload's stdout and exit code, a non-zero exit, and that a
deprovisioned id is refused. Both deprovision on the unwind path so a
failed assertion cannot leak a container, and both serialize: the .NET
class joins the existing MxcLiveHost collection, and the Rust tests take
a process-wide lock.

A Rust test binary built with `--features wslc` could not see the WSLC
backend at all. Cargo stages `wslcsdk.dll` and `wxc-wslc-daemon.exe` into
`target/<profile>/`, but an integration test runs from
`target/<profile>/deps/`, and both the DLL loader and the daemon lookup
search beside the running binary. `available_backends()` therefore
dropped `wslc`, a skip-if-unavailable gate would have skipped forever on
a working host, and the suite would have reported green while testing
nothing. The suite now copies both units beside its own binary before
the first probe, comparing content rather than timestamps because every
rebuild re-copies an identical DLL and re-staging one a live daemon has
loaded fails.

Skips are loud and `MXC_WSLC_TESTS_REQUIRED=1` turns them into failures,
matching `MXC_ISO_TESTS_REQUIRED`. `MXC_WSLC_TEST_IMAGE` selects the
image; the default `alpine:latest` is expected to be cached, since
pulling is already covered by the WSLC executor E2E suite.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings September 29, 2026 16:57
@SohamDas2021
Soham Das (SohamDas2021) force-pushed the sohamdas2021-sdk-wslc-provision-tests branch from fa26d35 to 862df27 Compare September 29, 2026 16:57

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.

Copilot review overview

🟡 Changes recommended

The Rust staging helper can silently run against stale runtime artifacts from an earlier build.

Review effort: Balanced
Findings: 1 Medium severity

Open (1)
What changed in this PR

Adds live-host WSLC lifecycle coverage for the Rust and .NET SDK bindings.

Changes:

  • Adds provision-to-deprovision WSLC integration tests.
  • Stages Rust runtime units and supports mandatory host checks.
  • Documents test prerequisites and environment variables.
File Description
src/​core/​mxc-sdk/​tests/​wslc_state_aware.rs Adds Rust lifecycle tests and runtime staging.
src/​core/​mxc-sdk/​README.md Documents Rust WSLC test setup.
sdk/​dotnet/​README.md Documents .NET WSLC host tests.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​WslcHost.cs Adds the .NET host availability gate.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​MxcWslcLifecycleE2ETests.cs Adds .NET lifecycle tests and cleanup.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +41 to +50
if !source.exists() {
if staged.exists() {
continue;
}
return Err(format!(
"{unit} is beside neither this test binary nor {}; produce both units with \
`cargo build -p wxc_wslc_daemon -p mxc-sdk --features mxc-sdk/wslc`",
profile_dir.display()
));
}
An error occurred while trying to automatically change base from sohamdas2021-wslc-image-prepull to main October 1, 2026 17: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.

2 participants