summary refs log tree commit diff
diff options
context:
space:
mode:
authorCRTified <carl.schneider+github@ruhr-uni-bochum.de>2022-01-17 01:39:27 +0100
committerCRTified <carl.schneider+github@ruhr-uni-bochum.de>2022-01-17 01:39:27 +0100
commitf9bc03e3c7726af2d397eb697ffe878aae503860 (patch)
treeba20bbb8d379a1cb5d349a952a7294bad94d7fbf
parentcbbabaddf9c2697379f49de6eaf0d7db99db2366 (diff)
downloadnixpkgs-f9bc03e3c7726af2d397eb697ffe878aae503860.tar
nixpkgs-f9bc03e3c7726af2d397eb697ffe878aae503860.tar.gz
nixpkgs-f9bc03e3c7726af2d397eb697ffe878aae503860.tar.bz2
nixpkgs-f9bc03e3c7726af2d397eb697ffe878aae503860.tar.lz
nixpkgs-f9bc03e3c7726af2d397eb697ffe878aae503860.tar.xz
nixpkgs-f9bc03e3c7726af2d397eb697ffe878aae503860.tar.zst
nixpkgs-f9bc03e3c7726af2d397eb697ffe878aae503860.zip
nixos/adguardhome: add test
-rw-r--r--nixos/tests/adguardhome.nix57
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--pkgs/servers/adguardhome/default.nix3
3 files changed, 60 insertions, 1 deletions
diff --git a/nixos/tests/adguardhome.nix b/nixos/tests/adguardhome.nix
new file mode 100644
index 00000000000..ddbe8ff9c11
--- /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 5ebe07ad3cb..a403a2fce49 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 9940decc0bc..dcf397ed4b2 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; {