Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Allow control of tests run in VMs on the host #5339

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

andrewjstone
Copy link
Contributor

@andrewjstone andrewjstone commented Mar 27, 2024

This is a reworking of falcon_runner.rs that splits the work between a FalconTest harness that allows direct manipulation of the runner so that the full falcon API is available, while also wrapping the bash nonsense to run a test and get the result back.

The harness is minimal at this point, and purposefully so, to allow for complete flexibility. This allows the user to launch multiple VMs, run arbitrary tests, mount arbitrary data directories into VMs, etc... We can provide more batteries included, perhaps with escape hatches, and we can also simplify further with attribute macros for the batteries included parts.

The example test can be run in the following manner, notably without a nextest target runner. pfexec may cause problems with permissions when forced to rebuild however.

 pfexec cargo nextest run -p omicron-test-utils run_launch_in_vm --run-ignored all --nocapture

Notice that we run the "host" test from nextest here, and that test spins up a VM and runs a test (launch) inside it.

This is a reworking of `falcon_runner.rs` that splits the work between
a `FalconTest` harness that allows direct manipulation of the runner
so that the full falcon API is available, while also wrapping the bash
nonsense to run a test and get the result back.

The harness is minimal at this point, and purposefully so, to allow for complete
flexibility. This allows the user to launch multiple VMs, run arbitrary tests,
mount arbitrary data directories into VMs, etc... We can provide more batteries
included, perhaps with escape hatches, and we can also simplify further
with attribute macros for the batteries included parts.
let cargo_bay = tempdir().unwrap();
info!(log, "Set cargo-bay to {} on host machine", cargo_bay.path());
let test_name = "launch";
let source_test_path = &args[0];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a hack to easily find the source binary. It works only if the test to run in the VM is part of the same test binary generated by cargo.


// Mount the cargo-bay into the VM
test.runner()
.mount(cargo_bay.path(), "/opt/cargo-bay", vm)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

"/opt/cargo-bay", and the host path are both arbitrary, and can be anything. As an example, if a test wanted to launch multiple VMs they may all use the same VM mount path, but have different local directories. This is part of the reason for allowing full access to the falcon API.

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