mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13: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> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "bcachefs";
|
||||
disko-config = ../example/bcachefs.nix;
|
||||
enableOCR = true;
|
||||
bootCommands = ''
|
||||
machine.wait_for_text("enter passphrase for /");
|
||||
machine.send_chars("secretsecret\n");
|
||||
machine.wait_for_text("enter passphrase for /home");
|
||||
machine.send_chars("secretsecret\n");
|
||||
machine.wait_for_text("enter passphrase for /nix");
|
||||
machine.send_chars("secretsecret\n");
|
||||
'';
|
||||
extraInstallerConfig = {
|
||||
boot = {
|
||||
kernelPackages = pkgs.linuxPackages_latest;
|
||||
supportedFilesystems = [ "bcachefs" ];
|
||||
imports = [ ../example/bcachefs.nix ];
|
||||
disko.test = {
|
||||
name = "bcachefs";
|
||||
enableOCR = true;
|
||||
bootCommands = ''
|
||||
machine.wait_for_text("enter passphrase for /");
|
||||
machine.send_chars("secretsecret\n");
|
||||
machine.wait_for_text("enter passphrase for /home");
|
||||
machine.send_chars("secretsecret\n");
|
||||
machine.wait_for_text("enter passphrase for /nix");
|
||||
machine.send_chars("secretsecret\n");
|
||||
'';
|
||||
nodes.formatter = {
|
||||
boot = {
|
||||
kernelPackages = pkgs.linuxPackages_latest;
|
||||
supportedFilesystems = [ "bcachefs" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
extraSystemConfig = {
|
||||
environment.systemPackages = [
|
||||
pkgs.jq
|
||||
];
|
||||
boot.initrd.extraUtilsCommands = ''
|
||||
# Copy tools for 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
|
||||
nodes.machine = {
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
boot.initrd.extraUtilsCommands = ''
|
||||
# Copy tools for 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> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "boot-raid1";
|
||||
disko-config = ../example/boot-raid1.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("test -b /dev/md/boot");
|
||||
machine.succeed("mountpoint /boot");
|
||||
'';
|
||||
extraSystemConfig = {
|
||||
imports = [ ../example/boot-raid1.nix ];
|
||||
disko.test = {
|
||||
name = "boot-raid1";
|
||||
extraChecks = ''
|
||||
machine.succeed("test -b /dev/md/boot");
|
||||
machine.succeed("mountpoint /boot");
|
||||
'';
|
||||
# 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> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "btrfs-only-root-subvolume";
|
||||
disko-config = ../example/btrfs-only-root-subvolume.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("btrfs subvolume list /");
|
||||
'';
|
||||
imports = [ ../example/btrfs-only-root-subvolume.nix ];
|
||||
disko.test = {
|
||||
name = "btrfs-only-root-subvolume";
|
||||
extraChecks = ''
|
||||
machine.succeed("btrfs subvolume list /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+15
-18
@@ -1,20 +1,17 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "btrfs-subvolumes";
|
||||
disko-config = ../example/btrfs-subvolumes.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("test ! -e /test");
|
||||
machine.succeed("test -e /home/user");
|
||||
machine.succeed("btrfs subvolume list / | grep -qs 'path test$'");
|
||||
machine.succeed("btrfs subvolume list / | grep -qs 'path nix$'");
|
||||
machine.succeed("btrfs subvolume list / | grep -qs 'path home$'");
|
||||
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");
|
||||
'';
|
||||
imports = [ ../example/btrfs-subvolumes.nix ];
|
||||
disko.test = {
|
||||
name = "btrfs-subvolumes";
|
||||
extraChecks = ''
|
||||
machine.succeed("test ! -e /test");
|
||||
machine.succeed("test -e /home/user");
|
||||
machine.succeed("btrfs subvolume list / | grep -qs 'path test$'");
|
||||
machine.succeed("btrfs subvolume list / | grep -qs 'path nix$'");
|
||||
machine.succeed("btrfs subvolume list / | grep -qs 'path home$'");
|
||||
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> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "cli";
|
||||
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!
|
||||
};
|
||||
testMode = "direct";
|
||||
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");
|
||||
'';
|
||||
extraSystemConfig = {
|
||||
imports = [
|
||||
../module.nix
|
||||
];
|
||||
};
|
||||
extraInstallerConfig = {
|
||||
boot.kernelModules = [
|
||||
imports = [ ../example/complex.nix ];
|
||||
disko.test = {
|
||||
name = lib.mkForce "cli";
|
||||
mode = "direct";
|
||||
extraChecks = lib.mkForce ''
|
||||
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");
|
||||
'';
|
||||
nodes.machine.fileSystems = {
|
||||
"/zfs_legacy_fs".options = [ "nofail" ];
|
||||
"/zfs_fs".options = [ "nofail" ];
|
||||
};
|
||||
nodes.formatter.boot.kernelModules = [
|
||||
"dm-raid"
|
||||
"dm-mirror"
|
||||
];
|
||||
imports = [
|
||||
../module.nix
|
||||
];
|
||||
};
|
||||
networking.hostId = "8425e349";
|
||||
}
|
||||
+18
-24
@@ -1,33 +1,27 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "complex";
|
||||
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")
|
||||
imports = [ ../example/complex.nix ];
|
||||
disko.test = {
|
||||
name = "complex";
|
||||
extraChecks = ''
|
||||
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_legacy_fs");
|
||||
machine.succeed("mountpoint /ext4onzfs");
|
||||
machine.succeed("mountpoint /ext4_on_lvm");
|
||||
machine.succeed("mountpoint /zfs_fs");
|
||||
machine.succeed("mountpoint /zfs_legacy_fs");
|
||||
machine.succeed("mountpoint /ext4onzfs");
|
||||
machine.succeed("mountpoint /ext4_on_lvm");
|
||||
|
||||
|
||||
machine.succeed("test -e /ext4_on_lvm/file-from-postMountHook");
|
||||
'';
|
||||
extraInstallerConfig = {
|
||||
boot.kernelModules = [
|
||||
machine.succeed("test -e /ext4_on_lvm/file-from-postMountHook");
|
||||
'';
|
||||
nodes.machine = {
|
||||
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-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> { },
|
||||
...
|
||||
}:
|
||||
let
|
||||
lib = pkgs.lib;
|
||||
diskoLib = import ../lib {
|
||||
inherit
|
||||
lib
|
||||
makeTest
|
||||
eval-config
|
||||
qemu-common
|
||||
;
|
||||
};
|
||||
inherit (pkgs) lib;
|
||||
|
||||
allTestFilenames = builtins.map (lib.removeSuffix ".nix") (
|
||||
builtins.filter (x: lib.hasSuffix ".nix" x && x != "default.nix") (
|
||||
lib.attrNames (builtins.readDir ./.)
|
||||
)
|
||||
);
|
||||
incompatibleTests = lib.optionals pkgs.stdenv.buildPlatform.isRiscV64 [
|
||||
bespoke = [
|
||||
"make-disk-image"
|
||||
"make-disk-image-impure"
|
||||
"mdadm-btrfs-wipe"
|
||||
"standalone"
|
||||
];
|
||||
incompatible = lib.optionals pkgs.stdenv.buildPlatform.isRiscV64 [
|
||||
"zfs"
|
||||
"zfs-over-legacy"
|
||||
"cli"
|
||||
"module"
|
||||
"complex"
|
||||
];
|
||||
allCompatibleFilenames = lib.subtractLists incompatibleTests allTestFilenames;
|
||||
|
||||
allTests = lib.genAttrs allCompatibleFilenames (
|
||||
test: import (./. + "/${test}.nix") { inherit diskoLib pkgs; }
|
||||
listNix =
|
||||
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
|
||||
allTests
|
||||
moduleTests // bespokeTests
|
||||
+9
-14
@@ -1,17 +1,12 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "f2fs";
|
||||
disko-config = ../example/f2fs.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("lsblk --fs >&2");
|
||||
'';
|
||||
# so that the installer boots with a f2fs enabled kernel
|
||||
extraInstallerConfig = {
|
||||
boot.supportedFilesystems = [ "f2fs" ];
|
||||
imports = [ ../example/f2fs.nix ];
|
||||
disko.test = {
|
||||
name = "f2fs";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("lsblk --fs >&2");
|
||||
'';
|
||||
# so that the installer boots with a f2fs enabled kernel
|
||||
nodes.formatter.boot.supportedFilesystems = [ "f2fs" ];
|
||||
};
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "gpt-bios-compat";
|
||||
disko-config = ../example/gpt-bios-compat.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
efi = false;
|
||||
imports = [ ../example/gpt-bios-compat.nix ];
|
||||
disko.test = {
|
||||
name = "gpt-bios-compat";
|
||||
efi = false;
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "gpt-name-with-whitespace";
|
||||
disko-config = ../example/gpt-name-with-whitespace.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint '/name with spaces'");
|
||||
machine.succeed("mountpoint '/name^with\\some@special#chars'");
|
||||
'';
|
||||
imports = [ ../example/gpt-name-with-whitespace.nix ];
|
||||
disko.test = {
|
||||
name = "gpt-name-with-whitespace";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint '/name with spaces'");
|
||||
machine.succeed("mountpoint '/name^with\\some@special#chars'");
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "gpt-unformatted";
|
||||
disko-config = ../example/gpt-unformatted.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
imports = [ ../example/gpt-unformatted.nix ];
|
||||
disko.test = {
|
||||
name = "gpt-unformatted";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+7
-10
@@ -1,12 +1,9 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "hybrid-mbr";
|
||||
disko-config = ../example/hybrid-mbr.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
imports = [ ../example/hybrid-mbr.nix ];
|
||||
disko.test = {
|
||||
name = "hybrid-mbr";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "hybrid-tmpfs-on-root";
|
||||
disko-config = ../example/hybrid-tmpfs-on-root.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("findmnt / --types tmpfs");
|
||||
'';
|
||||
imports = [ ../example/hybrid-tmpfs-on-root.nix ];
|
||||
disko.test = {
|
||||
name = "hybrid-tmpfs-on-root";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("findmnt / --types tmpfs");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+7
-10
@@ -1,12 +1,9 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "hybrid";
|
||||
disko-config = ../example/hybrid.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
imports = [ ../example/hybrid.nix ];
|
||||
disko.test = {
|
||||
name = "hybrid";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "legacy-table-with-whitespace";
|
||||
disko-config = ../example/legacy-table-with-whitespace.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint /name_with_spaces");
|
||||
'';
|
||||
imports = [ ../example/legacy-table-with-whitespace.nix ];
|
||||
disko.test = {
|
||||
name = "legacy-table-with-whitespace";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint /name_with_spaces");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+7
-10
@@ -1,12 +1,9 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "legacy-table";
|
||||
disko-config = ../example/legacy-table.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
imports = [ ../example/legacy-table.nix ];
|
||||
disko.test = {
|
||||
name = "legacy-table";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,12 +1,9 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "long-device-name";
|
||||
disko-config = ../example/long-device-name.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
imports = [ ../example/long-device-name.nix ];
|
||||
disko.test = {
|
||||
name = "long-device-name";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "luks-btrfs-raid";
|
||||
disko-config = ../example/luks-btrfs-raid.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||
machine.succeed("cryptsetup isLuks /dev/vdb1");
|
||||
machine.succeed("btrfs subvolume list /");
|
||||
'';
|
||||
imports = [ ../example/luks-btrfs-raid.nix ];
|
||||
disko.test = {
|
||||
name = "luks-btrfs-raid";
|
||||
extraChecks = ''
|
||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||
machine.succeed("cryptsetup isLuks /dev/vdb1");
|
||||
machine.succeed("btrfs subvolume list /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "luks-btrfs-subvolumes";
|
||||
disko-config = ../example/luks-btrfs-subvolumes.nix;
|
||||
extraTestScript = ''
|
||||
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");
|
||||
'';
|
||||
imports = [ ../example/luks-btrfs-subvolumes.nix ];
|
||||
disko.test = {
|
||||
name = "luks-btrfs-subvolumes";
|
||||
extraChecks = ''
|
||||
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> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "luks-fido2";
|
||||
disko-config = ../example/luks-fido2.nix;
|
||||
enableCanokey = true;
|
||||
extraTestScript = ''
|
||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
imports = [ ../example/luks-fido2.nix ];
|
||||
disko.test = {
|
||||
name = "luks-fido2";
|
||||
enableCanokey = true;
|
||||
extraChecks = ''
|
||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,17 +1,14 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "luks-interactive-login";
|
||||
disko-config = ../example/luks-interactive-login.nix;
|
||||
enableOCR = true;
|
||||
extraTestScript = ''
|
||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||
'';
|
||||
bootCommands = ''
|
||||
machine.wait_for_text("[Pp]assphrase for")
|
||||
machine.send_chars("secretsecret\n")
|
||||
'';
|
||||
imports = [ ../example/luks-interactive-login.nix ];
|
||||
disko.test = {
|
||||
name = "luks-interactive-login";
|
||||
enableOCR = true;
|
||||
bootCommands = ''
|
||||
machine.wait_for_text("[Pp]assphrase for")
|
||||
machine.send_chars("secretsecret\n")
|
||||
'';
|
||||
extraChecks = ''
|
||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+8
-11
@@ -1,13 +1,10 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "luks-lvm";
|
||||
disko-config = ../example/luks-lvm.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
imports = [ ../example/luks-lvm.nix ];
|
||||
disko.test = {
|
||||
name = "luks-lvm";
|
||||
extraChecks = ''
|
||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+8
-14
@@ -1,17 +1,11 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "luks-on-mdadm";
|
||||
disko-config = ../example/luks-on-mdadm.nix;
|
||||
extraTestScript = ''
|
||||
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;
|
||||
imports = [ ../example/luks-on-mdadm.nix ];
|
||||
disko.test = {
|
||||
name = "luks-on-mdadm";
|
||||
extraChecks = ''
|
||||
machine.succeed("test -b /dev/md/raid1");
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
nodes.machine.boot.loader.systemd-boot.enable = false;
|
||||
};
|
||||
}
|
||||
+8
-15
@@ -1,23 +1,16 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "lvm-raid";
|
||||
disko-config = ../example/lvm-raid.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
extraInstallerConfig = {
|
||||
boot.kernelModules = [
|
||||
imports = [ ../example/lvm-raid.nix ];
|
||||
disko.test = {
|
||||
name = "lvm-raid";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
nodes.formatter.boot.kernelModules = [
|
||||
"dm-raid"
|
||||
"raid0"
|
||||
"dm-mirror"
|
||||
];
|
||||
};
|
||||
extraSystemConfig = {
|
||||
# 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> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "lvm-sizes-sort";
|
||||
disko-config = ../example/lvm-sizes-sort.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
imports = [ ../example/lvm-sizes-sort.nix ];
|
||||
disko.test = {
|
||||
name = "lvm-sizes-sort";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+7
-10
@@ -1,12 +1,9 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "lvm-thin";
|
||||
disko-config = ../example/lvm-thin.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
imports = [ ../example/lvm-thin.nix ];
|
||||
disko.test = {
|
||||
name = "lvm-thin";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+9
-12
@@ -1,14 +1,11 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "mdadm-raid0";
|
||||
disko-config = ../example/mdadm-raid0.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("test -b /dev/md/raid0");
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
efi = false;
|
||||
imports = [ ../example/mdadm-raid0.nix ];
|
||||
disko.test = {
|
||||
name = "mdadm-raid0";
|
||||
efi = false;
|
||||
extraChecks = ''
|
||||
machine.succeed("test -b /dev/md/raid0");
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "mdadm-raid5-args";
|
||||
disko-config = ../example/mdadm-raid5-args.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("test -b /dev/md/raid5");
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
efi = false;
|
||||
imports = [ ../example/mdadm-raid5-args.nix ];
|
||||
disko.test = {
|
||||
name = "mdadm-raid5-args";
|
||||
efi = false;
|
||||
extraChecks = ''
|
||||
machine.succeed("test -b /dev/md/raid5");
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+9
-12
@@ -1,14 +1,11 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "mdadm";
|
||||
disko-config = ../example/mdadm.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("test -b /dev/md/raid1");
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
efi = false;
|
||||
imports = [ ../example/mdadm.nix ];
|
||||
disko.test = {
|
||||
name = "mdadm";
|
||||
efi = false;
|
||||
extraChecks = ''
|
||||
machine.succeed("test -b /dev/md/raid1");
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+15
-24
@@ -1,30 +1,21 @@
|
||||
{ lib, ... }:
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "module";
|
||||
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!
|
||||
};
|
||||
testMode = "module";
|
||||
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 = [
|
||||
imports = [ ../example/complex.nix ];
|
||||
disko.test = {
|
||||
name = lib.mkForce "module";
|
||||
mode = "module";
|
||||
extraChecks = lib.mkForce ''
|
||||
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");
|
||||
'';
|
||||
nodes.machine.fileSystems."/zfs_legacy_fs".options = [ "nofail" ];
|
||||
nodes.formatter.boot.kernelModules = [
|
||||
"dm-raid"
|
||||
"dm-mirror"
|
||||
];
|
||||
};
|
||||
networking.hostId = "8425e349";
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
# this is a regression test for https://github.com/nix-community/disko/issues/52
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "multi-device-no-deps";
|
||||
disko-config = ../example/multi-device-no-deps.nix;
|
||||
testBoot = false;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /mnt/a");
|
||||
machine.succeed("mountpoint /mnt/b");
|
||||
'';
|
||||
imports = [ ../example/multi-device-no-deps.nix ];
|
||||
disko.test = {
|
||||
name = "multi-device-no-deps";
|
||||
boot = false;
|
||||
extraChecks = ''
|
||||
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
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "negative-size";
|
||||
disko-config = ../example/negative-size.nix;
|
||||
testBoot = false;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /mnt");
|
||||
'';
|
||||
imports = [ ../example/negative-size.nix ];
|
||||
disko.test = {
|
||||
name = "negative-size";
|
||||
boot = false;
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /mnt");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+35
-39
@@ -1,49 +1,45 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "non-root-zfs";
|
||||
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")
|
||||
imports = [ ../example/non-root-zfs.nix ];
|
||||
disko.test = {
|
||||
name = "non-root-zfs";
|
||||
postDisko = ''
|
||||
machine.succeed("mountpoint /mnt/storage")
|
||||
machine.succeed("mountpoint /mnt/storage/dataset")
|
||||
|
||||
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage")[1].rstrip()
|
||||
print(f"/mnt/storage {filesystem=}")
|
||||
assert filesystem == "zfs", "/mnt/storage is not ZFS"
|
||||
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage")[1].rstrip()
|
||||
print(f"/mnt/storage {filesystem=}")
|
||||
assert filesystem == "zfs", "/mnt/storage is not ZFS"
|
||||
|
||||
machine.fail("mountpoint /mnt/storage2")
|
||||
machine.succeed("mountpoint /mnt/storage2/dataset")
|
||||
machine.fail("mountpoint /mnt/storage2")
|
||||
machine.succeed("mountpoint /mnt/storage2/dataset")
|
||||
|
||||
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage2")[1].rstrip()
|
||||
print(f"/mnt/storage2 {filesystem=}")
|
||||
assert filesystem != "zfs", "/mnt/storage should not be ZFS"
|
||||
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage2")[1].rstrip()
|
||||
print(f"/mnt/storage2 {filesystem=}")
|
||||
assert filesystem != "zfs", "/mnt/storage should not be ZFS"
|
||||
|
||||
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage2/dataset")[1].rstrip()
|
||||
print(f"/mnt/storage2/dataset {filesystem=}")
|
||||
assert filesystem == "zfs", "/mnt/storage/dataset is not ZFS"
|
||||
'';
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /storage")
|
||||
machine.succeed("mountpoint /storage/dataset")
|
||||
filesystem = machine.execute("stat --file-system --format=%T /mnt/storage2/dataset")[1].rstrip()
|
||||
print(f"/mnt/storage2/dataset {filesystem=}")
|
||||
assert filesystem == "zfs", "/mnt/storage/dataset is not ZFS"
|
||||
'';
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /storage")
|
||||
machine.succeed("mountpoint /storage/dataset")
|
||||
|
||||
filesystem = machine.execute("stat --file-system --format=%T /storage")[1].rstrip()
|
||||
print(f"/storage {filesystem=}")
|
||||
assert filesystem == "zfs", "/storage is not ZFS"
|
||||
filesystem = machine.execute("stat --file-system --format=%T /storage")[1].rstrip()
|
||||
print(f"/storage {filesystem=}")
|
||||
assert filesystem == "zfs", "/storage is not ZFS"
|
||||
|
||||
machine.fail("mountpoint /storage2")
|
||||
machine.succeed("mountpoint /storage2/dataset")
|
||||
machine.fail("mountpoint /storage2")
|
||||
machine.succeed("mountpoint /storage2/dataset")
|
||||
|
||||
filesystem = machine.execute("stat --file-system --format=%T /storage2")[1].rstrip()
|
||||
print(f"/storage2 {filesystem=}")
|
||||
assert filesystem != "zfs", "/storage should not be ZFS"
|
||||
filesystem = machine.execute("stat --file-system --format=%T /storage2")[1].rstrip()
|
||||
print(f"/storage2 {filesystem=}")
|
||||
assert filesystem != "zfs", "/storage should not be ZFS"
|
||||
|
||||
filesystem = machine.execute("stat --file-system --format=%T /storage2/dataset")[1].rstrip()
|
||||
print(f"/storage2/dataset {filesystem=}")
|
||||
assert filesystem == "zfs", "/storage/dataset is not ZFS"
|
||||
'';
|
||||
filesystem = machine.execute("stat --file-system --format=%T /storage2/dataset")[1].rstrip()
|
||||
print(f"/storage2/dataset {filesystem=}")
|
||||
assert filesystem == "zfs", "/storage/dataset is not ZFS"
|
||||
'';
|
||||
};
|
||||
networking.hostId = "8425e349";
|
||||
}
|
||||
+7
-10
@@ -1,12 +1,9 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "simple-efi";
|
||||
disko-config = ../example/simple-efi.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
imports = [ ../example/simple-efi.nix ];
|
||||
disko.test = {
|
||||
name = "simple-efi";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+23
-27
@@ -1,32 +1,28 @@
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "swap";
|
||||
disko-config = ../example/swap.nix;
|
||||
extraTestScript = ''
|
||||
import json
|
||||
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"))
|
||||
imports = [ ../example/swap.nix ];
|
||||
disko.test = {
|
||||
name = "swap";
|
||||
extraChecks = ''
|
||||
import json
|
||||
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]
|
||||
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}"
|
||||
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
|
||||
assert part_type == "Linux swap", f"Expected encrypted swap container to be of type Linux swap, got {part_type}"
|
||||
encrypted_swap_crypt = out["blockdevices"][0]["children"][1]
|
||||
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}"
|
||||
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
|
||||
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]
|
||||
mnt_point = plain_swap_part["mountpoints"][0]
|
||||
assert mnt_point == "[SWAP]", f"Expected swap partition to be mounted as [SWAP], got {mnt_point}"
|
||||
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}"
|
||||
'';
|
||||
extraSystemConfig = {
|
||||
environment.systemPackages = [ pkgs.jq ];
|
||||
plain_swap_part = out["blockdevices"][0]["children"][3]
|
||||
mnt_point = plain_swap_part["mountpoints"][0]
|
||||
assert mnt_point == "[SWAP]", f"Expected swap partition to be mounted as [SWAP], got {mnt_point}"
|
||||
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}"
|
||||
'';
|
||||
nodes.machine.environment.systemPackages = [ pkgs.jq ];
|
||||
};
|
||||
}
|
||||
+8
-11
@@ -1,13 +1,10 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "tmpfs";
|
||||
disko-config = ../example/tmpfs.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint /tmp");
|
||||
'';
|
||||
imports = [ ../example/tmpfs.nix ];
|
||||
disko.test = {
|
||||
name = "tmpfs";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint /tmp");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+9
-11
@@ -1,13 +1,11 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "with-lib";
|
||||
disko-config = ../example/with-lib.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
efi = false;
|
||||
imports = [ ../example/with-lib.nix ];
|
||||
_module.args.disks = [ "/dev/vdb" ];
|
||||
disko.test = {
|
||||
name = "with-lib";
|
||||
efi = false;
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
};
|
||||
}
|
||||
+8
-11
@@ -1,14 +1,11 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "xfs";
|
||||
disko-config = ../example/xfs-with-quota.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
imports = [ ../example/xfs-with-quota.nix ];
|
||||
disko.test = {
|
||||
name = "xfs";
|
||||
extraChecks = ''
|
||||
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> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "zfs-encrypted-root";
|
||||
extraInstallerConfig.networking.hostId = "8425e349";
|
||||
extraSystemConfig.networking.hostId = "8425e349";
|
||||
disko-config = pkgs.lib.recursiveUpdate (import ../example/zfs-encrypted-root.nix) {
|
||||
disko.devices.zpool.zroot.datasets.root.options.keylocation = "file:///tmp/secret.key";
|
||||
imports = [ ../example/zfs-encrypted-root.nix ];
|
||||
disko.test = {
|
||||
name = "zfs-encrypted-root";
|
||||
defaults.disko.devices.zpool.zroot.datasets.root.options.keylocation =
|
||||
lib.mkForce "file:///tmp/secret.key";
|
||||
extraChecks = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint /nix");
|
||||
machine.succeed("swapon --show=NAME | grep /dev/zd"); # i.e. /dev/zd0
|
||||
'';
|
||||
};
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint /nix");
|
||||
machine.succeed("swapon --show=NAME | grep /dev/zd"); # i.e. /dev/zd0
|
||||
'';
|
||||
networking.hostId = "8425e349";
|
||||
}
|
||||
@@ -1,15 +1,11 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "zfs-over-legacy";
|
||||
extraInstallerConfig.networking.hostId = "8425e349";
|
||||
extraSystemConfig.networking.hostId = "8425e349";
|
||||
disko-config = ../example/zfs-over-legacy.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("test -e /zfs_fs");
|
||||
machine.succeed("mountpoint /zfs_fs");
|
||||
'';
|
||||
imports = [ ../example/zfs-over-legacy.nix ];
|
||||
disko.test = {
|
||||
name = "zfs-over-legacy";
|
||||
extraChecks = ''
|
||||
machine.succeed("test -e /zfs_fs");
|
||||
machine.succeed("mountpoint /zfs_fs");
|
||||
'';
|
||||
};
|
||||
networking.hostId = "8425e349";
|
||||
}
|
||||
+66
-74
@@ -1,78 +1,70 @@
|
||||
{
|
||||
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";
|
||||
# It looks like the 60s of NixOS is sometimes not enough for our virtio-based zpool.
|
||||
# This fixes the flakeiness of the test.
|
||||
boot.initrd.postResumeCommands = ''
|
||||
for i in $(seq 1 120); do
|
||||
if zpool list | grep -q zroot || zpool import -N zroot; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
imports = [ ../example/zfs-with-vdevs.nix ];
|
||||
disko.test = {
|
||||
name = "zfs-with-vdevs";
|
||||
nodes.machine = {
|
||||
# It looks like the 60s of NixOS is sometimes not enough for our virtio-based zpool.
|
||||
# This fixes the flakeiness of the test.
|
||||
boot.initrd.postResumeCommands = ''
|
||||
for i in $(seq 1 120); do
|
||||
if zpool list | grep -q zroot || zpool import -N zroot; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
'';
|
||||
};
|
||||
extraChecks = ''
|
||||
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");
|
||||
|
||||
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 = ''
|
||||
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)}"
|
||||
'';
|
||||
networking.hostId = "8425e349";
|
||||
}
|
||||
+33
-39
@@ -1,42 +1,36 @@
|
||||
{
|
||||
pkgs ? import <nixpkgs> { },
|
||||
diskoLib ? pkgs.callPackage ../lib { },
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "zfs";
|
||||
disko-config = ../example/zfs.nix;
|
||||
extraInstallerConfig.networking.hostId = "8425e349";
|
||||
extraSystemConfig = {
|
||||
networking.hostId = "8425e349";
|
||||
fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
||||
imports = [ ../example/zfs.nix ];
|
||||
disko.test = {
|
||||
name = "zfs";
|
||||
nodes.machine.fileSystems."/zfs_legacy_fs".options = [ "nofail" ]; # TODO find out why we need this!
|
||||
extraChecks = ''
|
||||
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");
|
||||
'';
|
||||
};
|
||||
extraTestScript = ''
|
||||
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");
|
||||
'';
|
||||
networking.hostId = "8425e349";
|
||||
}
|
||||
Reference in new issue
Block a user