summaryrefslogtreecommitdiffstats
path: root/nixos/tests/omada.nix
blob: 6ab756782720498aed63ea38edcd8d81a089a089 (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
{ lib, ... }:

let
  port = 8088;
in

{
  name = "omada";
  meta.maintainers = with lib.maintainers; [ pathob ];

  nodes.machine = {
    # The controller (Java) plus the MongoDB it launches need more than the
    # default 1 GiB of memory.
    virtualisation.memorySize = 2048;

    services.omada = {
      enable = true;
    };
  };

  testScript = ''
    def omada_is_up(_) -> bool:
        status, _ = machine.execute("curl --fail http://localhost:${toString port}")
        return status == 0

    machine.start()
    machine.wait_for_unit("omada.service")
    machine.wait_for_open_port(${toString port})

    with machine.nested("Waiting for UI to work"):
        retry(omada_is_up)
  '';
}