Repository navigation
test(tart): cover the provider with real processes and, on request, real VMs - #101
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 runprocess 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.goputs a stand-intartshell script onPATH: a VM is a directory, and it is up while itstart runprocess lives. The provider then starts, kills and waits for real processes throughos/exec. Three tests:Shutdownreturns only once the processes it killed are gone;Shutdownends 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 ininternal/providerandinternal/controllerboot VMs with the realtart. They skip unlessRUNSCALER_TEST_TART_IMAGEis set, sogo 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.shprepares the base image. It installs a stand-in for the Actions runner, a script that prints the runner's ready line and keeps aRunner.Listenerprocess alive, so the tests register nothing with GitHub. In the controller test, jobs are delivered by calling the job handlers.docs/development.mdand 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 runprocess left behind:Shutdownwaits for the VM's processShutdownends and deletes a warm VMNot verified