tests/nixos/first-switch.nix
The AMI's first boot (nixos/amazon.nix) with #filnix user data: the filnix-first-switch unit switches to the named system while boot goes on. As a oneshot it deadlocked: switch-to-configuration waited for multi-user.target's start job, which waited for the unit doing the switch. The target here is a system in the store, so the VM needs no network.
λfilnix
let
λlib, …
used by nodes.machine nodes.target
in
"first-switch"
Test nodes leave switch-to-configuration out by default.
true
A new service wanted by multi-user.target, as demo-wiki's are: the switch then starts the target, whose boot start job was still waiting for the unit doing the switch.
uses amazon
λnodes, …
machine.start()
machine.wait_for_unit("multi-user.target")
machine.wait_until_succeeds("test -e /var/lib/filnix-first-switch/done", timeout=900)
current = machine.succeed("readlink -f /run/current-system").strip()
assert current == "${nodes.target.system.build.toplevel}", current
machine.succeed("test \"$(cat /etc/filnix-switched)\" = yes")
machine.succeed("systemctl is-active filnix-switched.service")
machine.succeed("systemctl show -p Result --value filnix-first-switch | grep -qx success")
# It runs once.
machine.systemctl("restart filnix-first-switch")
machine.succeed("journalctl -u filnix-first-switch | grep -q 'switching to'")
machine.succeed("journalctl -u filnix-first-switch -o cat | grep -A3 'units failed' | grep -q filnix-switch-broken")
print(machine.succeed("journalctl -u filnix-first-switch -o cat"))