mirror of
https://github.com/nix-community/disko.git
synced 2026-12-04 15:03:28 +01:00
tests: modulify in-repo tests; switch tests/default.nix to evalModules discovery
Convert all 40 `tests/*.nix` files that previously called
`diskoLib.testLib.makeDiskoTest { … }` into pure NixOS modules. Each
test now imports its corresponding `../example/foo.nix` and sets
`disko.test = { name = …; extraChecks = …; nodes.machine = …; … };`
inline.
Switch `tests/default.nix` to discover the module-style tests via
nixpkgs's `nixos/lib/eval-config.nix` and read
`config.system.build.diskoTest` off each. The four bespoke tests
(`make-disk-image`, `make-disk-image-impure`, `mdadm-btrfs-wipe`,
`standalone`) keep their function-call shape and are still imported
imperatively; they don't fit the example-eval pattern.
Arg-to-option translations performed in each file:
- `extraSystemConfig` → `disko.test.nodes.machine`
- `extraInstallerConfig` → `disko.test.nodes.formatter`
- `bootCommands`/`efi`/`enableOCR`/`postDisko`/`enableCanokey`
/`name` → `disko.test.<same>`
- `extraTestScript` → `disko.test.extraChecks`
- `testBoot` → `disko.test.boot`
- `testMode` → `disko.test.mode` (`cli` and `module` set this
explicitly; the rest use the default `"module"`)
- `extraInstallerConfig.networking.hostId` /
`extraSystemConfig.networking.hostId` → host-level
`networking.hostId` (propagated to every node by module.nix's
`defaults.networking.hostId` in the evalTest call)
`tests/cli.nix` and `tests/module.nix` both import
`../example/complex.nix` and override `disko.test.{name,mode,extraChecks}`
with `lib.mkForce` — those overrides will keep working after commit 8
folds `tests/complex.nix`'s `disko.test` block into
`example/complex.nix`.
`tests/zfs-encrypted-root.nix`'s legacy `pkgs.lib.recursiveUpdate` on
the imported disko-config becomes a flat
`disko.devices.zpool.zroot.datasets.root.options.keylocation = …;`
override — the module system merges nested attrs automatically.
Lost capability: `nix-build tests/luks.nix` standalone-build no
longer works (modules aren't directly buildable). Replace with
`nix build .#checks.<system>.luks`.
This commit is contained in:
1 parent
6e082c9e74
commit
88275cedd4
42 files changed
+652
-813
No files matched your search
+126
-140
@@ -1,145 +1,131 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/bcachefs.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "bcachefs";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
enableOCR = true;
|
||||||
inherit pkgs;
|
bootCommands = ''
|
||||||
name = "bcachefs";
|
machine.wait_for_text("enter passphrase for /");
|
||||||
disko-config = ../example/bcachefs.nix;
|
machine.send_chars("secretsecret\n");
|
||||||
enableOCR = true;
|
machine.wait_for_text("enter passphrase for /home");
|
||||||
bootCommands = ''
|
machine.send_chars("secretsecret\n");
|
||||||
machine.wait_for_text("enter passphrase for /");
|
machine.wait_for_text("enter passphrase for /nix");
|
||||||
machine.send_chars("secretsecret\n");
|
machine.send_chars("secretsecret\n");
|
||||||
machine.wait_for_text("enter passphrase for /home");
|
'';
|
||||||
machine.send_chars("secretsecret\n");
|
nodes.formatter = {
|
||||||
machine.wait_for_text("enter passphrase for /nix");
|
boot = {
|
||||||
machine.send_chars("secretsecret\n");
|
kernelPackages = pkgs.linuxPackages_latest;
|
||||||
'';
|
supportedFilesystems = [ "bcachefs" ];
|
||||||
extraInstallerConfig = {
|
};
|
||||||
boot = {
|
|
||||||
kernelPackages = pkgs.linuxPackages_latest;
|
|
||||||
supportedFilesystems = [ "bcachefs" ];
|
|
||||||
};
|
};
|
||||||
};
|
nodes.machine = {
|
||||||
extraSystemConfig = {
|
environment.systemPackages = [ pkgs.jq ];
|
||||||
environment.systemPackages = [
|
boot.initrd.extraUtilsCommands = ''
|
||||||
pkgs.jq
|
# Copy tools for bcachefs
|
||||||
];
|
copy_bin_and_libs ${pkgs.lib.getOutput "mount" pkgs.util-linux}/bin/mount
|
||||||
boot.initrd.extraUtilsCommands = ''
|
copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs
|
||||||
# Copy tools for bcachefs
|
copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/mount.bcachefs
|
||||||
copy_bin_and_libs ${pkgs.lib.getOutput "mount" pkgs.util-linux}/bin/mount
|
'';
|
||||||
copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/bcachefs
|
};
|
||||||
copy_bin_and_libs ${pkgs.bcachefs-tools}/bin/mount.bcachefs
|
extraChecks = ''
|
||||||
|
# Print debug information.
|
||||||
|
machine.succeed("uname -a >&2");
|
||||||
|
machine.succeed("ls -la / >&2");
|
||||||
|
machine.succeed("lsblk >&2");
|
||||||
|
machine.succeed("lsblk -f >&2");
|
||||||
|
machine.succeed("mount >&2");
|
||||||
|
# We need to manually unlock /dev/vda2 for some reason
|
||||||
|
# even though it should already get unlocked by bootCommands
|
||||||
|
machine.succeed(r'printf "secretsecret" | bcachefs unlock -k session /dev/vda2 >&2');
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 >&2");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vdd1 >&2");
|
||||||
|
machine.succeed("findmnt --json >&2");
|
||||||
|
|
||||||
|
machine.succeed("mountpoint /");
|
||||||
|
machine.succeed("mountpoint /home");
|
||||||
|
machine.succeed("mountpoint /nix");
|
||||||
|
machine.succeed("mountpoint /home/Documents");
|
||||||
|
machine.fail("mountpoint /non-existent");
|
||||||
|
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Devices:' | grep -q '3'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vdd1 | grep 'Devices:' | grep -q '1'");
|
||||||
|
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdb2'");
|
||||||
|
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdc1'");
|
||||||
|
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_b\.vdd1'");
|
||||||
|
machine.succeed(r"bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vde1'");
|
||||||
|
machine.fail("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'non-existent'");
|
||||||
|
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*compression:[[:space:]]+lz4'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*background_compression:[[:space:]]+lz4'");
|
||||||
|
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*compression:[[:space:]]+none'");
|
||||||
|
|
||||||
|
machine.succeed("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| select(.target == "/") \
|
||||||
|
| .options \
|
||||||
|
| split(",") \
|
||||||
|
| contains(["verbose"]) \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
machine.fail("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| .. \
|
||||||
|
| select(.target? == "/home/Documents") \
|
||||||
|
| .options \
|
||||||
|
| split(",") \
|
||||||
|
| contains(["verbose"]) \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
machine.fail("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| select(.target == "/") \
|
||||||
|
| .options \
|
||||||
|
| split(",") \
|
||||||
|
| contains(["non-existent"]) \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
machine.succeed("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| select(.target == "/") \
|
||||||
|
| .source \
|
||||||
|
| contains("/dev/vda2") \
|
||||||
|
and contains("/dev/vdb1") \
|
||||||
|
and contains("/dev/vdc1") \
|
||||||
|
and contains("[/subvolumes/root]") \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
machine.succeed("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| .. \
|
||||||
|
| select(.target? == "/home/Documents") \
|
||||||
|
| .source \
|
||||||
|
| contains("/dev/vdd1") \
|
||||||
|
'
|
||||||
|
""");
|
||||||
|
|
||||||
|
machine.fail("""
|
||||||
|
findmnt --json \
|
||||||
|
| jq -e ' \
|
||||||
|
.filesystems[] \
|
||||||
|
| select(.target == "/") \
|
||||||
|
| .source \
|
||||||
|
| contains(["/dev/non-existent"]) \
|
||||||
|
'
|
||||||
|
""");
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
extraTestScript = ''
|
|
||||||
# Print debug information.
|
|
||||||
machine.succeed("uname -a >&2");
|
|
||||||
machine.succeed("ls -la / >&2");
|
|
||||||
machine.succeed("lsblk >&2");
|
|
||||||
machine.succeed("lsblk -f >&2");
|
|
||||||
machine.succeed("mount >&2");
|
|
||||||
# We need to manually unlock /dev/vda2 for some reason
|
|
||||||
# even though it should already get unlocked by bootCommands
|
|
||||||
machine.succeed(r'printf "secretsecret" | bcachefs unlock -k session /dev/vda2 >&2');
|
|
||||||
machine.succeed("bcachefs show-super /dev/vda2 >&2");
|
|
||||||
machine.succeed("bcachefs show-super /dev/vdd1 >&2");
|
|
||||||
machine.succeed("findmnt --json >&2");
|
|
||||||
|
|
||||||
# Verify existence of mountpoints.
|
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
machine.succeed("mountpoint /home");
|
|
||||||
machine.succeed("mountpoint /nix");
|
|
||||||
machine.succeed("mountpoint /home/Documents");
|
|
||||||
machine.fail("mountpoint /non-existent");
|
|
||||||
|
|
||||||
# Verify device membership and labels.
|
|
||||||
machine.succeed("bcachefs show-super /dev/vda2 | grep 'Devices:' | grep -q '3'");
|
|
||||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep 'Devices:' | grep -q '1'");
|
|
||||||
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdb2'");
|
|
||||||
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vdc1'");
|
|
||||||
machine.succeed(r"bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_b\.vdd1'");
|
|
||||||
machine.succeed(r"bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*Label:[[:space:]]+group_a\.vde1'");
|
|
||||||
machine.fail("bcachefs show-super /dev/vda2 | grep 'Label:' | grep -q 'non-existent'");
|
|
||||||
|
|
||||||
# Verify format arguments.
|
|
||||||
# Test that lza4 compression and background_compression options were set for vda2.
|
|
||||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*compression:[[:space:]]+lz4'");
|
|
||||||
machine.succeed("bcachefs show-super /dev/vda2 | grep -qE '^[[:space:]]*background_compression:[[:space:]]+lz4'");
|
|
||||||
# Test that no compression option was set for vdd1.
|
|
||||||
machine.succeed("bcachefs show-super /dev/vdd1 | grep -qE '^[[:space:]]*compression:[[:space:]]+none'");
|
|
||||||
|
|
||||||
# Verify mount options from configuration.
|
|
||||||
# Test that verbose option was set for "/".
|
|
||||||
machine.succeed("""
|
|
||||||
findmnt --json \
|
|
||||||
| jq -e ' \
|
|
||||||
.filesystems[] \
|
|
||||||
| select(.target == "/") \
|
|
||||||
| .options \
|
|
||||||
| split(",") \
|
|
||||||
| contains(["verbose"]) \
|
|
||||||
'
|
|
||||||
""");
|
|
||||||
|
|
||||||
# Test that verbose option was not set for "/home/Documents".
|
|
||||||
machine.fail("""
|
|
||||||
findmnt --json \
|
|
||||||
| jq -e ' \
|
|
||||||
.filesystems[] \
|
|
||||||
| .. \
|
|
||||||
| select(.target? == "/home/Documents") \
|
|
||||||
| .options \
|
|
||||||
| split(",") \
|
|
||||||
| contains(["verbose"]) \
|
|
||||||
'
|
|
||||||
""");
|
|
||||||
|
|
||||||
# Test that non-existent option was not set for "/".
|
|
||||||
machine.fail("""
|
|
||||||
findmnt --json \
|
|
||||||
| jq -e ' \
|
|
||||||
.filesystems[] \
|
|
||||||
| select(.target == "/") \
|
|
||||||
| .options \
|
|
||||||
| split(",") \
|
|
||||||
| contains(["non-existent"]) \
|
|
||||||
'
|
|
||||||
""");
|
|
||||||
|
|
||||||
# Verify device composition of filesystems.
|
|
||||||
machine.succeed("""
|
|
||||||
findmnt --json \
|
|
||||||
| jq -e ' \
|
|
||||||
.filesystems[] \
|
|
||||||
| select(.target == "/") \
|
|
||||||
| .source \
|
|
||||||
| contains("/dev/vda2") \
|
|
||||||
and contains("/dev/vdb1") \
|
|
||||||
and contains("/dev/vdc1") \
|
|
||||||
and contains("[/subvolumes/root]") \
|
|
||||||
'
|
|
||||||
""");
|
|
||||||
|
|
||||||
machine.succeed("""
|
|
||||||
findmnt --json \
|
|
||||||
| jq -e ' \
|
|
||||||
.filesystems[] \
|
|
||||||
| .. \
|
|
||||||
| select(.target? == "/home/Documents") \
|
|
||||||
| .source \
|
|
||||||
| contains("/dev/vdd1") \
|
|
||||||
'
|
|
||||||
""");
|
|
||||||
|
|
||||||
machine.fail("""
|
|
||||||
findmnt --json \
|
|
||||||
| jq -e ' \
|
|
||||||
.filesystems[] \
|
|
||||||
| select(.target == "/") \
|
|
||||||
| .source \
|
|
||||||
| contains(["/dev/non-existent"]) \
|
|
||||||
'
|
|
||||||
""");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+8
-13
@@ -1,17 +1,12 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/boot-raid1.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "boot-raid1";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("test -b /dev/md/boot");
|
||||||
name = "boot-raid1";
|
machine.succeed("mountpoint /boot");
|
||||||
disko-config = ../example/boot-raid1.nix;
|
'';
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("test -b /dev/md/boot");
|
|
||||||
machine.succeed("mountpoint /boot");
|
|
||||||
'';
|
|
||||||
extraSystemConfig = {
|
|
||||||
# sadly systemd-boot fails to install to a raid /boot device
|
# sadly systemd-boot fails to install to a raid /boot device
|
||||||
boot.loader.systemd-boot.enable = false;
|
nodes.machine.boot.loader.systemd-boot.enable = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/btrfs-only-root-subvolume.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "btrfs-only-root-subvolume";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("btrfs subvolume list /");
|
||||||
name = "btrfs-only-root-subvolume";
|
'';
|
||||||
disko-config = ../example/btrfs-only-root-subvolume.nix;
|
};
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("btrfs subvolume list /");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+15
-18
@@ -1,20 +1,17 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/btrfs-subvolumes.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "btrfs-subvolumes";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("test ! -e /test");
|
||||||
name = "btrfs-subvolumes";
|
machine.succeed("test -e /home/user");
|
||||||
disko-config = ../example/btrfs-subvolumes.nix;
|
machine.succeed("btrfs subvolume list / | grep -qs 'path test$'");
|
||||||
extraTestScript = ''
|
machine.succeed("btrfs subvolume list / | grep -qs 'path nix$'");
|
||||||
machine.succeed("test ! -e /test");
|
machine.succeed("btrfs subvolume list / | grep -qs 'path home$'");
|
||||||
machine.succeed("test -e /home/user");
|
machine.succeed("test -e /.swapvol/swapfile");
|
||||||
machine.succeed("btrfs subvolume list / | grep -qs 'path test$'");
|
machine.succeed("test -e /.swapvol/rel-path");
|
||||||
machine.succeed("btrfs subvolume list / | grep -qs 'path nix$'");
|
machine.succeed("test -e /partition-root/swapfile");
|
||||||
machine.succeed("btrfs subvolume list / | grep -qs 'path home$'");
|
machine.succeed("test -e /partition-root/swapfile1");
|
||||||
machine.succeed("test -e /.swapvol/swapfile");
|
'';
|
||||||
machine.succeed("test -e /.swapvol/rel-path");
|
};
|
||||||
machine.succeed("test -e /partition-root/swapfile");
|
|
||||||
machine.succeed("test -e /partition-root/swapfile1");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+18
-32
@@ -1,38 +1,24 @@
|
|||||||
|
{ lib, ... }:
|
||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/complex.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = lib.mkForce "cli";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
mode = "direct";
|
||||||
inherit pkgs;
|
extraChecks = lib.mkForce ''
|
||||||
name = "cli";
|
machine.succeed("test -b /dev/md/raid1p1");
|
||||||
disko-config = ../example/complex.nix;
|
machine.succeed("mountpoint /zfs_fs");
|
||||||
extraInstallerConfig.networking.hostId = "8425e349";
|
machine.succeed("mountpoint /zfs_legacy_fs");
|
||||||
extraSystemConfig = {
|
machine.succeed("mountpoint /ext4onzfs");
|
||||||
networking.hostId = "8425e349";
|
machine.succeed("mountpoint /ext4_on_lvm");
|
||||||
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
'';
|
||||||
fileSystems."/zfs_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
nodes.machine.fileSystems = {
|
||||||
};
|
"/zfs_legacy_fs".options = [ "nofail" ];
|
||||||
testMode = "direct";
|
"/zfs_fs".options = [ "nofail" ];
|
||||||
extraTestScript = ''
|
};
|
||||||
machine.succeed("test -b /dev/md/raid1p1");
|
nodes.formatter.boot.kernelModules = [
|
||||||
|
|
||||||
machine.succeed("mountpoint /zfs_fs");
|
|
||||||
machine.succeed("mountpoint /zfs_legacy_fs");
|
|
||||||
machine.succeed("mountpoint /ext4onzfs");
|
|
||||||
machine.succeed("mountpoint /ext4_on_lvm");
|
|
||||||
'';
|
|
||||||
extraSystemConfig = {
|
|
||||||
imports = [
|
|
||||||
../module.nix
|
|
||||||
];
|
|
||||||
};
|
|
||||||
extraInstallerConfig = {
|
|
||||||
boot.kernelModules = [
|
|
||||||
"dm-raid"
|
"dm-raid"
|
||||||
"dm-mirror"
|
"dm-mirror"
|
||||||
];
|
];
|
||||||
imports = [
|
|
||||||
../module.nix
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
networking.hostId = "8425e349";
|
||||||
}
|
}
|
||||||
+18
-24
@@ -1,33 +1,27 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/complex.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "complex";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("test -b /dev/md/raid1p1");
|
||||||
name = "complex";
|
machine.succeed("test -b /dev/disk/by-partuuid/f0f0f0f0-f0f0-f0f0-f0f0-f0f0f0f0f0f0")
|
||||||
disko-config = ../example/complex.nix;
|
|
||||||
extraInstallerConfig.networking.hostId = "8425e349";
|
|
||||||
extraSystemConfig = {
|
|
||||||
networking.hostId = "8425e349";
|
|
||||||
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
|
||||||
fileSystems."/zfs_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
|
||||||
};
|
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("test -b /dev/md/raid1p1");
|
|
||||||
machine.succeed("test -b /dev/disk/by-partuuid/f0f0f0f0-f0f0-f0f0-f0f0-f0f0f0f0f0f0")
|
|
||||||
|
|
||||||
machine.succeed("mountpoint /zfs_fs");
|
machine.succeed("mountpoint /zfs_fs");
|
||||||
machine.succeed("mountpoint /zfs_legacy_fs");
|
machine.succeed("mountpoint /zfs_legacy_fs");
|
||||||
machine.succeed("mountpoint /ext4onzfs");
|
machine.succeed("mountpoint /ext4onzfs");
|
||||||
machine.succeed("mountpoint /ext4_on_lvm");
|
machine.succeed("mountpoint /ext4_on_lvm");
|
||||||
|
|
||||||
|
|
||||||
machine.succeed("test -e /ext4_on_lvm/file-from-postMountHook");
|
machine.succeed("test -e /ext4_on_lvm/file-from-postMountHook");
|
||||||
'';
|
'';
|
||||||
extraInstallerConfig = {
|
nodes.machine = {
|
||||||
boot.kernelModules = [
|
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
||||||
|
fileSystems."/zfs_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
||||||
|
};
|
||||||
|
nodes.formatter.boot.kernelModules = [
|
||||||
"dm-raid"
|
"dm-raid"
|
||||||
"dm-mirror"
|
"dm-mirror"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
networking.hostId = "8425e349";
|
||||||
}
|
}
|
||||||
+36
-22
@@ -1,36 +1,50 @@
|
|||||||
{
|
{
|
||||||
makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>,
|
|
||||||
eval-config ? import <nixpkgs/nixos/lib/eval-config.nix>,
|
|
||||||
qemu-common ? import <nixpkgs/nixos/lib/qemu-common.nix>,
|
|
||||||
pkgs ? import <nixpkgs> { },
|
pkgs ? import <nixpkgs> { },
|
||||||
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
lib = pkgs.lib;
|
inherit (pkgs) lib;
|
||||||
diskoLib = import ../lib {
|
|
||||||
inherit
|
|
||||||
lib
|
|
||||||
makeTest
|
|
||||||
eval-config
|
|
||||||
qemu-common
|
|
||||||
;
|
|
||||||
};
|
|
||||||
|
|
||||||
allTestFilenames = builtins.map (lib.removeSuffix ".nix") (
|
bespoke = [
|
||||||
builtins.filter (x: lib.hasSuffix ".nix" x && x != "default.nix") (
|
"make-disk-image"
|
||||||
lib.attrNames (builtins.readDir ./.)
|
"make-disk-image-impure"
|
||||||
)
|
"mdadm-btrfs-wipe"
|
||||||
);
|
"standalone"
|
||||||
incompatibleTests = lib.optionals pkgs.stdenv.buildPlatform.isRiscV64 [
|
];
|
||||||
|
incompatible = lib.optionals pkgs.stdenv.buildPlatform.isRiscV64 [
|
||||||
"zfs"
|
"zfs"
|
||||||
"zfs-over-legacy"
|
"zfs-over-legacy"
|
||||||
"cli"
|
"cli"
|
||||||
"module"
|
"module"
|
||||||
"complex"
|
"complex"
|
||||||
];
|
];
|
||||||
allCompatibleFilenames = lib.subtractLists incompatibleTests allTestFilenames;
|
|
||||||
|
|
||||||
allTests = lib.genAttrs allCompatibleFilenames (
|
listNix =
|
||||||
test: import (./. + "/${test}.nix") { inherit diskoLib pkgs; }
|
dir:
|
||||||
|
map (lib.removeSuffix ".nix") (
|
||||||
|
lib.attrNames (
|
||||||
|
lib.filterAttrs (n: _: lib.hasSuffix ".nix" n && n != "default.nix") (builtins.readDir dir)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
evalModule =
|
||||||
|
file:
|
||||||
|
import (pkgs.path + "/nixos/lib/eval-config.nix") {
|
||||||
|
system = pkgs.stdenv.hostPlatform.system;
|
||||||
|
modules = [
|
||||||
|
../module.nix
|
||||||
|
file
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
testsDirModule = lib.genAttrs (lib.subtractLists bespoke (listNix ./.)) (
|
||||||
|
name: evalModule (./. + "/${name}.nix")
|
||||||
);
|
);
|
||||||
|
|
||||||
|
moduleTests = lib.mapAttrs (_: eval: eval.config.system.build.diskoTest) (
|
||||||
|
lib.removeAttrs testsDirModule incompatible
|
||||||
|
);
|
||||||
|
|
||||||
|
bespokeTests = lib.genAttrs bespoke (name: import (./. + "/${name}.nix") { inherit pkgs; });
|
||||||
in
|
in
|
||||||
allTests
|
moduleTests // bespokeTests
|
||||||
+9
-14
@@ -1,17 +1,12 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/f2fs.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "f2fs";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "f2fs";
|
machine.succeed("lsblk --fs >&2");
|
||||||
disko-config = ../example/f2fs.nix;
|
'';
|
||||||
extraTestScript = ''
|
# so that the installer boots with a f2fs enabled kernel
|
||||||
machine.succeed("mountpoint /");
|
nodes.formatter.boot.supportedFilesystems = [ "f2fs" ];
|
||||||
machine.succeed("lsblk --fs >&2");
|
|
||||||
'';
|
|
||||||
# so that the installer boots with a f2fs enabled kernel
|
|
||||||
extraInstallerConfig = {
|
|
||||||
boot.supportedFilesystems = [ "f2fs" ];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,10 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/gpt-bios-compat.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "gpt-bios-compat";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
efi = false;
|
||||||
inherit pkgs;
|
extraChecks = ''
|
||||||
name = "gpt-bios-compat";
|
machine.succeed("mountpoint /");
|
||||||
disko-config = ../example/gpt-bios-compat.nix;
|
'';
|
||||||
extraTestScript = ''
|
};
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
efi = false;
|
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/gpt-name-with-whitespace.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "gpt-name-with-whitespace";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "gpt-name-with-whitespace";
|
machine.succeed("mountpoint '/name with spaces'");
|
||||||
disko-config = ../example/gpt-name-with-whitespace.nix;
|
machine.succeed("mountpoint '/name^with\\some@special#chars'");
|
||||||
extraTestScript = ''
|
'';
|
||||||
machine.succeed("mountpoint /");
|
};
|
||||||
machine.succeed("mountpoint '/name with spaces'");
|
|
||||||
machine.succeed("mountpoint '/name^with\\some@special#chars'");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/gpt-unformatted.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "gpt-unformatted";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "gpt-unformatted";
|
'';
|
||||||
disko-config = ../example/gpt-unformatted.nix;
|
};
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+7
-10
@@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/hybrid-mbr.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "hybrid-mbr";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "hybrid-mbr";
|
'';
|
||||||
disko-config = ../example/hybrid-mbr.nix;
|
};
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,10 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/hybrid-tmpfs-on-root.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "hybrid-tmpfs-on-root";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "hybrid-tmpfs-on-root";
|
machine.succeed("findmnt / --types tmpfs");
|
||||||
disko-config = ../example/hybrid-tmpfs-on-root.nix;
|
'';
|
||||||
extraTestScript = ''
|
};
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
machine.succeed("findmnt / --types tmpfs");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+7
-10
@@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/hybrid.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "hybrid";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "hybrid";
|
'';
|
||||||
disko-config = ../example/hybrid.nix;
|
};
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
@@ -1,13 +1,10 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/legacy-table-with-whitespace.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "legacy-table-with-whitespace";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "legacy-table-with-whitespace";
|
machine.succeed("mountpoint /name_with_spaces");
|
||||||
disko-config = ../example/legacy-table-with-whitespace.nix;
|
'';
|
||||||
extraTestScript = ''
|
};
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
machine.succeed("mountpoint /name_with_spaces");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+7
-10
@@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/legacy-table.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "legacy-table";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "legacy-table";
|
'';
|
||||||
disko-config = ../example/legacy-table.nix;
|
};
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/long-device-name.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "long-device-name";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "long-device-name";
|
'';
|
||||||
disko-config = ../example/long-device-name.nix;
|
};
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/luks-btrfs-raid.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "luks-btrfs-raid";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||||
name = "luks-btrfs-raid";
|
machine.succeed("cryptsetup isLuks /dev/vdb1");
|
||||||
disko-config = ../example/luks-btrfs-raid.nix;
|
machine.succeed("btrfs subvolume list /");
|
||||||
extraTestScript = ''
|
'';
|
||||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
};
|
||||||
machine.succeed("cryptsetup isLuks /dev/vdb1");
|
|
||||||
machine.succeed("btrfs subvolume list /");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/luks-btrfs-subvolumes.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "luks-btrfs-subvolumes";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||||
name = "luks-btrfs-subvolumes";
|
machine.succeed("btrfs subvolume list / | grep -qs 'path nix$'");
|
||||||
disko-config = ../example/luks-btrfs-subvolumes.nix;
|
machine.succeed("btrfs subvolume list / | grep -qs 'path home$'");
|
||||||
extraTestScript = ''
|
machine.succeed("test -e /.swapvol/swapfile");
|
||||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
'';
|
||||||
machine.succeed("btrfs subvolume list / | grep -qs 'path nix$'");
|
};
|
||||||
machine.succeed("btrfs subvolume list / | grep -qs 'path home$'");
|
|
||||||
machine.succeed("test -e /.swapvol/swapfile");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+9
-12
@@ -1,14 +1,11 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/luks-fido2.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "luks-fido2";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
enableCanokey = true;
|
||||||
inherit pkgs;
|
extraChecks = ''
|
||||||
name = "luks-fido2";
|
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||||
disko-config = ../example/luks-fido2.nix;
|
machine.succeed("mountpoint /");
|
||||||
enableCanokey = true;
|
'';
|
||||||
extraTestScript = ''
|
};
|
||||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
@@ -1,17 +1,14 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/luks-interactive-login.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "luks-interactive-login";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
enableOCR = true;
|
||||||
inherit pkgs;
|
bootCommands = ''
|
||||||
name = "luks-interactive-login";
|
machine.wait_for_text("[Pp]assphrase for")
|
||||||
disko-config = ../example/luks-interactive-login.nix;
|
machine.send_chars("secretsecret\n")
|
||||||
enableOCR = true;
|
'';
|
||||||
extraTestScript = ''
|
extraChecks = ''
|
||||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||||
'';
|
'';
|
||||||
bootCommands = ''
|
};
|
||||||
machine.wait_for_text("[Pp]assphrase for")
|
|
||||||
machine.send_chars("secretsecret\n")
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+8
-11
@@ -1,13 +1,10 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/luks-lvm.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "luks-lvm";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||||
name = "luks-lvm";
|
machine.succeed("mountpoint /home");
|
||||||
disko-config = ../example/luks-lvm.nix;
|
'';
|
||||||
extraTestScript = ''
|
};
|
||||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
|
||||||
machine.succeed("mountpoint /home");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+8
-14
@@ -1,17 +1,11 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/luks-on-mdadm.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "luks-on-mdadm";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("test -b /dev/md/raid1");
|
||||||
name = "luks-on-mdadm";
|
machine.succeed("mountpoint /");
|
||||||
disko-config = ../example/luks-on-mdadm.nix;
|
'';
|
||||||
extraTestScript = ''
|
nodes.machine.boot.loader.systemd-boot.enable = false;
|
||||||
machine.succeed("test -b /dev/md/raid1");
|
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
extraSystemConfig = {
|
|
||||||
# sadly systemd-boot fails to install to a raid /boot device
|
|
||||||
boot.loader.systemd-boot.enable = false;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
+8
-15
@@ -1,23 +1,16 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/lvm-raid.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "lvm-raid";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /home");
|
||||||
name = "lvm-raid";
|
'';
|
||||||
disko-config = ../example/lvm-raid.nix;
|
nodes.formatter.boot.kernelModules = [
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /home");
|
|
||||||
'';
|
|
||||||
extraInstallerConfig = {
|
|
||||||
boot.kernelModules = [
|
|
||||||
"dm-raid"
|
"dm-raid"
|
||||||
"raid0"
|
"raid0"
|
||||||
"dm-mirror"
|
"dm-mirror"
|
||||||
];
|
];
|
||||||
};
|
|
||||||
extraSystemConfig = {
|
|
||||||
# sadly systemd-boot fails to install to a raid /boot device
|
# sadly systemd-boot fails to install to a raid /boot device
|
||||||
boot.loader.systemd-boot.enable = false;
|
nodes.machine.boot.loader.systemd-boot.enable = false;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/lvm-sizes-sort.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "lvm-sizes-sort";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /home");
|
||||||
name = "lvm-sizes-sort";
|
'';
|
||||||
disko-config = ../example/lvm-sizes-sort.nix;
|
};
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /home");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+7
-10
@@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/lvm-thin.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "lvm-thin";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /home");
|
||||||
name = "lvm-thin";
|
'';
|
||||||
disko-config = ../example/lvm-thin.nix;
|
};
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /home");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+9
-12
@@ -1,14 +1,11 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/mdadm-raid0.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "mdadm-raid0";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
efi = false;
|
||||||
inherit pkgs;
|
extraChecks = ''
|
||||||
name = "mdadm-raid0";
|
machine.succeed("test -b /dev/md/raid0");
|
||||||
disko-config = ../example/mdadm-raid0.nix;
|
machine.succeed("mountpoint /");
|
||||||
extraTestScript = ''
|
'';
|
||||||
machine.succeed("test -b /dev/md/raid0");
|
};
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
efi = false;
|
|
||||||
}
|
}
|
||||||
@@ -1,14 +1,11 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/mdadm-raid5-args.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "mdadm-raid5-args";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
efi = false;
|
||||||
inherit pkgs;
|
extraChecks = ''
|
||||||
name = "mdadm-raid5-args";
|
machine.succeed("test -b /dev/md/raid5");
|
||||||
disko-config = ../example/mdadm-raid5-args.nix;
|
machine.succeed("mountpoint /");
|
||||||
extraTestScript = ''
|
'';
|
||||||
machine.succeed("test -b /dev/md/raid5");
|
};
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
efi = false;
|
|
||||||
}
|
}
|
||||||
+9
-12
@@ -1,14 +1,11 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/mdadm.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "mdadm";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
efi = false;
|
||||||
inherit pkgs;
|
extraChecks = ''
|
||||||
name = "mdadm";
|
machine.succeed("test -b /dev/md/raid1");
|
||||||
disko-config = ../example/mdadm.nix;
|
machine.succeed("mountpoint /");
|
||||||
extraTestScript = ''
|
'';
|
||||||
machine.succeed("test -b /dev/md/raid1");
|
};
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
efi = false;
|
|
||||||
}
|
}
|
||||||
+15
-24
@@ -1,30 +1,21 @@
|
|||||||
|
{ lib, ... }:
|
||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/complex.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = lib.mkForce "module";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
mode = "module";
|
||||||
inherit pkgs;
|
extraChecks = lib.mkForce ''
|
||||||
name = "module";
|
machine.succeed("test -b /dev/md/raid1p1");
|
||||||
disko-config = ../example/complex.nix;
|
machine.succeed("mountpoint /zfs_fs");
|
||||||
extraInstallerConfig.networking.hostId = "8425e349";
|
machine.succeed("mountpoint /zfs_legacy_fs");
|
||||||
extraSystemConfig = {
|
machine.succeed("mountpoint /ext4onzfs");
|
||||||
networking.hostId = "8425e349";
|
machine.succeed("mountpoint /ext4_on_lvm");
|
||||||
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
'';
|
||||||
};
|
nodes.machine.fileSystems."/zfs_legacy_fs".options = [ "nofail" ];
|
||||||
testMode = "module";
|
nodes.formatter.boot.kernelModules = [
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("test -b /dev/md/raid1p1");
|
|
||||||
|
|
||||||
|
|
||||||
machine.succeed("mountpoint /zfs_fs");
|
|
||||||
machine.succeed("mountpoint /zfs_legacy_fs");
|
|
||||||
machine.succeed("mountpoint /ext4onzfs");
|
|
||||||
machine.succeed("mountpoint /ext4_on_lvm");
|
|
||||||
'';
|
|
||||||
extraInstallerConfig = {
|
|
||||||
boot.kernelModules = [
|
|
||||||
"dm-raid"
|
"dm-raid"
|
||||||
"dm-mirror"
|
"dm-mirror"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
networking.hostId = "8425e349";
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,12 @@
|
|||||||
# this is a regression test for https://github.com/nix-community/disko/issues/52
|
# this is a regression test for https://github.com/nix-community/disko/issues/52
|
||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/multi-device-no-deps.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "multi-device-no-deps";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
boot = false;
|
||||||
inherit pkgs;
|
extraChecks = ''
|
||||||
name = "multi-device-no-deps";
|
machine.succeed("mountpoint /mnt/a");
|
||||||
disko-config = ../example/multi-device-no-deps.nix;
|
machine.succeed("mountpoint /mnt/b");
|
||||||
testBoot = false;
|
'';
|
||||||
extraTestScript = ''
|
};
|
||||||
machine.succeed("mountpoint /mnt/a");
|
|
||||||
machine.succeed("mountpoint /mnt/b");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+8
-11
@@ -1,14 +1,11 @@
|
|||||||
# this is a regression test for https://github.com/nix-community/disko/issues/52
|
# this is a regression test for https://github.com/nix-community/disko/issues/52
|
||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/negative-size.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "negative-size";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
boot = false;
|
||||||
inherit pkgs;
|
extraChecks = ''
|
||||||
name = "negative-size";
|
machine.succeed("mountpoint /mnt");
|
||||||
disko-config = ../example/negative-size.nix;
|
'';
|
||||||
testBoot = false;
|
};
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /mnt");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+35
-39
@@ -1,49 +1,45 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/non-root-zfs.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "non-root-zfs";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
postDisko = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /mnt/storage")
|
||||||
name = "non-root-zfs";
|
machine.succeed("mountpoint /mnt/storage/dataset")
|
||||||
disko-config = ../example/non-root-zfs.nix;
|
|
||||||
extraInstallerConfig.networking.hostId = "8425e349";
|
|
||||||
extraSystemConfig.networking.hostId = "8425e349";
|
|
||||||
postDisko = ''
|
|
||||||
machine.succeed("mountpoint /mnt/storage")
|
|
||||||
machine.succeed("mountpoint /mnt/storage/dataset")
|
|
||||||
|
|
||||||
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage")[1].rstrip()
|
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage")[1].rstrip()
|
||||||
print(f"/mnt/storage {filesystem=}")
|
print(f"/mnt/storage {filesystem=}")
|
||||||
assert filesystem == "zfs", "/mnt/storage is not ZFS"
|
assert filesystem == "zfs", "/mnt/storage is not ZFS"
|
||||||
|
|
||||||
machine.fail("mountpoint /mnt/storage2")
|
machine.fail("mountpoint /mnt/storage2")
|
||||||
machine.succeed("mountpoint /mnt/storage2/dataset")
|
machine.succeed("mountpoint /mnt/storage2/dataset")
|
||||||
|
|
||||||
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage2")[1].rstrip()
|
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage2")[1].rstrip()
|
||||||
print(f"/mnt/storage2 {filesystem=}")
|
print(f"/mnt/storage2 {filesystem=}")
|
||||||
assert filesystem != "zfs", "/mnt/storage should not be ZFS"
|
assert filesystem != "zfs", "/mnt/storage should not be ZFS"
|
||||||
|
|
||||||
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage2/dataset")[1].rstrip()
|
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage2/dataset")[1].rstrip()
|
||||||
print(f"/mnt/storage2/dataset {filesystem=}")
|
print(f"/mnt/storage2/dataset {filesystem=}")
|
||||||
assert filesystem == "zfs", "/mnt/storage/dataset is not ZFS"
|
assert filesystem == "zfs", "/mnt/storage/dataset is not ZFS"
|
||||||
'';
|
'';
|
||||||
extraTestScript = ''
|
extraChecks = ''
|
||||||
machine.succeed("mountpoint /storage")
|
machine.succeed("mountpoint /storage")
|
||||||
machine.succeed("mountpoint /storage/dataset")
|
machine.succeed("mountpoint /storage/dataset")
|
||||||
|
|
||||||
filesystem = machine.execute("stat --file-system --format=%T /storage")[1].rstrip()
|
filesystem = machine.execute("stat --file-system --format=%T /storage")[1].rstrip()
|
||||||
print(f"/storage {filesystem=}")
|
print(f"/storage {filesystem=}")
|
||||||
assert filesystem == "zfs", "/storage is not ZFS"
|
assert filesystem == "zfs", "/storage is not ZFS"
|
||||||
|
|
||||||
machine.fail("mountpoint /storage2")
|
machine.fail("mountpoint /storage2")
|
||||||
machine.succeed("mountpoint /storage2/dataset")
|
machine.succeed("mountpoint /storage2/dataset")
|
||||||
|
|
||||||
filesystem = machine.execute("stat --file-system --format=%T /storage2")[1].rstrip()
|
filesystem = machine.execute("stat --file-system --format=%T /storage2")[1].rstrip()
|
||||||
print(f"/storage2 {filesystem=}")
|
print(f"/storage2 {filesystem=}")
|
||||||
assert filesystem != "zfs", "/storage should not be ZFS"
|
assert filesystem != "zfs", "/storage should not be ZFS"
|
||||||
|
|
||||||
filesystem = machine.execute("stat --file-system --format=%T /storage2/dataset")[1].rstrip()
|
filesystem = machine.execute("stat --file-system --format=%T /storage2/dataset")[1].rstrip()
|
||||||
print(f"/storage2/dataset {filesystem=}")
|
print(f"/storage2/dataset {filesystem=}")
|
||||||
assert filesystem == "zfs", "/storage/dataset is not ZFS"
|
assert filesystem == "zfs", "/storage/dataset is not ZFS"
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
|
networking.hostId = "8425e349";
|
||||||
}
|
}
|
||||||
+7
-10
@@ -1,12 +1,9 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/simple-efi.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "simple-efi";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "simple-efi";
|
'';
|
||||||
disko-config = ../example/simple-efi.nix;
|
};
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+23
-27
@@ -1,32 +1,28 @@
|
|||||||
|
{ pkgs, ... }:
|
||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/swap.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "swap";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
import json
|
||||||
name = "swap";
|
machine.succeed("mountpoint /");
|
||||||
disko-config = ../example/swap.nix;
|
machine.succeed("swapon --show >&2");
|
||||||
extraTestScript = ''
|
machine.succeed("lsblk -o +PARTTYPENAME --json /dev/vda >&2");
|
||||||
import json
|
out = json.loads(machine.succeed("lsblk -o +PARTTYPENAME --json /dev/vda"))
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
machine.succeed("swapon --show >&2");
|
|
||||||
machine.succeed("lsblk -o +PARTTYPENAME --json /dev/vda >&2");
|
|
||||||
out = json.loads(machine.succeed("lsblk -o +PARTTYPENAME --json /dev/vda"))
|
|
||||||
|
|
||||||
encrypted_swap_crypt = out["blockdevices"][0]["children"][1]
|
encrypted_swap_crypt = out["blockdevices"][0]["children"][1]
|
||||||
mnt_point = encrypted_swap_crypt["children"][0]["mountpoints"][0]
|
mnt_point = encrypted_swap_crypt["children"][0]["mountpoints"][0]
|
||||||
assert mnt_point == "[SWAP]", f"Expected encrypted swap partition to be mounted as [SWAP], got {mnt_point}"
|
assert mnt_point == "[SWAP]", f"Expected encrypted swap partition to be mounted as [SWAP], got {mnt_point}"
|
||||||
part_type = encrypted_swap_crypt["parttypename"]
|
part_type = encrypted_swap_crypt["parttypename"]
|
||||||
# The dm-crypt partition should be labelled as swap, not dm-crypt, see https://github.com/util-linux/util-linux/issues/3238
|
# The dm-crypt partition should be labelled as swap, not dm-crypt, see https://github.com/util-linux/util-linux/issues/3238
|
||||||
assert part_type == "Linux swap", f"Expected encrypted swap container to be of type Linux swap, got {part_type}"
|
assert part_type == "Linux swap", f"Expected encrypted swap container to be of type Linux swap, got {part_type}"
|
||||||
|
|
||||||
plain_swap_part = out["blockdevices"][0]["children"][3]
|
plain_swap_part = out["blockdevices"][0]["children"][3]
|
||||||
mnt_point = plain_swap_part["mountpoints"][0]
|
mnt_point = plain_swap_part["mountpoints"][0]
|
||||||
assert mnt_point == "[SWAP]", f"Expected swap partition to be mounted as [SWAP], got {mnt_point}"
|
assert mnt_point == "[SWAP]", f"Expected swap partition to be mounted as [SWAP], got {mnt_point}"
|
||||||
part_type = plain_swap_part["parttypename"]
|
part_type = plain_swap_part["parttypename"]
|
||||||
assert part_type == "Linux swap", f"Expected plain swap partition to be of type Linux swap, got {part_type}"
|
assert part_type == "Linux swap", f"Expected plain swap partition to be of type Linux swap, got {part_type}"
|
||||||
'';
|
'';
|
||||||
extraSystemConfig = {
|
nodes.machine.environment.systemPackages = [ pkgs.jq ];
|
||||||
environment.systemPackages = [ pkgs.jq ];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
+8
-11
@@ -1,13 +1,10 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/tmpfs.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "tmpfs";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "tmpfs";
|
machine.succeed("mountpoint /tmp");
|
||||||
disko-config = ../example/tmpfs.nix;
|
'';
|
||||||
extraTestScript = ''
|
};
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
machine.succeed("mountpoint /tmp");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+9
-11
@@ -1,13 +1,11 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/with-lib.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
_module.args.disks = [ "/dev/vdb" ];
|
||||||
}:
|
disko.test = {
|
||||||
diskoLib.testLib.makeDiskoTest {
|
name = "with-lib";
|
||||||
inherit pkgs;
|
efi = false;
|
||||||
name = "with-lib";
|
extraChecks = ''
|
||||||
disko-config = ../example/with-lib.nix;
|
machine.succeed("mountpoint /");
|
||||||
extraTestScript = ''
|
'';
|
||||||
machine.succeed("mountpoint /");
|
};
|
||||||
'';
|
|
||||||
efi = false;
|
|
||||||
}
|
}
|
||||||
+8
-11
@@ -1,14 +1,11 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/xfs-with-quota.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "xfs";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("mountpoint /");
|
||||||
name = "xfs";
|
|
||||||
disko-config = ../example/xfs-with-quota.nix;
|
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
|
|
||||||
machine.succeed("xfs_quota -c 'print' / | grep -q '(pquota)'")
|
machine.succeed("xfs_quota -c 'print' / | grep -q '(pquota)'")
|
||||||
'';
|
'';
|
||||||
|
};
|
||||||
}
|
}
|
||||||
@@ -1,18 +1,15 @@
|
|||||||
|
{ lib, ... }:
|
||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/zfs-encrypted-root.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "zfs-encrypted-root";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
defaults.disko.devices.zpool.zroot.datasets.root.options.keylocation =
|
||||||
inherit pkgs;
|
lib.mkForce "file:///tmp/secret.key";
|
||||||
name = "zfs-encrypted-root";
|
extraChecks = ''
|
||||||
extraInstallerConfig.networking.hostId = "8425e349";
|
machine.succeed("mountpoint /");
|
||||||
extraSystemConfig.networking.hostId = "8425e349";
|
machine.succeed("mountpoint /nix");
|
||||||
disko-config = pkgs.lib.recursiveUpdate (import ../example/zfs-encrypted-root.nix) {
|
machine.succeed("swapon --show=NAME | grep /dev/zd"); # i.e. /dev/zd0
|
||||||
disko.devices.zpool.zroot.datasets.root.options.keylocation = "file:///tmp/secret.key";
|
'';
|
||||||
};
|
};
|
||||||
extraTestScript = ''
|
networking.hostId = "8425e349";
|
||||||
machine.succeed("mountpoint /");
|
|
||||||
machine.succeed("mountpoint /nix");
|
|
||||||
machine.succeed("swapon --show=NAME | grep /dev/zd"); # i.e. /dev/zd0
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
@@ -1,15 +1,11 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/zfs-over-legacy.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "zfs-over-legacy";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
extraChecks = ''
|
||||||
inherit pkgs;
|
machine.succeed("test -e /zfs_fs");
|
||||||
name = "zfs-over-legacy";
|
machine.succeed("mountpoint /zfs_fs");
|
||||||
extraInstallerConfig.networking.hostId = "8425e349";
|
'';
|
||||||
extraSystemConfig.networking.hostId = "8425e349";
|
};
|
||||||
disko-config = ../example/zfs-over-legacy.nix;
|
networking.hostId = "8425e349";
|
||||||
extraTestScript = ''
|
|
||||||
machine.succeed("test -e /zfs_fs");
|
|
||||||
machine.succeed("mountpoint /zfs_fs");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+66
-74
@@ -1,78 +1,70 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/zfs-with-vdevs.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "zfs-with-vdevs";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
nodes.machine = {
|
||||||
inherit pkgs;
|
# It looks like the 60s of NixOS is sometimes not enough for our virtio-based zpool.
|
||||||
name = "zfs-with-vdevs";
|
# This fixes the flakeiness of the test.
|
||||||
disko-config = ../example/zfs-with-vdevs.nix;
|
boot.initrd.postResumeCommands = ''
|
||||||
extraInstallerConfig.networking.hostId = "8425e349";
|
for i in $(seq 1 120); do
|
||||||
extraSystemConfig = {
|
if zpool list | grep -q zroot || zpool import -N zroot; then
|
||||||
networking.hostId = "8425e349";
|
break
|
||||||
# It looks like the 60s of NixOS is sometimes not enough for our virtio-based zpool.
|
fi
|
||||||
# This fixes the flakeiness of the test.
|
done
|
||||||
boot.initrd.postResumeCommands = ''
|
'';
|
||||||
for i in $(seq 1 120); do
|
};
|
||||||
if zpool list | grep -q zroot || zpool import -N zroot; then
|
extraChecks = ''
|
||||||
break
|
def assert_property(ds, property, expected_value):
|
||||||
fi
|
out = machine.succeed(f"zfs get -H {property} {ds} -o value").rstrip()
|
||||||
done
|
assert (
|
||||||
|
out == expected_value
|
||||||
|
), f"Expected {property}={expected_value} on {ds}, got: {out}"
|
||||||
|
|
||||||
|
# These fields are 0 if l2arc is disabled
|
||||||
|
assert (
|
||||||
|
machine.succeed(
|
||||||
|
"cat /proc/spl/kstat/zfs/arcstats"
|
||||||
|
" | grep '^l2_' | tr -s ' '"
|
||||||
|
" | cut -s -d ' ' -f3 | uniq"
|
||||||
|
).strip() != "0"
|
||||||
|
), "Excepted cache to be utilized."
|
||||||
|
|
||||||
|
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");
|
||||||
|
|
||||||
|
group = ""
|
||||||
|
vdev = ""
|
||||||
|
actual = []
|
||||||
|
for line in machine.succeed("zpool status -P zroot").split("\n"):
|
||||||
|
first_word = line.strip().split(" ", 1)[0]
|
||||||
|
if line.startswith("\t ") and first_word.startswith("/"):
|
||||||
|
actual.append(f"{group}{vdev}{first_word}")
|
||||||
|
elif line.startswith("\t "):
|
||||||
|
vdev = f"{first_word.split('-', 1)[0]} "
|
||||||
|
elif line.startswith("\t"):
|
||||||
|
group = f"{first_word} "
|
||||||
|
vdev = ""
|
||||||
|
actual.sort()
|
||||||
|
expected=sorted([
|
||||||
|
'zroot /dev/disk/by-partlabel/disk-data1-zfs',
|
||||||
|
'zroot mirror /dev/disk/by-partlabel/disk-data2-zfs',
|
||||||
|
'zroot mirror /dev/disk/by-partlabel/disk-data3-zfs',
|
||||||
|
'dedup /dev/disk/by-partlabel/disk-dedup3-zfs',
|
||||||
|
'dedup mirror /dev/disk/by-partlabel/disk-dedup1-zfs',
|
||||||
|
'dedup mirror /dev/disk/by-partlabel/disk-dedup2-zfs',
|
||||||
|
'special /dev/disk/by-partlabel/disk-special3-zfs',
|
||||||
|
'special mirror /dev/disk/by-partlabel/disk-special1-zfs',
|
||||||
|
'special mirror /dev/disk/by-partlabel/disk-special2-zfs',
|
||||||
|
'logs /dev/disk/by-partlabel/disk-log3-zfs',
|
||||||
|
'logs mirror /dev/disk/by-partlabel/disk-log1-zfs',
|
||||||
|
'logs mirror /dev/disk/by-partlabel/disk-log2-zfs',
|
||||||
|
'cache /dev/disk/by-partlabel/disk-cache-zfs',
|
||||||
|
'spares /dev/disk/by-partlabel/disk-spare-zfs',
|
||||||
|
])
|
||||||
|
assert actual == expected, f"Incorrect pool layout. Expected:\n\t{'\n\t'.join(expected)}\nActual:\n\t{'\n\t'.join(actual)}"
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
extraTestScript = ''
|
networking.hostId = "8425e349";
|
||||||
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}"
|
|
||||||
|
|
||||||
# These fields are 0 if l2arc is disabled
|
|
||||||
assert (
|
|
||||||
machine.succeed(
|
|
||||||
"cat /proc/spl/kstat/zfs/arcstats"
|
|
||||||
" | grep '^l2_' | tr -s ' '"
|
|
||||||
" | cut -s -d ' ' -f3 | uniq"
|
|
||||||
).strip() != "0"
|
|
||||||
), "Excepted cache to be utilized."
|
|
||||||
|
|
||||||
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");
|
|
||||||
|
|
||||||
# Take the status output and flatten it so that each device is on a single line prefixed with with the group (either
|
|
||||||
# the pool name or a designation like log/cache/spare/dedup/special) and first portion of the vdev name (empty for a
|
|
||||||
# disk from a single vdev, mirror for devices in a mirror. This makes it easy to verify that the layout is as
|
|
||||||
# expected.
|
|
||||||
group = ""
|
|
||||||
vdev = ""
|
|
||||||
actual = []
|
|
||||||
for line in machine.succeed("zpool status -P zroot").split("\n"):
|
|
||||||
first_word = line.strip().split(" ", 1)[0]
|
|
||||||
if line.startswith("\t ") and first_word.startswith("/"):
|
|
||||||
actual.append(f"{group}{vdev}{first_word}")
|
|
||||||
elif line.startswith("\t "):
|
|
||||||
vdev = f"{first_word.split('-', 1)[0]} "
|
|
||||||
elif line.startswith("\t"):
|
|
||||||
group = f"{first_word} "
|
|
||||||
vdev = ""
|
|
||||||
actual.sort()
|
|
||||||
expected=sorted([
|
|
||||||
'zroot /dev/disk/by-partlabel/disk-data1-zfs',
|
|
||||||
'zroot mirror /dev/disk/by-partlabel/disk-data2-zfs',
|
|
||||||
'zroot mirror /dev/disk/by-partlabel/disk-data3-zfs',
|
|
||||||
'dedup /dev/disk/by-partlabel/disk-dedup3-zfs',
|
|
||||||
'dedup mirror /dev/disk/by-partlabel/disk-dedup1-zfs',
|
|
||||||
'dedup mirror /dev/disk/by-partlabel/disk-dedup2-zfs',
|
|
||||||
'special /dev/disk/by-partlabel/disk-special3-zfs',
|
|
||||||
'special mirror /dev/disk/by-partlabel/disk-special1-zfs',
|
|
||||||
'special mirror /dev/disk/by-partlabel/disk-special2-zfs',
|
|
||||||
'logs /dev/disk/by-partlabel/disk-log3-zfs',
|
|
||||||
'logs mirror /dev/disk/by-partlabel/disk-log1-zfs',
|
|
||||||
'logs mirror /dev/disk/by-partlabel/disk-log2-zfs',
|
|
||||||
'cache /dev/disk/by-partlabel/disk-cache-zfs',
|
|
||||||
'spares /dev/disk/by-partlabel/disk-spare-zfs',
|
|
||||||
])
|
|
||||||
assert actual == expected, f"Incorrect pool layout. Expected:\n\t{'\n\t'.join(expected)}\nActual:\n\t{'\n\t'.join(actual)}"
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
+33
-39
@@ -1,42 +1,36 @@
|
|||||||
{
|
{
|
||||||
pkgs ? import <nixpkgs> { },
|
imports = [ ../example/zfs.nix ];
|
||||||
diskoLib ? pkgs.callPackage ../lib { },
|
disko.test = {
|
||||||
}:
|
name = "zfs";
|
||||||
diskoLib.testLib.makeDiskoTest {
|
nodes.machine.fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
||||||
inherit pkgs;
|
extraChecks = ''
|
||||||
name = "zfs";
|
machine.succeed("test -b /dev/zvol/zroot/zfs_volume");
|
||||||
disko-config = ../example/zfs.nix;
|
machine.succeed("test -b /dev/zvol/zroot/zfs_encryptedvolume");
|
||||||
extraInstallerConfig.networking.hostId = "8425e349";
|
|
||||||
extraSystemConfig = {
|
def assert_property(ds, property, expected_value):
|
||||||
networking.hostId = "8425e349";
|
out = machine.succeed(f"zfs get -H {property} {ds} -o value").rstrip()
|
||||||
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
assert (
|
||||||
|
out == expected_value
|
||||||
|
), f"Expected {property}={expected_value} on {ds}, got: {out}"
|
||||||
|
|
||||||
|
assert_property("zroot", "compression", "zstd")
|
||||||
|
assert_property("zroot/zfs_fs", "compression", "zstd")
|
||||||
|
assert_property("zroot", "com.sun:auto-snapshot", "false")
|
||||||
|
assert_property("zroot/zfs_fs", "com.sun:auto-snapshot", "true")
|
||||||
|
assert_property("zroot/zfs_volume", "volsize", "10M")
|
||||||
|
assert_property("zroot/zfs_encryptedvolume", "volsize", "10M")
|
||||||
|
assert_property("zroot/zfs_unmounted_fs", "mountpoint", "none")
|
||||||
|
|
||||||
|
machine.succeed("zfs get name zroot@blank")
|
||||||
|
|
||||||
|
machine.succeed("mountpoint /zfs_fs");
|
||||||
|
machine.succeed("mountpoint /zfs_legacy_fs");
|
||||||
|
machine.succeed("mountpoint /ext4onzfs");
|
||||||
|
machine.succeed("mountpoint /ext4onzfsencrypted");
|
||||||
|
machine.succeed("mountpoint /zfs_crypted");
|
||||||
|
machine.succeed("zfs get keystatus zroot/encrypted");
|
||||||
|
machine.succeed("zfs get keystatus zroot/encrypted/test");
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
extraTestScript = ''
|
networking.hostId = "8425e349";
|
||||||
machine.succeed("test -b /dev/zvol/zroot/zfs_volume");
|
|
||||||
machine.succeed("test -b /dev/zvol/zroot/zfs_encryptedvolume");
|
|
||||||
|
|
||||||
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", "compression", "zstd")
|
|
||||||
assert_property("zroot", "com.sun:auto-snapshot", "false")
|
|
||||||
assert_property("zroot/zfs_fs", "com.sun:auto-snapshot", "true")
|
|
||||||
assert_property("zroot/zfs_volume", "volsize", "10M")
|
|
||||||
assert_property("zroot/zfs_encryptedvolume", "volsize", "10M")
|
|
||||||
assert_property("zroot/zfs_unmounted_fs", "mountpoint", "none")
|
|
||||||
|
|
||||||
machine.succeed("zfs get name zroot@blank")
|
|
||||||
|
|
||||||
machine.succeed("mountpoint /zfs_fs");
|
|
||||||
machine.succeed("mountpoint /zfs_legacy_fs");
|
|
||||||
machine.succeed("mountpoint /ext4onzfs");
|
|
||||||
machine.succeed("mountpoint /ext4onzfsencrypted");
|
|
||||||
machine.succeed("mountpoint /zfs_crypted");
|
|
||||||
machine.succeed("zfs get keystatus zroot/encrypted");
|
|
||||||
machine.succeed("zfs get keystatus zroot/encrypted/test");
|
|
||||||
'';
|
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user