disko/tests/zfs.nix

30 lines
1.1 KiB
Nix
Raw Normal View History

{ pkgs ? (import <nixpkgs> { })
, makeDiskoTest ? (pkgs.callPackage ./lib.nix { }).makeDiskoTest
2022-08-25 13:08:26 +00:00
}:
2022-08-25 21:12:49 +00:00
makeDiskoTest {
2022-08-25 13:08:26 +00:00
disko-config = import ../example/zfs.nix;
extraConfig = {
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
};
2022-08-25 21:12:49 +00:00
extraTestScript = ''
2022-08-25 13:08:26 +00:00
machine.succeed("test -b /dev/zvol/zroot/zfs_testvolume");
2022-08-26 07:07:24 +00:00
def assert_property(ds, property, expected_value):
out = machine.succeed(f"zfs get -H {property} {ds} -o value").rstrip()
assert (
out == expected_value
), f"Expected {property}={expected_value} on {ds}, got: {out}"
assert_property("zroot", "compression", "lz4")
assert_property("zroot/zfs_fs", "compression", "lz4")
assert_property("zroot", "com.sun:auto-snapshot", "false")
assert_property("zroot/zfs_fs", "com.sun:auto-snapshot", "true")
assert_property("zroot/zfs_testvolume", "volsize", "10M")
assert_property("zroot/zfs_unmounted_fs", "mountpoint", "none")
2022-08-26 07:07:24 +00:00
machine.succeed("mountpoint /zfs_fs");
machine.succeed("mountpoint /zfs_legacy_fs");
machine.succeed("mountpoint /ext4onzfs");
2022-08-25 13:08:26 +00:00
'';
}