]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Also test stats API for recursor
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 14 Apr 2021 09:30:44 +0000 (11:30 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 14 Apr 2021 09:30:44 +0000 (11:30 +0200)
pdns/histogram.hh
regression-tests.api/test_Servers.py

index a315b8813f36e8393522ea059938058aa65893f4..525ccbf45670d0f7be48c5609a70f6c4525428ea 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <algorithm>
 #include <atomic>
+#include <stdexcept>
 #include <string>
 #include <vector>
 
index e635b25de32a5727dedae7a0739f377cb1ee025d..6789796906814490837dfdbce3fc56470c0bf6a7 100644 (file)
@@ -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"))