about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAdam C. Stephens <2071575+adamcstephens@users.noreply.github.com>2024-03-16 16:31:15 -0700
committerGitHub <noreply@github.com>2024-03-16 16:31:15 -0700
commit79edbc3691c254fc929fe7a827cbb100f5af997d (patch)
treed012000781eaa164c7ce77ea44c2e7395cc6a3cf
parent2eff0f9d30c9c1c648cadce403de084c1b843691 (diff)
parent9d411861b5c23ba205b7e02c3b96996063576038 (diff)
downloadnixlib-79edbc3691c254fc929fe7a827cbb100f5af997d.tar
nixlib-79edbc3691c254fc929fe7a827cbb100f5af997d.tar.gz
nixlib-79edbc3691c254fc929fe7a827cbb100f5af997d.tar.bz2
nixlib-79edbc3691c254fc929fe7a827cbb100f5af997d.tar.lz
nixlib-79edbc3691c254fc929fe7a827cbb100f5af997d.tar.xz
nixlib-79edbc3691c254fc929fe7a827cbb100f5af997d.tar.zst
nixlib-79edbc3691c254fc929fe7a827cbb100f5af997d.zip
Merge pull request #295376 from adamcstephens/incus/test-zfs
nixos/tests/incus: add storage test and exercise zfs integration
-rw-r--r--nixos/tests/incus/default.nix1
-rw-r--r--nixos/tests/incus/storage.nix46
2 files changed, 47 insertions, 0 deletions
diff --git a/nixos/tests/incus/default.nix b/nixos/tests/incus/default.nix
index 474a621c5ce9..32bc5396a164 100644
--- a/nixos/tests/incus/default.nix
+++ b/nixos/tests/incus/default.nix
@@ -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; };
 }
diff --git a/nixos/tests/incus/storage.nix b/nixos/tests/incus/storage.nix
new file mode 100644
index 000000000000..190f4f7451c2
--- /dev/null
+++ b/nixos/tests/incus/storage.nix
@@ -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")
+    '';
+  }
+)