at master 1.4 kB view raw
1# A basic test with no webserver, no API, just checking DNS functionality 2{ 3 lib, 4 pkgs, 5 ... 6}: 7 8rec { 9 name = "pihole-ftl-basic"; 10 meta.maintainers = with lib.maintainers; [ averyvigolo ]; 11 12 nodes.machine = 13 { pkgs, lib, ... }: 14 { 15 services.pihole-ftl = { 16 enable = true; 17 openFirewallDNS = true; 18 }; 19 environment.systemPackages = with pkgs; [ dig ]; 20 }; 21 22 nodes.client = 23 { pkgs, lib, ... }: 24 { 25 environment.systemPackages = with pkgs; [ dig ]; 26 }; 27 28 testScript = 29 { nodes, ... }: 30 '' 31 machine.wait_for_unit("pihole-ftl.service") 32 machine.wait_for_open_port(53) 33 client.wait_for_unit("network.target") 34 35 with subtest("the pi-hole machine resolves properly"): 36 ret, out = machine.execute("dig @localhost +short pi.hole") 37 assert ret == 0, "pi.hole should resolve on the local machine" 38 assert out.rstrip() == "127.0.0.1", "pi.hole should resolve to localhost on the local machine" 39 40 machine_address = "${(builtins.head nodes.machine.networking.interfaces.eth1.ipv4.addresses).address}" 41 42 with subtest("a client machine resolves properly"): 43 ret, out = client.execute(f"dig @{machine_address} +short pi.hole") 44 assert ret == 0, "pi.hole should resolve on a client machine" 45 assert out.rstrip() == machine_address, "pi.hole should resolve to the machine's address" 46 ''; 47}