summary refs log tree commit diff
path: root/nixos/tests/adguardhome.nix
blob: ddbe8ff9c11739da5a3955f4e9f00b9ec145651c (plain) (blame)
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
import ./make-test-python.nix {
  name = "adguardhome";

  nodes = {
    minimalConf = { ... }: {
      services.adguardhome = { enable = true; };
    };

    declarativeConf = { ... }: {
      services.adguardhome = {
        enable = true;

        mutableSettings = false;
        settings = {
          dns = {
            bind_host = "0.0.0.0";
            bootstrap_dns = "127.0.0.1";
          };
        };
      };
    };

    mixedConf = { ... }: {
      services.adguardhome = {
        enable = true;

        mutableSettings = true;
        settings = {
          dns = {
            bind_host = "0.0.0.0";
            bootstrap_dns = "127.0.0.1";
          };
        };
      };
    };
  };

  testScript = ''
    with subtest("Minimal config test"):
        minimalConf.wait_for_unit("adguardhome.service")
        minimalConf.wait_for_open_port(3000)

    with subtest("Declarative config test, DNS will be reachable"):
        declarativeConf.wait_for_unit("adguardhome.service")
        declarativeConf.wait_for_open_port(53)
        declarativeConf.wait_for_open_port(3000)

    with subtest("Mixed config test, check whether merging works"):
        mixedConf.wait_for_unit("adguardhome.service")
        mixedConf.wait_for_open_port(53)
        mixedConf.wait_for_open_port(3000)
        # Test whether merging works properly, even if nothing is changed
        mixedConf.systemctl("restart adguardhome.service")
        mixedConf.wait_for_unit("adguardhome.service")
        mixedConf.wait_for_open_port(3000)
  '';
}