98 lines
2.6 KiB
Nix
98 lines
2.6 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
inputs,
|
|
...
|
|
}:
|
|
let
|
|
# Create pkgs with ensureZfsMounts overlay
|
|
testPkgs = import inputs.nixpkgs {
|
|
system = pkgs.system;
|
|
overlays = [ (import ../overlays.nix) ];
|
|
};
|
|
in
|
|
testPkgs.testers.runNixOSTest {
|
|
name = "zfs folder dependency and mounting test";
|
|
|
|
nodes.machine =
|
|
{ pkgs, ... }:
|
|
{
|
|
imports = [
|
|
(lib.serviceMountDeps "foobar" [ "/mnt/foobar_data" ])
|
|
(lib.serviceMountDeps "foobarSadge" [
|
|
"/mnt/foobar_data"
|
|
"/mnt/does_not_exist_lol"
|
|
])
|
|
|
|
];
|
|
virtualisation = {
|
|
emptyDiskImages = [
|
|
4096
|
|
];
|
|
};
|
|
networking.hostId = "deadbeef";
|
|
boot.kernelPackages = config.boot.kernelPackages;
|
|
boot.zfs.package = config.boot.zfs.package;
|
|
boot.supportedFilesystems = [ "zfs" ];
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
parted
|
|
ensureZfsMounts
|
|
];
|
|
|
|
systemd.services.foobar = {
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
ExecStart = lib.getExe pkgs.bash;
|
|
};
|
|
};
|
|
|
|
systemd.services.foobarSadge = {
|
|
serviceConfig = {
|
|
Type = "oneshot";
|
|
RemainAfterExit = true;
|
|
ExecStart = lib.getExe pkgs.bash;
|
|
};
|
|
};
|
|
};
|
|
|
|
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/test path with spaces' rpool/test3")
|
|
|
|
machine.succeed("zfsEnsureMounted '/mnt/test path with spaces'")
|
|
|
|
# machine.succeed("zfsEnsureMounted /mnt/test\\ escaped\\ spaces") # TODO! fix escaped spaces
|
|
|
|
machine.succeed("zfsEnsureMounted /mnt/test_mountpoint '/mnt/test path with spaces' /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")
|
|
'';
|
|
}
|