mirror of
https://github.com/nix-community/disko
synced 2024-09-20 05:51:54 +00:00
test: fix and add stub test for zfs-with-vdevs
This commit is contained in:
parent
f484389085
commit
8d071db09b
4 changed files with 34 additions and 14 deletions
|
@ -60,7 +60,7 @@
|
|||
};
|
||||
cache = {
|
||||
type = "disk";
|
||||
device = "/dev/sdc";
|
||||
device = "/dev/vdc";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
|
@ -100,15 +100,14 @@
|
|||
};
|
||||
|
||||
datasets = {
|
||||
# See examples/zfs.nix for more comprehensive usage.
|
||||
zfs_fs = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/zfs_fs";
|
||||
options."com.sun:auto-snapshot" = "true";
|
||||
};
|
||||
# See examples/zfs.nix for more comprehensive usage.
|
||||
zfs_fs = {
|
||||
type = "zfs_fs";
|
||||
mountpoint = "/zfs_fs";
|
||||
options."com.sun:auto-snapshot" = "true";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -100,4 +100,3 @@
|
|||
};
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -150,9 +150,9 @@ in
|
|||
topology=""
|
||||
# For shell check
|
||||
mode="${config.mode}"
|
||||
if [ $mode != "prescribed" ]; then
|
||||
${if hasTopology then
|
||||
''topology="${config.mode} \"''${zfs_devices}\""''
|
||||
if [ "$mode" != "prescribed" ]; then
|
||||
${if !hasTopology then
|
||||
''topology="${config.mode} ''${zfs_devices[*]}"''
|
||||
else
|
||||
''
|
||||
echo "topology cannot be set when mode != 'prescribed', skipping creating zpool ${config.name}" >&2
|
||||
|
@ -174,7 +174,6 @@ in
|
|||
devs=''${line#*=}
|
||||
IFS=' ' read -r -a devices <<< "$devs"
|
||||
all_devices+=("''${devices[@]}")
|
||||
# shellcheck disable=SC2089
|
||||
topology+=" ''${mode} ''${devices[*]}"
|
||||
done
|
||||
# all_devices sorted should equal zfs_devices sorted
|
||||
|
@ -188,7 +187,6 @@ in
|
|||
fi
|
||||
fi
|
||||
if [ $continue -eq 1 ]; then
|
||||
# shellcheck disable=SC2090
|
||||
zpool create -f ${config.name} \
|
||||
-R ${rootMountPoint} \
|
||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") config.options)} \
|
||||
|
|
24
tests/zfs-with-vdevs.nix
Normal file
24
tests/zfs-with-vdevs.nix
Normal file
|
@ -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");
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue