about summary refs log tree commit diff
path: root/nixos/tests/incus/storage.nix
blob: 190f4f7451c207069f421fac6108a2d2f6c7a969 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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")
    '';
  }
)