]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Check for duplicated prometheus line/keys 16668/head
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 9 Jan 2026 14:54:11 +0000 (15:54 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 9 Jan 2026 14:54:11 +0000 (15:54 +0100)
Signed-off-by: Remi Gacogne <remi.gacogne@powerdns.com>
regression-tests.dnsdist/test_Prometheus.py

index 57e5cc06576eca5b115f9312c5a99da65760f826..72c494384620e8225d7baa3479e90c1bf61a1954 100644 (file)
@@ -36,7 +36,12 @@ class TestPrometheus(DNSDistTest):
     """
 
     def checkPrometheusContentBasic(self, content):
+        linesSeen = {}
+        keysSeen = {}
         for line in content.splitlines():
+            if line in linesSeen:
+                raise AssertionError(f"Duplicate line in prometheus output: '{line}'")
+            linesSeen[line] = True
             if line.startswith('# HELP'):
                 tokens = line.split(' ')
                 self.assertGreaterEqual(len(tokens), 4)
@@ -50,6 +55,10 @@ class TestPrometheus(DNSDistTest):
                 if not line.startswith('dnsdist_') and not line.startswith('custom_'):
                     raise AssertionError(
                         'Expecting prometheus metric to be prefixed by \'dnsdist_\', got: "%s"' % (line))
+                key = tokens[0]
+                if key in keysSeen:
+                    raise AssertionError(f"Duplicate prometheus key: '{key}'")
+                keysSeen[key] = True
 
     def checkMetric(self, content, name, expectedType, expectedValue, expectedLabels=""):
         typeFound = False