coreos / ignition

First boot installer and configuration tool
https://coreos.github.io/ignition/
Apache License 2.0
837 stars 247 forks source link

Experiment with running blackbox tests in VMs #728

Open ajeddeloh opened 5 years ago

ajeddeloh commented 5 years ago

Feature Request

Background

Currently the blackbox tests are somewhat terrifying, albeit fast. They run directly on the host, as root, with no isolation except that we use loopback devices. This means working on the test runner itself is particularly fragile and makes it easy to leak disk images all over /var/tmp. It also means running the tests in a container is very hard.

Proposal to experiment with

Run each test in its own (very minimal) vm via qemu (not libvirt, more on that later). The vm image would be three parts: 1) kernel: something minimal that boots to the initramfs very fast. There are a lot of tests, so speed savings here actually matter quite a bit 2) initramfs: probably generated by dracut but with custom dracut modules only. We actually don't want to switch root, we just want something to build a minimal filesystem. We don't want any other cruft that might interfere with the tests either. We basically want udev rules, systemd, something for networking (more on that later), and ignition + the tools it needs. 3) input disk images: This should be generated by the test runner and have a bare skeleton of a linux filesystem (just enough to run things like useradd with the --root flag and other things Ignition does), plus whatever input files are needed for the tests. Additionally we should have a secondary disk to attach for testing things like partitioning.

Generating the initramfs:

Running the tests

Networking

cc @arithx since we chatted about this, let me know if I missed something

arithx commented 5 years ago

It's worth noting that we should also refactor the existing tests to have a generalized input disk so that we can ideally use a single image created by the test runner. Ideally I think the runner should have the functionality to detect the input disks and create an image for each unique input disk so that if we need a custom input set in the future it's possible, but for an initial refactor generating a single image will likely be a sizable time saving.