diff options
author | Florian Klink <flokli@flokli.de> | 2024-03-18T10·09+0200 |
---|---|---|
committer | flokli <flokli@flokli.de> | 2024-04-16T18·45+0000 |
commit | cf47294b9ee7887ca1f21db34d48c346e89f9cec (patch) | |
tree | 26242f47abf091e0e3281a9727d7ae31af9242c4 /tvix | |
parent | 538d5fc8eef825f97add6a34f708d9a6b87a3ebd (diff) |
feat(tvix/boot): boot nixos VM r/7951
This makes use of the vmCmdline and assertVMOutput to boot a NixOS VM off of `tvix-store virtiofs` have it write a message on successful bootup, then have it shut down again. We check we see the message in the output. Seeding the store with the closure it's what's currently taking most of the time (as it's all linear still), so log a message before booting the VM. Change-Id: I6887d935f589eb0ad6507033c01337e1ec500a0b Reviewed-on: https://cl.tvl.fyi/c/depot/+/11191 Autosubmit: flokli <flokli@flokli.de> Reviewed-by: raitobezarius <tvl@lahfa.xyz> Tested-by: BuildkiteCI
Diffstat (limited to 'tvix')
-rw-r--r-- | tvix/boot/tests/default.nix | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/tvix/boot/tests/default.nix b/tvix/boot/tests/default.nix index 949be35ccf53..d16dba79f140 100644 --- a/tvix/boot/tests/default.nix +++ b/tvix/boot/tests/default.nix @@ -70,12 +70,38 @@ let tvix-store --otlp=false copy '' + '' # Invoke a VM using tvix as the backing store, ensure the outpath appears in its listing. + echo "Starting VM…" CH_CMDLINE="${vmCmdline}" run-tvix-vm 2>&1 | tee output.txt grep "${assertVMOutput}" output.txt ''; requiredSystemFeatures = [ "kvm" ]; }; + + systemFor = sys: (depot.ops.nixos.nixosFor sys).system; + + testSystem = systemFor ({ modulesPath, pkgs, ... }: { + # Set some options necessary to evaluate. + boot.loader.systemd-boot.enable = true; + # TODO: figure out how to disable this without causing eval to fail + fileSystems."/" = { + device = "/dev/root"; + fsType = "tmpfs"; + }; + + services.getty.helpLine = "Onwards and upwards."; + systemd.services.do-shutdown = { + after = [ "getty.target" ]; + description = "Shut down again"; + wantedBy = [ "multi-user.target" ]; + serviceConfig.Type = "oneshot"; + script = "/run/current-system/sw/bin/systemctl poweroff --when=+10s"; + }; + + # Don't warn about stateVersion. + system.stateVersion = "24.05"; + }); + in depot.nix.readTree.drvTargets { @@ -101,4 +127,12 @@ depot.nix.readTree.drvTargets path = depot.tvix.store; isClosure = true; }); + + closure-nixos = (mkBootTest { + blobServiceAddr = "objectstore+file://$PWD/blobs"; + path = testSystem; + isClosure = true; + vmCmdline = "init=${testSystem}/init panic=-1"; # reboot immediately on panic + assertVMOutput = "Onwards and upwards."; + }); } |