From da858b16b88cad1ed67662b0fa6f483bb665d498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sandro=20J=C3=A4ckel?= Date: Thu, 29 Apr 2021 06:00:45 +0200 Subject: [PATCH] nixos/tests/prometheus-exporters: add unbound test Author: WilliButz --- nixos/tests/prometheus-exporters.nix | 23 +++++++++++++++++++ .../prometheus/unbound-exporter.nix | 6 ++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/nixos/tests/prometheus-exporters.nix b/nixos/tests/prometheus-exporters.nix index 62c0080dd51..55fe7db4db3 100644 --- a/nixos/tests/prometheus-exporters.nix +++ b/nixos/tests/prometheus-exporters.nix @@ -1000,6 +1000,29 @@ let ''; }; + unbound = { + exporterConfig = { + enable = true; + fetchType = "uds"; + controlInterface = "/run/unbound/unbound.ctl"; + }; + metricProvider = { + services.unbound = { + enable = true; + localControlSocketPath = "/run/unbound/unbound.ctl"; + }; + systemd.services.prometheus-unbound-exporter.serviceConfig = { + SupplementaryGroups = [ "unbound" ]; + }; + }; + exporterTest = '' + wait_for_unit("unbound.service") + wait_for_unit("prometheus-unbound-exporter.service") + wait_for_open_port(9167) + succeed("curl -sSf localhost:9167/metrics | grep -q 'unbound_up 1'") + ''; + }; + varnish = { exporterConfig = { enable = true; diff --git a/pkgs/servers/monitoring/prometheus/unbound-exporter.nix b/pkgs/servers/monitoring/prometheus/unbound-exporter.nix index c085226d909..6b26379bf26 100644 --- a/pkgs/servers/monitoring/prometheus/unbound-exporter.nix +++ b/pkgs/servers/monitoring/prometheus/unbound-exporter.nix @@ -1,4 +1,4 @@ -{ lib, rustPlatform, fetchFromGitHub, openssl, pkg-config }: +{ lib, rustPlatform, fetchFromGitHub, openssl, pkg-config, nixosTests }: rustPlatform.buildRustPackage rec { pname = "unbound-telemetry"; @@ -17,6 +17,10 @@ rustPlatform.buildRustPackage rec { buildInputs = [ openssl ]; + passthru.tests = { + inherit (nixosTests.prometheus-exporters) unbound; + }; + meta = with lib; { description = "Prometheus exporter for Unbound DNS resolver"; homepage = "https://github.com/svartalf/unbound-telemetry";