summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorlassulus <lassulus@lassul.us>2022-08-25 15:08:26 +0200
committerlassulus <lassulus@lassul.us>2022-08-25 23:31:05 +0200
commit83fb8f661eb574f32fad1d51bbebd0c36595db01 (patch)
tree93761cafa54cc79af862e13baee151ad682d957d /tests
parentdd99e29edc994056d5f700e24a75406115e98dff (diff)
add zfs support/test/example
Diffstat (limited to 'tests')
-rw-r--r--tests/zfs.nix40
1 files changed, 40 insertions, 0 deletions
diff --git a/tests/zfs.nix b/tests/zfs.nix
new file mode 100644
index 0000000..bc807bc
--- /dev/null
+++ b/tests/zfs.nix
@@ -0,0 +1,40 @@
+{ makeTest ? import <nixpkgs/nixos/tests/make-test-python.nix>
+, pkgs ? (import <nixpkgs> {})
+}:
+let
+ makeTest' = args:
+ makeTest args {
+ inherit pkgs;
+ inherit (pkgs) system;
+ };
+ disko-config = import ../example/zfs.nix;
+ tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. {}).create disko-config);
+ tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. {}).mount disko-config);
+in makeTest' {
+ name = "disko";
+
+ nodes.machine =
+ { config, pkgs, modulesPath, ... }:
+
+ {
+ imports = [
+ (modulesPath + "/profiles/installation-device.nix")
+ (modulesPath + "/profiles/base.nix")
+ ];
+
+ # speed-up eval
+ documentation.enable = false;
+
+ virtualisation.emptyDiskImages = [ 512 512 ];
+ };
+
+ testScript = ''
+ machine.succeed("echo 'secret' > /tmp/secret.key");
+ machine.succeed("${tsp-create}");
+ machine.succeed("${tsp-mount}");
+ machine.succeed("${tsp-mount}"); # verify that the command is idempotent
+ machine.succeed("test -b /dev/zvol/zroot/zfs_testvolume");
+ machine.succeed("grep -qs '/mnt/ext4onzfs' /proc/mounts");
+ '';
+}
+