add testing infra
This commit is contained in:
87
tests/zfs.nix
Normal file
87
tests/zfs.nix
Normal file
@@ -0,0 +1,87 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
pkgs.testers.runNixOSTest {
|
||||
name = "test of tests";
|
||||
|
||||
nodes.machine =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
(lib.serviceMountDeps "foobar" [ "/mnt/foobar_data" ])
|
||||
(lib.serviceMountDeps "foobarSadge" [
|
||||
"/mnt/foobar_data"
|
||||
"/mnt/does_not_exist_lol"
|
||||
])
|
||||
|
||||
];
|
||||
virtualisation = {
|
||||
emptyDiskImages = [
|
||||
4096
|
||||
];
|
||||
useBootLoader = true;
|
||||
useEFIBoot = true;
|
||||
};
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
boot.loader.timeout = 0;
|
||||
boot.loader.efi.canTouchEfiVariables = true;
|
||||
networking.hostId = "deadbeef";
|
||||
boot.kernelPackages = config.boot.kernelPackages;
|
||||
boot.zfs.package = config.boot.zfs.package;
|
||||
boot.supportedFilesystems = [ "zfs" ];
|
||||
|
||||
environment.systemPackages = [
|
||||
pkgs.parted
|
||||
lib.ensureZfsMounts
|
||||
];
|
||||
|
||||
systemd.services.foobar = {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStart = "${lib.getExe pkgs.bash} -c \"true\"";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services.foobarSadge = {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
ExecStart = "${lib.getExe pkgs.bash} -c \"true\"";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
testScript = ''
|
||||
start_all()
|
||||
machine.wait_for_unit("multi-user.target")
|
||||
machine.succeed(
|
||||
"parted --script /dev/vdb mklabel msdos",
|
||||
"parted --script /dev/vdb -- mkpart primary 1024M -1s",
|
||||
)
|
||||
|
||||
machine.fail("zfsEnsureMounted")
|
||||
machine.fail("zfsEnsureMounted /mnt/test_mountpoint")
|
||||
|
||||
machine.succeed("zpool create rpool /dev/vdb1")
|
||||
machine.succeed("zfs create -o mountpoint=/mnt/test_mountpoint rpool/test")
|
||||
|
||||
machine.succeed("zfsEnsureMounted /mnt/test_mountpoint")
|
||||
|
||||
machine.fail("zfsEnsureMounted /mnt/does_not_exist_lol")
|
||||
machine.fail("zfsEnsureMounted /mnt/test_mountpoint /mnt/does_not_exist_lol")
|
||||
|
||||
machine.succeed("zfs create -o mountpoint=/mnt/test_mountpoint_dos rpool/test2")
|
||||
|
||||
machine.succeed("zfsEnsureMounted /mnt/test_mountpoint /mnt/test_mountpoint_dos")
|
||||
|
||||
|
||||
machine.succeed("zfs create -o mountpoint=/mnt/foobar_data rpool/foobar")
|
||||
machine.succeed("systemctl start foobar")
|
||||
|
||||
machine.fail("systemctl start foobarSadge")
|
||||
'';
|
||||
}
|
||||
Reference in New Issue
Block a user