docs: automate gif generation

This commit is contained in:
Willem Vanhulle committed 2026-10-16 11:42:52 +02:00
1 parent a39797cbd2
commit 04219bb58e
18 files changed
+375 -153

No files matched your search

-57
View File
@@ -1,57 +0,0 @@
{ bootvineModule }:
{
name = "bootvine-luks";
enableOCR = true;
nodes.machine =
{ lib, pkgs, ... }:
{
imports = [ bootvineModule ];
services.bootvine.enable = true;
boot.loader.systemd-boot.enable = true;
boot.initrd.systemd.enable = true;
environment.systemPackages = [ pkgs.cryptsetup ];
virtualisation = {
emptyDiskImages = [ 64 ];
useBootLoader = true;
useEFIBoot = true;
mountHostNixStore = true;
};
specialisation.unlock.configuration = {
boot.initrd.luks.devices = lib.mkVMOverride {
secret.device = "/dev/vdb";
};
};
};
testScript = ''
import time
passphrase = "quietly unlocked"
machine.wait_for_unit("multi-user.target")
machine.succeed(f"echo -n '{passphrase}' | cryptsetup luksFormat -q --iter-time=1 /dev/vdb -")
machine.succeed("bootctl set-default nixos-generation-1-specialisation-unlock.conf")
machine.succeed("sync")
machine.crash()
machine.start()
machine.wait_for_text("passphrase")
machine.send_chars("not the passphrase\n")
time.sleep(5)
machine.wait_for_text("passphrase")
machine.screenshot("passphrase")
machine.send_chars(f"{passphrase}\n")
machine.wait_for_unit("multi-user.target")
machine.succeed("test -e /dev/mapper/secret")
journal = machine.succeed("journalctl -b -u bootvine -o cat")
print(journal)
assert "in initrd" in journal, "never ran in the initrd"
assert journal.count("answered a password prompt") == 2, "did not answer both attempts itself"
'';
}
-66
View File
@@ -1,66 +0,0 @@
{ demoHost }:
{
name = "bootvine";
enableOCR = true;
nodes.machine =
{ lib, pkgs, ... }:
let
lingerFor = seconds: lib.mkForce "${pkgs.coreutils}/bin/sleep ${seconds}";
in
{
imports = [ demoHost ];
systemd.settings.Manager.ShowStatus = lib.mkForce true;
systemd.services.demo-db.serviceConfig.ExecStop = lingerFor "20";
virtualisation = {
memorySize = 2048;
qemu.options = [
"-vga none"
"-device virtio-vga,xres=1280,yres=800"
];
};
};
testScript = ''
machine.start()
machine.wait_for_text("Initrd")
machine.screenshot("initrd")
machine.wait_for_text("Stage 2")
machine.screenshot("stage-2")
quieted = machine.succeed("cut -f1 /proc/sys/kernel/printk").strip()
assert quieted == "1", f"stage 2 sysctl reopened the kernel console: {quieted}"
machine.wait_for_unit("greetd.service")
machine.wait_until_succeeds("systemctl show -p ActiveState --value bootvine | grep -qx inactive")
journal = machine.succeed("journalctl -b -u bootvine -o cat")
print(journal)
watched = [line for line in journal.splitlines() if line.startswith("bootvine: watching")]
assert any(" in initrd " in line for line in watched), "never ran in the initrd"
assert any(" in stage 2 " in line for line in watched), "never reconnected after the root switch"
pids = {line.split(" as pid ")[1].split()[0] for line in watched}
assert len(pids) == 1, f"the initrd process did not survive the root switch: {pids}"
assert "handing the console over" in journal, "never handed the console over"
machine.succeed("test \"$(systemctl show -p Result --value bootvine)\" = success")
console_level = machine.succeed("cut -f1 /proc/sys/kernel/printk").strip()
assert console_level != "1", f"kernel console level was not restored: {console_level}"
show_status = machine.succeed("systemctl show -p ShowStatus --value").strip()
assert show_status == "yes", f"systemd status output was not restored: {show_status}"
machine.screenshot("handed-over")
foreground = machine.succeed("cat /sys/class/tty/tty0/active").strip()
machine.succeed("systemctl restart bootvine")
machine.wait_until_succeeds("systemctl show -p ActiveState --value bootvine | grep -qx inactive", timeout=10)
assert "boot already finished" in machine.succeed("journalctl -u bootvine -o cat"), "a restart after boot did not stand down"
still_foreground = machine.succeed("cat /sys/class/tty/tty0/active").strip()
assert still_foreground == foreground, f"a restart after boot took the console: {foreground} -> {still_foreground}"
machine.succeed("systemctl poweroff --no-block")
machine.wait_for_text("demo-db")
machine.screenshot("shutdown")
machine.wait_for_shutdown()
'';
}