Unverified Commit baf5e10d authored by Jonathan Davies's avatar Jonathan Davies
Browse files

nixos/ntpd-rs: tests: Configure server observability endpoint on globally listening address

This is how it would be configured for a real-world Prometheus deployment
parent d28bf5e5
Loading
Loading
Loading
Loading
+20 −4
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@ import ./make-test-python.nix (
      client = {
        services.ntpd-rs = {
          enable = true;
          metrics.enable = true;
          metrics.enable = false;
          useNetworkingTimeServers = false;
          settings = {
            source = [
@@ -27,11 +27,22 @@ import ./make-test-python.nix (
        };
      };
      server = {
        networking.firewall.allowedUDPPorts = [ 123 ];
        networking.firewall = {
          allowedTCPPorts = [
            9975
          ];
          allowedUDPPorts = [
            123
          ];
        };

        services.ntpd-rs = {
          enable = true;
          metrics.enable = true;
          settings = {
            observability = {
              metrics-exporter-listen = "[::]:9975";
            };
            server = [
              { listen = "[::]:123"; }
            ];
@@ -48,8 +59,13 @@ import ./make-test-python.nix (
        for machine in (server, client):
          machine.wait_for_unit('multi-user.target')
          machine.succeed('systemctl is-active ntpd-rs.service')
          machine.succeed('systemctl is-active ntpd-rs-metrics.service')
          machine.succeed('curl http://localhost:9975/metrics | grep ntp_uptime_seconds')

        client.fail('systemctl is-active ntpd-rs-metrics.service')
        server.succeed('systemctl is-active ntpd-rs-metrics.service')

        server.wait_for_open_port(9975)
        client.succeed('curl http://server:9975/metrics | grep ntp_uptime_seconds')
        server.fail('curl --fail --connect-timeout 2 http://client:9975/metrics | grep ntp_uptime_seconds')

        client.succeed("ntp-ctl status | grep server:123")
        server.succeed("ntp-ctl status | grep '\[::\]:123'")