From f0178e45eb6f218acef4e8ae46aaea052a2171c7 Mon Sep 17 00:00:00 2001 From: Florian Klink Date: Sat, 26 Feb 2022 22:38:28 +0100 Subject: [PATCH] nixosTests.kexec: extend with kexecBoot attribute Add a node2, which imports the kexec-boot.nix profile. Ensure node2 successfully boots up, then invoke the kexec-boot script from it on node1. --- nixos/tests/kexec.nix | 48 +++++++++++++++++++++++++++++++------------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/nixos/tests/kexec.nix b/nixos/tests/kexec.nix index 55b71e0999f6..7be04c740565 100644 --- a/nixos/tests/kexec.nix +++ b/nixos/tests/kexec.nix @@ -1,22 +1,44 @@ # Test whether fast reboots via kexec work. -import ./make-test-python.nix ({ pkgs, lib, ...} : { +import ./make-test-python.nix ({ pkgs, lib, ... }: { name = "kexec"; meta = with lib.maintainers; { maintainers = [ eelco ]; }; - nodes.machine = { ... }: - { virtualisation.vlans = [ ]; }; + nodes = { + node1 = { ... }: { + virtualisation.vlans = [ ]; + virtualisation.memorySize = 2 * 1024; + }; - testScript = - '' - machine.wait_for_unit("multi-user.target") - machine.succeed('kexec --load /run/current-system/kernel --initrd /run/current-system/initrd --command-line "$(&2 &", check_return=False) - machine.connected = False - machine.connect() - machine.wait_for_unit("multi-user.target") - machine.shutdown() - ''; + node2 = { modulesPath, ... }: { + virtualisation.vlans = [ ]; + imports = [ + "${modulesPath}/installer/kexec/kexec-boot.nix" + ]; + }; + }; + + testScript = { nodes, ... }: '' + node1.wait_for_unit("multi-user.target") + node1.succeed('kexec --load /run/current-system/kernel --initrd /run/current-system/initrd --command-line "$(&2 &", check_return=False) + node1.connected = False + node1.connect() + node1.wait_for_unit("multi-user.target") + + + # Check the machine with kexec-boot.nix profile boots up + node2.wait_for_unit("multi-user.target") + node2.shutdown() + + # Kexec node1 to the toplevel of node2 via the kexec-boot script + node1.execute('${nodes.node2.config.system.build.kexecBoot}/kexec-boot', check_return=False) + node1.connected = False + node1.connect() + node1.wait_for_unit("multi-user.target") + + node1.shutdown() + ''; })