diff options
author | Orivej Desh <orivej@gmx.fr> | 2017-11-16 20:00:16 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-11-16 20:00:16 +0000 |
commit | f79e3e237fc6bbb479fb2eb30bcaa99a7977bc89 (patch) | |
tree | f5dceb4109e26d6da48e149129ccffd0133ba7ea /nixos | |
parent | 354a6fcfab1cc9f7d4439b19855f467c075aa6d1 (diff) | |
parent | 59e4599723a2c1c598fdf6ad6e0f24ee591c718d (diff) |
Merge pull request #31618 from adisbladis/zfs-tests
Add basic ZFS tests
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/tests/zfs.nix | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/nixos/tests/zfs.nix b/nixos/tests/zfs.nix new file mode 100644 index 0000000000000..a6908024de9bb --- /dev/null +++ b/nixos/tests/zfs.nix @@ -0,0 +1,85 @@ +{ system ? builtins.currentSystem }: + +with import ../lib/testing.nix { inherit system; }; + +let + + makeTest = import ./make-test.nix; + + makeZfsTest = name: + { kernelPackage ? pkgs.linuxPackages_latest + , enableUnstable ? false + , extraTest ? "" + }: + makeTest { + name = "zfs-" + name; + meta = with pkgs.stdenv.lib.maintainers; { + maintainers = [ adisbladis ]; + }; + + machine = { config, lib, pkgs, ... }: + { + virtualisation.emptyDiskImages = [ 4096 ]; + networking.hostId = "deadbeef"; + boot.kernelPackages = kernelPackage; + boot.supportedFilesystems = [ "zfs" ]; + boot.zfs.enableUnstable = enableUnstable; + + environment.systemPackages = with pkgs; [ + parted + ]; + }; + + testScript = '' + $machine->succeed("modprobe zfs"); + $machine->succeed("zpool status"); + + $machine->succeed("ls /dev"); + + $machine->succeed( + "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" + + ); + + '' + extraTest; + + }; + + +in { + + stable = makeZfsTest "stable" { }; + + unstable = makeZfsTest "unstable" { + enableUnstable = true; + extraTest = '' + $machine->succeed( + "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" + ); + ''; + }; + + installer = (import ./installer.nix { }).zfsroot; + +} |