Skip to content

test(tart): cover the provider with real processes and, on request, real VMs - #101

Merged
ysya merged 2 commits into
mainfrom
test/tart-process-and-real-host
Dec 1, 2026
Merged

ysya merged 2 commits into
mainfrom
test/tart-process-and-real-host

Conversation

@ysya

@ysya ysya commented Dec 1, 2026

Copy link
Copy Markdown
Owner

Second of four stacked PRs. Stacked on #100; merge that first.

Why

The Tart tests answered every command from a mock inside the test process. A mock cannot show what ends a tart run process or whether anything waits for it to be gone, which is where the last two Tart bugs were. This adds two more levels.

Real processes, in CI

internal/provider/tart_process_test.go puts a stand-in tart shell script on PATH: a VM is a directory, and it is up while its tart run process lives. The provider then starts, kills and waits for real processes through os/exec. Three tests:

  • a VM's process survives the cancellation of its start context, and removal ends it;
  • Shutdown returns only once the processes it killed are gone;
  • Shutdown ends and deletes warm pool VMs, whatever step the pool worker was at.

They run on Linux and macOS with the rest of the suite. Each of the first two fails when its fix is reverted. They do not touch the test machine's network: the provider's automatic MTU lookup is off.

Real VMs, on request

The TestTartIntegration_ tests in internal/provider and internal/controller boot VMs with the real tart. They skip unless RUNSCALER_TEST_TART_IMAGE is set, so go test ./... and CI are unaffected. No CI can run them: Tart needs Apple silicon, and GitHub-hosted Apple silicon runners do not support nested virtualization.

scripts/prepare-tart-test-image.sh prepares the base image. It installs a stand-in for the Actions runner, a script that prints the runner's ready line and keeps a Runner.Listener process alive, so the tests register nothing with GitHub. In the controller test, jobs are delivered by calling the job handlers.

docs/development.md and its Traditional Chinese counterpart gain a "Testing" section that says when to run them and how.

Verified on a Tart host

An Apple silicon host with tart 2.40.1 and a macOS guest. The script prepared the image in 36 s, and all five tests passed with no VM or tart run process left behind:

Test Result
VM outlives its start context still running 5 s after the cancel; removal took under 1 s
Shutdown waits for the VM's process returned in 4 ms with the process gone
start cancelled once the runner is started the VM was returned, still running
Shutdown ends and deletes a warm VM returned in 0.1 s; VM deleted
two scale sets sharing the host's two VM slots both finished runners removed, both second runners idle 34 s later

Not verified

  • A real runner and real jobs from GitHub.
  • Linux guests, bridged networking and Softnet.

ysya added 2 commits December 2, 2026 01:30
Tart can create the clone and still fail, for example when a cancelled
context kills the command. Nothing tracked that VM yet, so it stayed on
disk until the next start of runscaler removed it as an orphan. A warm pool
that was shut down while a worker was cloning its next VM left one behind
about one time in three.

A failed clone is now deleted, with a deadline. A clone refused by the
free-space floor never reached Tart, and one Tart refused because the name
is taken left a VM that belongs to someone else, so neither is deleted.
…eal VMs

The Tart tests answered every command from a mock inside the test process,
which cannot show what ends a `tart run` or whether anything waits for it.

A stand-in `tart` shell script now lets three tests run the provider
through os/exec. They run in CI on Linux and macOS and fail if a VM's
process dies with its start context, or if Shutdown returns before the
processes it killed are gone.

The `TestTartIntegration_` tests boot VMs with the real `tart` and skip
unless RUNSCALER_TEST_TART_IMAGE is set. No CI can run them, because Tart
needs Apple silicon and hosted Apple silicon runners cannot nest a VM.
scripts/prepare-tart-test-image.sh prepares their base image with a
stand-in for the Actions runner, so they register nothing with GitHub.
docs/development.md says when and how to run them.
Base automatically changed from fix/tart-failed-clone-leftover to main December 1, 2026 19:31
@ysya
ysya merged commit f96cb46 into main Dec 1, 2026
7 checks passed
@ysya
ysya deleted the test/tart-process-and-real-host branch December 1, 2026 19:31
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