Testing the installer
The installer test runs darkone new end to end in a
QEMU 🡕/KVM VM, on the real network : what a newcomer
downloads, the test downloads. The same tool runs locally and in
continuous integration.
What is where
Section titled “What is where”File (dnf/) | Role |
|---|---|
tests/installer/run.py | Scenarios, driven by pexpect |
tests/installer/dnf-vm.sh | QEMU machine : UEFI, disk, USB key |
tests/installer/default.nix | installer-test, try, try-local commands |
.github/workflows/installer-test.yml | CI, three scenarios in parallel |
run.py boots the generic ISO, selects 1 from the tty1 menu via the emulated
keyboard, then drives the wizard through the serial console. The cable
(set_link) and the USB key (device_del, device_add) go through
QMP 🡕.
The scenarios
Section titled “The scenarios”| Scenario | What is exercised |
|---|---|
preflight | Cable unplugged, pre-checks |
scripted | Answer file, plain disk |
interactive | Console questions, encrypted disk |
resume | Link cut, Ctrl-C, then Resume |
preflight: no installation, about one minute.- The other three : about 30 minutes and 25 GB of disk each.
all(default) : the four, in that order.
preflight requires the network error before the first question, then, with the
cable plugged back in, that Check again leads to the questions. scripted
starts without network : the cable is plugged in when tty1 waits for it.
interactive unplugs then replugs the backup key, and unlocks the first boot
through the initrd sshd. resume checks that only the disk passphrase is asked
again, and that the disk is not wiped.
After an installation, the system reboots and is checked over SSH :
- zone prefix
10.1(the QEMU network uses10.0) ; - system
running, no failed unit, clean/etc/nixos; - home page installed, backup marker present ;
- second backup with
just backup-admin, the first kept under its date ; - backup opened from the host.
Run locally
Section titled “Run locally”-
Prerequisites
/dev/kvmaccessible (otherwise emulation, much slower), 25 GB free per scenario, Internet access. -
Run
Fenêtre de terminal just test-installer # all four scenariosjust test-installer preflight # a single onejust test-installer scripted /chemin/de/l.iso # another ISOjust test-installer gateway '' chemin/de/dnf-generatorgateway, outside the four: the administration workstation installed, thendarkone add gatewayon a machine with two network cards behind a simulated box (QEMU user network, test bench switch), recabling included. Two installations; it requires a generator that hasdarkone add gateway.Without an ISO, the recipe builds one from the current tree, on the generator pinned by
dnf/flake.lock. -
Read the result
One
TESTline per step, thenScenario <nom>: OKorFAILED. Disks and logs:~/.cache/dnf-installer-test/<scénario>/, the disk erased after a success.
On a local generator
Section titled “On a local generator”An unpublished generator can be tested on an ISO built from its local copy,
from dnf/:
out=$(nix build --no-link --print-out-paths --no-write-lock-file \ --override-input dnf-generator "git+file://$(realpath chemin/de/dnf-generator)" \ .#nixosConfigurations.iso-x86_64-linux.config.system.build.isoImage)just test-installer scripted "$out"/iso/*.isoOnly files tracked by git are included in the ISO: git add any new file
first. Shortcut: just test-installer <scénario> '' chemin/de/dnf-generator
builds the same ISO.
Test program options
Section titled “Test program options”The recipe only exposes the scenario and the ISO. The program also accepts :
nix run .#installer-test -- --iso "$iso" --scenario scripted \ --memory 4096 --workdir /tmp/dnf-test --keep| Option | Effect |
|---|---|
--scenario | A scenario, or all (default) |
--workdir | Disks and logs, short path |
--memory | VM RAM in MiB (default 8192) |
--keep | Keeps the disks after a success |
Measure the memory threshold
Section titled “Measure the memory threshold”The pre-check refuses a machine whose MemTotal is below
MIN_RAM_MIB (src/installer/checks.rs in the generator). This threshold is
measured with scripted, one RAM size at a time.
-
Lower the threshold
On a copy of the generator, lower
MIN_RAM_MIBbelow the smallest size to measure and commit, then build the ISO on it (local generator). -
One size per run
Fenêtre de terminal nix run .#installer-test -- --iso "$iso" --scenario scripted --memory 4096 -
Read the verdict
Compare the duration to that of 8192 MiB. A saturated VM does not complete, the test gives up after 90 minutes.
-
Report
MIN_RAM_MIBjust below theMemTotalof the smallest size that passes, then the prerequisites of the installation.
Without swap, a saturated VM rereads its ISO in a loop : the QEMU read counter then climbs by several GB per second.
grep rchar /proc/$(pgrep -f qemu-system)/ioReference measurement, default administration workstation (14 GB copied) :
| VM RAM | scripted |
|---|---|
| 4096 MiB | Unfinished after 90 min |
| 6144 MiB | 12 min |
| 8192 MiB | 12 min |
Hence the 5500 MiB threshold : a 6 GB machine passes, a 4 GB one is refused.
Try by hand
Section titled “Try by hand”To try the current tree in a QEMU window :
just try # disk keptjust try reset path/to/dnf-generator # fresh disk, local generatorUnlike nix run …#try, the project written by the wizard is pinned to the
ISO’s framework (path:) and not to the template’s release : the installed
system carries the unpublished code. Disk :
~/.local/share/dnf-try-local.
The machine’s store serves as a package cache (nix-serve-ng on
127.0.0.1:5000, started by just try if the port is free). The ISO sets
DNF_URL and DNF_CACHE : a rerun of darkone new in the VM keeps them.
What to do about “workdir too deep”?
Section titled “What to do about “workdir too deep”?”The QEMU socket path exceeds 107 bytes, the limit of a Unix
socket : choose a shorter --workdir, /tmp/dnf-test for example.
Where to read what happened?
Section titled “Where to read what happened?”<workdir>/<scenario>/serial.log : the whole serial console, wizard and
nixos-install included. Its path follows the FAILED line; --keep
also keeps the disk.