checks/installation: restore the install without system aspect

This commit is contained in:
Jörg Thalheim
2025-04-09 10:28:37 +00:00
parent d03971e583
commit 2c83211c1d
2 changed files with 21 additions and 19 deletions

View File

@@ -26,7 +26,7 @@
test-flash-machine = test-flash-machine =
{ lib, ... }: { lib, ... }:
{ {
imports = [ self.nixosModules.test-install-machine ]; imports = [ self.nixosModules.test-install-machine-without-system ];
clan.core.vars.generators.test = lib.mkForce { }; clan.core.vars.generators.test = lib.mkForce { };
@@ -56,7 +56,7 @@
in in
{ {
checks = pkgs.lib.mkIf pkgs.stdenv.isLinux { checks = pkgs.lib.mkIf pkgs.stdenv.isLinux {
test-flash = (import ../lib/test-base.nix) { flash = (import ../lib/test-base.nix) {
name = "flash"; name = "flash";
nodes.target = { nodes.target = {
virtualisation.emptyDiskImages = [ 4096 ]; virtualisation.emptyDiskImages = [ 4096 ];

View File

@@ -70,18 +70,19 @@ let
}; };
in in
{ {
# The purpose of this test is to ensure `clan machines install` works # The purpose of this test is to ensure `clan machines install` works
# for machines that don't have a hardware config yet. # for machines that don't have a hardware config yet.
# If this test starts failing it could be due to the `facter.json` being out of date # If this test starts failing it could be due to the `facter.json` being out of date
# you can get a new one by adding # you can get a new one by adding
# server.fail("cat test-flake/machines/test-install-machine/facter.json >&2") # client.fail("cat test-flake/machines/test-install-machine/facter.json >&2")
# to the installation test. # to the installation test.
clan.machines.test-install-machine = { clan.machines.test-install-machine-without-system = {
fileSystems."/".device = lib.mkDefault "/dev/vda"; fileSystems."/".device = lib.mkDefault "/dev/vda";
boot.loader.grub.device = lib.mkDefault "/dev/vda"; boot.loader.grub.device = lib.mkDefault "/dev/vda";
imports = [ self.nixosModules.test-install-machine ]; imports = [ self.nixosModules.test-install-machine-without-system ];
}; };
clan.machines.test-install-machine-with-system = clan.machines.test-install-machine-with-system =
{ pkgs, ... }: { pkgs, ... }:
@@ -100,15 +101,14 @@ in
fileSystems."/".device = lib.mkDefault "/dev/vda"; fileSystems."/".device = lib.mkDefault "/dev/vda";
boot.loader.grub.device = lib.mkDefault "/dev/vda"; boot.loader.grub.device = lib.mkDefault "/dev/vda";
imports = [ imports = [ self.nixosModules.test-install-machine-without-system ];
self.nixosModules.test-install-machine
];
}; };
flake.nixosModules = { flake.nixosModules = {
test-install-machine = test-install-machine-without-system =
{ lib, modulesPath, ... }: { lib, modulesPath, ... }:
{ {
imports = [ imports = [
(modulesPath + "/testing/test-instrumentation.nix") # we need these 2 modules always to be able to run the tests
(modulesPath + "/profiles/qemu-guest.nix") (modulesPath + "/profiles/qemu-guest.nix")
../lib/minify.nix ../lib/minify.nix
]; ];
@@ -173,6 +173,7 @@ in
}; };
}; };
}; };
perSystem = perSystem =
{ {
pkgs, pkgs,
@@ -210,12 +211,13 @@ in
installer.wait_until_succeeds("timeout 2 ssh -o StrictHostKeyChecking=accept-new -v nonrootuser@localhost hostname") installer.wait_until_succeeds("timeout 2 ssh -o StrictHostKeyChecking=accept-new -v nonrootuser@localhost hostname")
installer.succeed("cp -r ${../..} test-flake && chmod -R +w test-flake") installer.succeed("cp -r ${../..} test-flake && chmod -R +w test-flake")
installer.succeed("clan machines install --no-reboot --debug --flake test-flake --yes test-install-machine --target-host nonrootuser@localhost --update-hardware-config nixos-facter >&2") installer.succeed("clan machines install --no-reboot --debug --flake test-flake --yes test-install-machine-without-system --target-host nonrootuser@localhost --update-hardware-config nixos-facter >&2")
installer.shutdown()
# We are missing the test instrumentation somehow. Test this later. # We are missing the test instrumentation somehow. Test this later.
#target.state_dir = installer.state_dir target.state_dir = installer.state_dir
#target.start() target.start()
#target.wait_for_unit("multi-user.target") target.wait_for_unit("multi-user.target")
''; '';
} { inherit pkgs self; }; } { inherit pkgs self; };
@@ -231,13 +233,13 @@ in
installer.fail("test -f test-flake/machines/test-install-machine/hardware-configuration.nix") installer.fail("test -f test-flake/machines/test-install-machine/hardware-configuration.nix")
installer.fail("test -f test-flake/machines/test-install-machine/facter.json") installer.fail("test -f test-flake/machines/test-install-machine/facter.json")
installer.succeed("clan machines update-hardware-config --debug --flake test-flake test-install-machine nonrootuser@localhost >&2") installer.succeed("clan machines update-hardware-config --debug --flake test-flake test-install-machine-without-system nonrootuser@localhost >&2")
installer.succeed("test -f test-flake/machines/test-install-machine/facter.json") installer.succeed("test -f test-flake/machines/test-install-machine-without-system/facter.json")
installer.succeed("rm test-flake/machines/test-install-machine/facter.json") installer.succeed("rm test-flake/machines/test-install-machine-without-system/facter.json")
installer.succeed("clan machines update-hardware-config --debug --backend nixos-generate-config --flake test-flake test-install-machine nonrootuser@localhost>&2") installer.succeed("clan machines update-hardware-config --debug --backend nixos-generate-config --flake test-flake test-install-machine-without-system nonrootuser@localhost >&2")
installer.succeed("test -f test-flake/machines/test-install-machine/hardware-configuration.nix") installer.succeed("test -f test-flake/machines/test-install-machine-without-system/hardware-configuration.nix")
installer.succeed("rm test-flake/machines/test-install-machine/hardware-configuration.nix") installer.succeed("rm test-flake/machines/test-install-machine-without-system/hardware-configuration.nix")
''; '';
} { inherit pkgs self; }; } { inherit pkgs self; };
}; };