Skip to content

Commit 4dcf2fa

Browse files
committed
nix: Add NixOS integration test definition for ZTS
1 parent 536f2e6 commit 4dcf2fa

File tree

2 files changed

+97
-0
lines changed

2 files changed

+97
-0
lines changed

flake.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
in
2828
{
2929
packages.default = openzfs;
30+
31+
checks.zts = pkgs.testers.runNixOSTest (import ./nix/test.nix { inherit openzfs; });
3032
}
3133
);
3234
}

nix/test.nix

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
{ openzfs, ... }:
2+
3+
{
4+
name = "zts";
5+
6+
globalTimeout = 24 * 60 * 60;
7+
8+
nodes = {
9+
machine =
10+
{ pkgs, lib, ... }:
11+
{
12+
virtualisation = {
13+
cores = 4;
14+
diskSize = 10 * 1024;
15+
memorySize = 16 * 1024;
16+
};
17+
18+
boot.kernelPatches = [
19+
{
20+
name = "enable KASAN";
21+
patch = null;
22+
extraConfig = ''
23+
KASAN y
24+
DEBUG_KMEMLEAK y
25+
GCOV_KERNEL y
26+
'';
27+
}
28+
];
29+
30+
boot.kernelParams = [
31+
"kasan.fault=report"
32+
];
33+
34+
boot.loader.systemd-boot.enable = true;
35+
boot.initrd.systemd.enable = true;
36+
37+
networking.hostId = "deadbeef";
38+
boot.zfs.package = openzfs;
39+
boot.zfs.modulePackage = openzfs;
40+
boot.supportedFilesystems = [ "zfs" ];
41+
42+
environment.systemPackages =
43+
let
44+
zfsTestsScript = pkgs.writeShellScriptBin "zfs-tests" ''
45+
export STF_PATH=${
46+
lib.makeBinPath [
47+
pkgs.bash
48+
pkgs.coreutils
49+
pkgs.bzip2
50+
pkgs.gawk
51+
pkgs.ksh
52+
pkgs.lvm2
53+
pkgs.su
54+
pkgs.sudo
55+
pkgs.systemd
56+
pkgs.util-linux
57+
openzfs
58+
]
59+
};
60+
61+
export LOSETUP="${lib.getExe' pkgs.util-linux "losetup"}"
62+
export DMSETUP="${lib.getExe' pkgs.lvm2.bin "dmsetup"}"
63+
64+
${openzfs}/share/zfs/zfs-tests.sh -K -m -v -x
65+
'';
66+
in
67+
[
68+
zfsTestsScript
69+
openzfs
70+
];
71+
72+
users.users.tester = {
73+
isNormalUser = true;
74+
description = "ZFS tester";
75+
password = "foobar";
76+
extraGroups = [ "wheel" ];
77+
};
78+
79+
security.sudo.wheelNeedsPassword = false;
80+
};
81+
82+
};
83+
84+
testScript = ''
85+
machine.wait_for_unit("multi-user.target")
86+
87+
machine.log(machine.succeed(
88+
"sudo -u tester -- zfs-tests"
89+
))
90+
91+
_, report_location = machine.execute("find /tmp -name zts-report")
92+
93+
machine.copy_from_vm(report_location, "")
94+
'';
95+
}

0 commit comments

Comments
 (0)