From f9bc03e3c7726af2d397eb697ffe878aae503860 Mon Sep 17 00:00:00 2001 From: CRTified Date: Mon, 17 Jan 2022 01:39:27 +0100 Subject: [PATCH] nixos/adguardhome: add test --- nixos/tests/adguardhome.nix | 57 ++++++++++++++++++++++++++++ nixos/tests/all-tests.nix | 1 + pkgs/servers/adguardhome/default.nix | 3 +- 3 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 nixos/tests/adguardhome.nix diff --git a/nixos/tests/adguardhome.nix b/nixos/tests/adguardhome.nix new file mode 100644 index 000000000000..ddbe8ff9c117 --- /dev/null +++ b/nixos/tests/adguardhome.nix @@ -0,0 +1,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) + ''; +} diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 5ebe07ad3cb7..a403a2fce491 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -23,6 +23,7 @@ in { _3proxy = handleTest ./3proxy.nix {}; acme = handleTest ./acme.nix {}; + adguardhome = handleTest ./adguardhome.nix {}; aesmd = handleTest ./aesmd.nix {}; agda = handleTest ./agda.nix {}; airsonic = handleTest ./airsonic.nix {}; diff --git a/pkgs/servers/adguardhome/default.nix b/pkgs/servers/adguardhome/default.nix index 9940decc0bc9..dcf397ed4b24 100644 --- a/pkgs/servers/adguardhome/default.nix +++ b/pkgs/servers/adguardhome/default.nix @@ -1,4 +1,4 @@ -{ lib, stdenv, fetchurl, fetchzip }: +{ lib, stdenv, fetchurl, fetchzip, nixosTests }: stdenv.mkDerivation rec { pname = "adguardhome"; @@ -12,6 +12,7 @@ stdenv.mkDerivation rec { passthru = { updateScript = ./update.sh; + tests.adguardhome = nixosTests.adguardhome; }; meta = with lib; {