about summary refs log tree commit diff
path: root/nixos/tests/grafana
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2022-12-14 13:57:51 +0100
committerFranz Pletz <fpletz@fnordicwalking.de>2022-12-14 14:42:13 +0100
commita0b60725473c3f0646f5b6f9b1352a8d848c8b9e (patch)
tree25c447ab560c2c48401bd00265f3a0e525b53410 /nixos/tests/grafana
parent9be81d0acfd8a5ac8c6a2222255ea9665f66d511 (diff)
nixos/grafana: add test case for socket proxy
Diffstat (limited to 'nixos/tests/grafana')
-rw-r--r--nixos/tests/grafana/basic.nix27
1 files changed, 27 insertions, 0 deletions
diff --git a/nixos/tests/grafana/basic.nix b/nixos/tests/grafana/basic.nix
index f6566d4497098..8bf4caad7fbfc 100644
--- a/nixos/tests/grafana/basic.nix
+++ b/nixos/tests/grafana/basic.nix
@@ -25,6 +25,22 @@ let
   extraNodeConfs = {
     sqlite = {};
 
+    socket = { config, ... }: {
+      services.grafana.settings.server = {
+        protocol = "socket";
+        socket = "/run/grafana/sock";
+        socket_gid = config.users.groups.nginx.gid;
+      };
+
+      users.users.grafana.extraGroups = [ "nginx" ];
+
+      services.nginx = {
+        enable = true;
+        recommendedProxySettings = true;
+        virtualHosts."_".locations."/".proxyPass = "http://unix:/run/grafana/sock";
+      };
+    };
+
     declarativePlugins = {
       services.grafana.declarativePlugins = [ pkgs.grafanaPlugins.grafana-clock-panel ];
     };
@@ -92,6 +108,17 @@ in {
         )
         sqlite.shutdown()
 
+    with subtest("Successful API query as admin user with sqlite db listening on socket"):
+        socket.wait_for_unit("grafana.service")
+        socket.wait_for_open_port(80)
+        print(socket.succeed(
+            "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1/api/org/users -i"
+        ))
+        socket.succeed(
+            "curl -sSfN -u testadmin:snakeoilpwd http://127.0.0.1/api/org/users | grep admin\@localhost"
+        )
+        socket.shutdown()
+
     with subtest("Successful API query as admin user with postgresql db"):
         postgresql.wait_for_unit("grafana.service")
         postgresql.wait_for_unit("postgresql.service")