summaryrefslogtreecommitdiffstats
path: root/tests/mdadm.nix
blob: 37465e448661ee2d0e5f81371c88c6ff42a89fcf (plain)
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
{ 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' {
  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/md/raid1");
    machine.succeed("grep -qs '/mnt/raid' /proc/mounts");
  '';
}