nixos/tests/incus: add storage test and exercise zfs integration

This commit is contained in:
Adam Stephens 2024-03-12 13:36:58 -04:00
parent cc6483ff6f
commit 9d411861b5
No known key found for this signature in database
2 changed files with 47 additions and 0 deletions

View file

@ -14,6 +14,7 @@
openvswitch = import ./openvswitch.nix { inherit system pkgs; };
preseed = import ./preseed.nix { inherit system pkgs; };
socket-activated = import ./socket-activated.nix { inherit system pkgs; };
storage = import ./storage.nix { inherit system pkgs; };
ui = import ./ui.nix {inherit system pkgs;};
virtual-machine = handleTestOn [ "x86_64-linux" ] ./virtual-machine.nix { inherit system pkgs; };
}

View file

@ -0,0 +1,46 @@
import ../make-test-python.nix (
{ pkgs, lib, ... }:
{
name = "incus-storage";
meta = {
maintainers = lib.teams.lxc.members;
};
nodes.machine =
{ lib, ... }:
{
boot.supportedFilesystems = [ "zfs" ];
boot.zfs.forceImportRoot = false;
environment.systemPackages = [ pkgs.parted ];
networking.hostId = "01234567";
networking.nftables.enable = true;
virtualisation = {
emptyDiskImages = [ 2048 ];
incus.enable = true;
};
};
testScript = ''
machine.wait_for_unit("incus.service")
with subtest("Verify zfs pool created and usable"):
machine.succeed(
"zpool status",
"parted --script /dev/vdb mklabel gpt",
"zpool create zfs_pool /dev/vdb",
)
machine.succeed("incus storage create zfs_pool zfs source=zfs_pool/incus")
machine.succeed("zfs list zfs_pool/incus")
machine.succeed("incus storage volume create zfs_pool test_fs --type filesystem")
machine.succeed("incus storage volume create zfs_pool test_vol --type block")
machine.succeed("incus storage show zfs_pool")
machine.succeed("incus storage volume list zfs_pool")
machine.succeed("incus storage volume show zfs_pool test_fs")
machine.succeed("incus storage volume show zfs_pool test_vol")
'';
}
)