mirror of
https://github.com/nix-community/disko.git
synced 2026-12-01 05:23:28 +01:00
tests: Move example tests to dedicated folder
This commit is contained in:
1 parent
389235b63f
commit
737e045f53
40 files changed
+58
-43
No files matched your search
@@ -0,0 +1,3 @@
|
||||
# Tests for all example files
|
||||
|
||||
You can check out the examples tested here in [../../example](../../example/).
|
||||
@@ -0,0 +1,16 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "bcachefs";
|
||||
disko-config = ../../example/bcachefs.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("lsblk >&2");
|
||||
'';
|
||||
# so that the installer boots with a bcachefs enabled kernel
|
||||
extraInstallerConfig = {
|
||||
boot.supportedFilesystems = [ "bcachefs" ];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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 = {
|
||||
# sadly systemd-boot fails to install to a raid /boot device
|
||||
boot.loader.systemd-boot.enable = false;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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 /");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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");
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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("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 = [ "dm-raid" "dm-mirror" ];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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" ];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "gpt-bios-compat";
|
||||
disko-config = ../../example/gpt-bios-compat.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
efi = false;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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'");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "hybrid-mbr";
|
||||
disko-config = ../../example/hybrid-mbr.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "hybrid";
|
||||
disko-config = ../../example/hybrid.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "legacy-table";
|
||||
disko-config = ../../example/legacy-table.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "long-device-name";
|
||||
disko-config = ../../example/long-device-name.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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 /");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "luks-interactive-login";
|
||||
disko-config = ../../example/luks-interactive-login.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("cryptsetup isLuks /dev/vda2");
|
||||
'';
|
||||
bootCommands = ''
|
||||
machine.wait_for_console_text("vda")
|
||||
machine.send_console("secretsecret\n")
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "lvm-raid";
|
||||
disko-config = ../../example/lvm-raid.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
extraInstallerConfig = {
|
||||
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;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "lvm-sizes-sort";
|
||||
disko-config = ../../example/lvm-sizes-sort.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "lvm-thin";
|
||||
disko-config = ../../example/lvm-thin.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /home");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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;
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
# this is a regression test for https://github.com/nix-community/disko/issues/52
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
# this is a regression test for https://github.com/nix-community/disko/issues/52
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "negative-size";
|
||||
disko-config = ../../example/negative-size.nix;
|
||||
testBoot = false;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /mnt");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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")
|
||||
|
||||
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")
|
||||
|
||||
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 /storage")[1].rstrip()
|
||||
print(f"/storage {filesystem=}")
|
||||
assert filesystem == "zfs", "/storage is not ZFS"
|
||||
|
||||
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/dataset")[1].rstrip()
|
||||
print(f"/storage2/dataset {filesystem=}")
|
||||
assert filesystem == "zfs", "/storage/dataset is not ZFS"
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "simple-efi";
|
||||
disko-config = ../../example/simple-efi.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
{ pkgs ? import <nixpkgs> { }, ... }:
|
||||
(pkgs.nixos [
|
||||
../../example/stand-alone/configuration.nix
|
||||
{ documentation.enable = false; }
|
||||
]).config.system.build.toplevel
|
||||
@@ -0,0 +1,31 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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"))
|
||||
|
||||
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 ];
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "tmpfs";
|
||||
disko-config = ../../example/tmpfs.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
machine.succeed("mountpoint /tmp");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_lib { }
|
||||
}:
|
||||
diskoLib.testLib.makeDiskoTest {
|
||||
inherit pkgs;
|
||||
name = "with-lib";
|
||||
disko-config = ../../example/with-lib.nix;
|
||||
extraTestScript = ''
|
||||
machine.succeed("mountpoint /");
|
||||
'';
|
||||
efi = false;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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");
|
||||
'';
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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
|
||||
'';
|
||||
};
|
||||
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");
|
||||
'';
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
{ pkgs ? import <nixpkgs> { }
|
||||
, diskoLib ? pkgs.callPackage ../src/disko_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!
|
||||
};
|
||||
extraTestScript = ''
|
||||
machine.succeed("test -b /dev/zvol/zroot/zfs_testvolume");
|
||||
|
||||
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_testvolume", "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 /zfs_crypted");
|
||||
machine.succeed("zfs get keystatus zroot/encrypted");
|
||||
machine.succeed("zfs get keystatus zroot/encrypted/test");
|
||||
'';
|
||||
}
|
||||
Reference in new issue
Block a user