summaryrefslogtreecommitdiffstats
path: root/nixos/tests/holo-daemon-modular.nix
blob: af32d7e5d4722af02272a7cd84ec404de87fa2db (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ ... }:
{
  _class = "nixosTest";
  name = "holo-daemon-modular-service-test";

  nodes = {
    machine =
      { pkgs, ... }:
      {
        environment.systemPackages = [
          pkgs.holo-daemon
          pkgs.holo-cli
        ];
        system.services.holo-daemon = {
          imports = [ pkgs.holo-daemon.services.default ];
        };
        users.users.holo = {
          isSystemUser = true;
          group = "holo";
          home = "/var/lib/holo";
          createHome = true;
        };
        users.groups.holo = { };
        services.getty.autologinUser = "root";
      };
  };

  testScript =
    { nodes, ... }:
    ''
      import time

      start_all()

      # holo-cli connects to the daemon at startup
      # features a bash-like editing functionality for interactive use
      # uses -c option to execute arguments as commands

      machine.wait_for_unit("multi-user.target")

      machine.wait_for_unit("holo-daemon.service")

      machine.succeed("holo-cli -V")

      # wait for cli to connect to the daemon
      machine.wait_for_open_port(50051)

      # Test the running configuration is empty
      machine.succeed("holo-cli -c 'show running format json'")

      # Configure an OSPFv3 instance:
      # as seen in https://asciinema.org/a/qYxmDu1QjGPBAt5gNyNKvXhHk

      machine.send_chars("holo-cli\n", 1)
      time.sleep(5)
      machine.send_chars("configure\n", 1)
      machine.send_chars("routing control-plane-protocols control-plane-protocol ietf-ospf:ospfv3 main\n", 1)
      machine.send_chars("ospf preference inter-area 50\n", 1)
      machine.send_chars("show changes\n", 1)
      machine.send_chars("commit\n", 1)
      machine.send_chars("exit\n", 1)

      # Verify the configuration was applied (in interactive test)
      machine.succeed("test \"$(holo-cli -c 'show running format json')\" != \"{}\"");
    '';
}