disko/tests/mdadm.nix

40 lines
1.1 KiB
Nix
Raw Normal View History

{ 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/mdadm.nix;
tsp-create = pkgs.writeScript "create" ((pkgs.callPackage ../. {}).create disko-config);
tsp-mount = pkgs.writeScript "mount" ((pkgs.callPackage ../. {}).mount disko-config);
in makeTest' {
2018-08-05 12:45:15 +03:00
name = "disko";
nodes.machine =
{ config, pkgs, modulesPath, ... }:
2018-08-05 12:45:15 +03:00
{
imports = [
(modulesPath + "/profiles/installation-device.nix")
(modulesPath + "/profiles/base.nix")
2018-08-05 12:45:15 +03:00
];
# speed-up eval
documentation.enable = false;
2022-08-24 17:46:36 +03:00
virtualisation.emptyDiskImages = [ 512 512 ];
2018-08-05 12:45:15 +03:00
};
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
2022-08-24 17:46:36 +03:00
machine.succeed("test -b /dev/md/raid1");
machine.succeed("grep -qs '/mnt/raid' /proc/mounts");
'';
}