mirror of
https://github.com/nix-community/disko.git
synced 2026-12-03 06:23:28 +01:00
test: fix and add stub test for zfs-with-vdevs
This commit is contained in:
4 files changed
+34
-14
No files matched your search
@@ -60,7 +60,7 @@
|
|||||||
};
|
};
|
||||||
cache = {
|
cache = {
|
||||||
type = "disk";
|
type = "disk";
|
||||||
device = "/dev/sdc";
|
device = "/dev/vdc";
|
||||||
content = {
|
content = {
|
||||||
type = "gpt";
|
type = "gpt";
|
||||||
partitions = {
|
partitions = {
|
||||||
@@ -100,15 +100,14 @@
|
|||||||
};
|
};
|
||||||
|
|
||||||
datasets = {
|
datasets = {
|
||||||
# See examples/zfs.nix for more comprehensive usage.
|
# See examples/zfs.nix for more comprehensive usage.
|
||||||
zfs_fs = {
|
zfs_fs = {
|
||||||
type = "zfs_fs";
|
type = "zfs_fs";
|
||||||
mountpoint = "/zfs_fs";
|
mountpoint = "/zfs_fs";
|
||||||
options."com.sun:auto-snapshot" = "true";
|
options."com.sun:auto-snapshot" = "true";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -100,4 +100,3 @@
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
+3
-5
@@ -150,9 +150,9 @@ in
|
|||||||
topology=""
|
topology=""
|
||||||
# For shell check
|
# For shell check
|
||||||
mode="${config.mode}"
|
mode="${config.mode}"
|
||||||
if [ $mode != "prescribed" ]; then
|
if [ "$mode" != "prescribed" ]; then
|
||||||
${if hasTopology then
|
${if !hasTopology then
|
||||||
''topology="${config.mode} \"''${zfs_devices}\""''
|
''topology="${config.mode} ''${zfs_devices[*]}"''
|
||||||
else
|
else
|
||||||
''
|
''
|
||||||
echo "topology cannot be set when mode != 'prescribed', skipping creating zpool ${config.name}" >&2
|
echo "topology cannot be set when mode != 'prescribed', skipping creating zpool ${config.name}" >&2
|
||||||
@@ -174,7 +174,6 @@ in
|
|||||||
devs=''${line#*=}
|
devs=''${line#*=}
|
||||||
IFS=' ' read -r -a devices <<< "$devs"
|
IFS=' ' read -r -a devices <<< "$devs"
|
||||||
all_devices+=("''${devices[@]}")
|
all_devices+=("''${devices[@]}")
|
||||||
# shellcheck disable=SC2089
|
|
||||||
topology+=" ''${mode} ''${devices[*]}"
|
topology+=" ''${mode} ''${devices[*]}"
|
||||||
done
|
done
|
||||||
# all_devices sorted should equal zfs_devices sorted
|
# all_devices sorted should equal zfs_devices sorted
|
||||||
@@ -188,7 +187,6 @@ in
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
if [ $continue -eq 1 ]; then
|
if [ $continue -eq 1 ]; then
|
||||||
# shellcheck disable=SC2090
|
|
||||||
zpool create -f ${config.name} \
|
zpool create -f ${config.name} \
|
||||||
-R ${rootMountPoint} \
|
-R ${rootMountPoint} \
|
||||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
{ pkgs ? import <nixpkgs> { }
|
||||||
|
, diskoLib ? pkgs.callPackage ../lib { }
|
||||||
|
}:
|
||||||
|
diskoLib.testLib.makeDiskoTest {
|
||||||
|
inherit pkgs;
|
||||||
|
name = "zfs-with-vdevs";
|
||||||
|
disko-config = ../example/zfs-with-vdevs.nix;
|
||||||
|
extraInstallerConfig.networking.hostId = "8425e349";
|
||||||
|
extraSystemConfig = {
|
||||||
|
networking.hostId = "8425e349";
|
||||||
|
};
|
||||||
|
extraTestScript = ''
|
||||||
|
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", "zstd")
|
||||||
|
assert_property("zroot/zfs_fs", "com.sun:auto-snapshot", "true")
|
||||||
|
assert_property("zroot/zfs_fs", "compression", "zstd")
|
||||||
|
machine.succeed("mountpoint /zfs_fs");
|
||||||
|
'';
|
||||||
|
}
|
||||||
Reference in new issue
Block a user