tests: enable swraid, add luks-on-mdadm test

This commit is contained in:
lassulus 2023-08-10 12:47:01 +02:00 committed by mergify[bot]
parent 5a9bfa9fa6
commit 491e567d47
3 changed files with 78 additions and 1 deletions

58
example/luks-on-mdadm.nix Normal file
View File

@ -0,0 +1,58 @@
{ lib, ... }:
{
disko.devices.disk = lib.genAttrs [ "a" "b" ] (name: {
type = "disk";
device = "/dev/sd${name}";
content = {
type = "gpt";
partitions = {
boot = {
size = "1M";
type = "EF02"; # for grub MBR
};
ESP = {
size = "100M";
type = "EF00";
content = {
type = "mdraid";
name = "boot";
};
};
mdadm = {
size = "100%";
content = {
type = "mdraid";
name = "raid1";
};
};
};
};
});
disko.devices.mdadm = {
boot = {
type = "mdadm";
level = 1;
metadata = "1.0";
content = {
type = "filesystem";
format = "vfat";
mountpoint = "/boot";
};
};
raid1 = {
type = "mdadm";
level = 1;
content = {
type = "luks";
name = "crypted";
settings.keyFile = "/tmp/secret.key";
content= {
type = "filesystem";
format = "ext4";
mountpoint = "/";
};
};
};
};
}

View File

@ -167,11 +167,14 @@ let
networking.hostId = "8425e349";
})
];
boot.initrd.services.swraid.enable = true;
systemd.services.mdmonitor.enable = false; # silence some weird warnings
environment.systemPackages = [
pkgs.jq
];
# speed-up eval
documentation.enable = false;

16
tests/luks-on-mdadm.nix Normal file
View File

@ -0,0 +1,16 @@
{ pkgs ? import <nixpkgs> { }
, diskoLib ? pkgs.callPackage ../lib { }
}:
diskoLib.testLib.makeDiskoTest {
inherit pkgs;
name = "luks-on-mdadm";
disko-config = ../example/luks-on-mdadm.nix;
extraTestScript = ''
machine.succeed("test -b /dev/md/raid1");
machine.succeed("mountpoint /");
'';
extraSystemConfig = {
# sadly systemd-boot fails to install to a raid /boot device
boot.loader.systemd-boot.enable = false;
};
}