Merge pull request #156071 from Madouura/dev/bcachefs-installer

nixos/tests/installer: add bcachefs tests
This commit is contained in:
Artturi 2022-05-09 19:48:16 +03:00 committed by GitHub
commit 4ae23f5c7d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 80 additions and 0 deletions

View File

@ -701,6 +701,85 @@ in {
'';
};
bcachefsSimple = makeInstallerTest "bcachefs-simple" {
extraInstallerConfig = {
boot.supportedFilesystems = [ "bcachefs" ];
};
createPartitions = ''
machine.succeed(
"flock /dev/vda parted --script /dev/vda -- mklabel msdos"
+ " mkpart primary ext2 1M 100MB" # /boot
+ " mkpart primary linux-swap 100M 1024M" # swap
+ " mkpart primary 1024M -1s", # /
"udevadm settle",
"mkswap /dev/vda2 -L swap",
"swapon -L swap",
"mkfs.bcachefs -L root /dev/vda3",
"mount -t bcachefs /dev/vda3 /mnt",
"mkfs.ext3 -L boot /dev/vda1",
"mkdir -p /mnt/boot",
"mount /dev/vda1 /mnt/boot",
)
'';
};
bcachefsEncrypted = makeInstallerTest "bcachefs-encrypted" {
extraInstallerConfig = {
boot.supportedFilesystems = [ "bcachefs" ];
environment.systemPackages = with pkgs; [ keyutils ];
};
# We don't want to use the normal way of unlocking bcachefs defined in tasks/filesystems/bcachefs.nix.
# So, override initrd.postDeviceCommands completely and simply unlock with the predefined password.
extraConfig = ''
boot.initrd.postDeviceCommands = lib.mkForce "echo password | bcachefs unlock /dev/vda3";
'';
createPartitions = ''
machine.succeed(
"flock /dev/vda parted --script /dev/vda -- mklabel msdos"
+ " mkpart primary ext2 1M 100MB" # /boot
+ " mkpart primary linux-swap 100M 1024M" # swap
+ " mkpart primary 1024M -1s", # /
"udevadm settle",
"mkswap /dev/vda2 -L swap",
"swapon -L swap",
"keyctl link @u @s",
"echo password | mkfs.bcachefs -L root --encrypted /dev/vda3",
"echo password | bcachefs unlock /dev/vda3",
"mount -t bcachefs /dev/vda3 /mnt",
"mkfs.ext3 -L boot /dev/vda1",
"mkdir -p /mnt/boot",
"mount /dev/vda1 /mnt/boot",
)
'';
};
bcachefsMulti = makeInstallerTest "bcachefs-multi" {
extraInstallerConfig = {
boot.supportedFilesystems = [ "bcachefs" ];
};
createPartitions = ''
machine.succeed(
"flock /dev/vda parted --script /dev/vda -- mklabel msdos"
+ " mkpart primary ext2 1M 100MB" # /boot
+ " mkpart primary linux-swap 100M 1024M" # swap
+ " mkpart primary 1024M 4096M" # /
+ " mkpart primary 4096M -1s", # /
"udevadm settle",
"mkswap /dev/vda2 -L swap",
"swapon -L swap",
"mkfs.bcachefs -L root --metadata_replicas 2 --foreground_target ssd --promote_target ssd --background_target hdd --label ssd /dev/vda3 --label hdd /dev/vda4",
"mount -t bcachefs /dev/vda3:/dev/vda4 /mnt",
"mkfs.ext3 -L boot /dev/vda1",
"mkdir -p /mnt/boot",
"mount /dev/vda1 /mnt/boot",
)
'';
};
# Test a basic install using GRUB 1.
grub1 = makeInstallerTest "grub1" rec {
createPartitions = ''

View File

@ -58,6 +58,7 @@ stdenv.mkDerivation {
passthru.tests = {
smoke-test = nixosTests.bcachefs;
inherit (nixosTests.installer) bcachefsSimple bcachefsEncrypted bcachefsMulti;
};
enableParallelBuilding = true;