Skip to content

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.

File (dnf/)Role
tests/installer/run.pyScenarios, driven by pexpect
tests/installer/dnf-vm.shQEMU machine : UEFI, disk, USB key
tests/installer/default.nixinstaller-test, try, try-local commands
.github/workflows/installer-test.ymlCI, 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 🡕.

ScenarioWhat is exercised
preflightCable unplugged, pre-checks
scriptedAnswer file, plain disk
interactiveConsole questions, encrypted disk
resumeLink 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 uses 10.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.
  1. Prerequisites

    /dev/kvm accessible (otherwise emulation, much slower), 25 GB free per scenario, Internet access.

  2. Run

    Fenêtre de terminal
    just test-installer # all four scenarios
    just test-installer preflight # a single one
    just test-installer scripted /chemin/de/l.iso # another ISO
    just test-installer gateway '' chemin/de/dnf-generator

    gateway, outside the four: the administration workstation installed, then darkone add gateway on 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 has darkone add gateway.

    Without an ISO, the recipe builds one from the current tree, on the generator pinned by dnf/flake.lock.

  3. Read the result

    One TEST line per step, then Scenario <nom>: OK or FAILED. Disks and logs: ~/.cache/dnf-installer-test/<scénario>/, the disk erased after a success.

An unpublished generator can be tested on an ISO built from its local copy, from dnf/:

Fenêtre de terminal
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/*.iso

Only 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.

The recipe only exposes the scenario and the ISO. The program also accepts :

Fenêtre de terminal
nix run .#installer-test -- --iso "$iso" --scenario scripted \
--memory 4096 --workdir /tmp/dnf-test --keep
OptionEffect
--scenarioA scenario, or all (default)
--workdirDisks and logs, short path
--memoryVM RAM in MiB (default 8192)
--keepKeeps the disks after a success

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.

  1. Lower the threshold

    On a copy of the generator, lower MIN_RAM_MIB below the smallest size to measure and commit, then build the ISO on it (local generator).

  2. One size per run

    Fenêtre de terminal
    nix run .#installer-test -- --iso "$iso" --scenario scripted --memory 4096
  3. Read the verdict

    Compare the duration to that of 8192 MiB. A saturated VM does not complete, the test gives up after 90 minutes.

  4. Report

    MIN_RAM_MIB just below the MemTotal of 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.

Fenêtre de terminal
grep rchar /proc/$(pgrep -f qemu-system)/io

Reference measurement, default administration workstation (14 GB copied) :

VM RAMscripted
4096 MiBUnfinished after 90 min
6144 MiB12 min
8192 MiB12 min

Hence the 5500 MiB threshold : a 6 GB machine passes, a 4 GB one is refused.

To try the current tree in a QEMU window :

Fenêtre de terminal
just try # disk kept
just try reset path/to/dnf-generator # fresh disk, local generator

Unlike 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.

The QEMU socket path exceeds 107 bytes, the limit of a Unix socket : choose a shorter --workdir, /tmp/dnf-test for example.

<workdir>/<scenario>/serial.log : the whole serial console, wizard and nixos-install included. Its path follows the FAILED line; --keep also keeps the disk.