From: Otto Moerbeek Date: Wed, 14 Apr 2021 09:30:44 +0000 (+0200) Subject: Also test stats API for recursor X-Git-Tag: dnsdist-1.6.0~3^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b521df9938dd1138793a5becd3167126d258978e;p=thirdparty%2Fpdns.git Also test stats API for recursor --- diff --git a/pdns/histogram.hh b/pdns/histogram.hh index a315b8813f..525ccbf456 100644 --- a/pdns/histogram.hh +++ b/pdns/histogram.hh @@ -23,6 +23,7 @@ #include #include +#include #include #include diff --git a/regression-tests.api/test_Servers.py b/regression-tests.api/test_Servers.py index e635b25de3..6789796906 100644 --- a/regression-tests.api/test_Servers.py +++ b/regression-tests.api/test_Servers.py @@ -43,8 +43,8 @@ class Servers(ApiTestCase): self.assert_success_json(r) data = r.json() self.assertIn('uptime', [e['name'] for e in data]) + print(data) if is_auth(): - print(data) qtype_stats, respsize_stats, queries_stats, rcode_stats = None, None, None, None for elem in data: if elem['type'] == 'MapStatisticItem' and elem['name'] == 'response-by-qtype': @@ -59,6 +59,19 @@ class Servers(ApiTestCase): self.assertIn('60', [e['name'] for e in respsize_stats]) self.assertIn('example.com/A', [e['name'] for e in queries_stats]) self.assertIn('No Error', [e['name'] for e in rcode_stats]) + else: + qtype_stats, respsize_stats, rcode_stats = None, None, None + for elem in data: + if elem['type'] == 'MapStatisticItem' and elem['name'] == 'response-by-qtype': + qtype_stats = elem['value'] + elif elem['type'] == 'MapStatisticItem' and elem['name'] == 'response-sizes': + respsize_stats = elem['value'] + elif elem['type'] == 'MapStatisticItem' and elem['name'] == 'response-by-rcode': + rcode_stats = elem['value'] + self.assertIn('A', [e['name'] for e in qtype_stats]) + self.assertIn('60', [e['name'] for e in respsize_stats]) + self.assertIn('No Error', [e['name'] for e in rcode_stats]) + def test_read_one_statistic(self): r = self.session.get(self.url("/api/v1/servers/localhost/statistics?statistic=uptime"))