nixpkgs/nixos/tests/zfs.nix

76 lines
2.0 KiB
Nix
Raw Normal View History

{ system ? builtins.currentSystem,
config ? {},
pkgs ? import ../.. { inherit system config; }
}:
2017-11-13 21:56:03 +03:00
2020-01-28 10:54:17 +03:00
with import ../lib/testing-python.nix { inherit system pkgs; };
2017-11-13 21:56:03 +03:00
let
makeZfsTest = name:
{ kernelPackage ? pkgs.linuxPackages_latest
, enableUnstable ? false
, extraTest ? ""
}:
makeTest {
name = "zfs-" + name;
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ adisbladis ];
};
2020-01-28 10:54:17 +03:00
machine = { pkgs, ... }: {
virtualisation.emptyDiskImages = [ 4096 ];
networking.hostId = "deadbeef";
boot.kernelPackages = kernelPackage;
boot.supportedFilesystems = [ "zfs" ];
boot.zfs.enableUnstable = enableUnstable;
2017-11-13 21:56:03 +03:00
2020-01-28 10:54:17 +03:00
environment.systemPackages = [ pkgs.parted ];
};
2017-11-13 21:56:03 +03:00
testScript = ''
2019-10-27 15:53:36 +03:00
machine.succeed(
2020-01-28 10:54:17 +03:00
"modprobe zfs",
"zpool status",
"ls /dev",
"mkdir /tmp/mnt",
"udevadm settle",
"parted --script /dev/vdb mklabel msdos",
"parted --script /dev/vdb -- mkpart primary 1024M -1s",
"udevadm settle",
"zpool create rpool /dev/vdb1",
"zfs create -o mountpoint=legacy rpool/root",
"mount -t zfs rpool/root /tmp/mnt",
"udevadm settle",
"umount /tmp/mnt",
"zpool destroy rpool",
"udevadm settle",
2019-10-27 15:53:36 +03:00
)
2017-11-13 21:56:03 +03:00
'' + extraTest;
};
in {
stable = makeZfsTest "stable" { };
unstable = makeZfsTest "unstable" {
enableUnstable = true;
extraTest = ''
2019-10-27 15:53:36 +03:00
machine.succeed(
2020-01-28 10:54:17 +03:00
'echo password | zpool create -o altroot="/tmp/mnt" '
+ "-O encryption=aes-256-gcm -O keyformat=passphrase rpool /dev/vdb1",
"zfs create -o mountpoint=legacy rpool/root",
"mount -t zfs rpool/root /tmp/mnt",
"udevadm settle",
"umount /tmp/mnt",
"zpool destroy rpool",
"udevadm settle",
2019-10-27 15:53:36 +03:00
)
2017-11-13 21:56:03 +03:00
'';
};
installer = (import ./installer.nix { }).zfsroot;
}