From 429896894f1d656efa003e42901a9b98b4523ac9 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Fri, 9 Jan 2026 15:54:11 +0100 Subject: [PATCH] dnsdist: Check for duplicated prometheus line/keys Signed-off-by: Remi Gacogne --- regression-tests.dnsdist/test_Prometheus.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/regression-tests.dnsdist/test_Prometheus.py b/regression-tests.dnsdist/test_Prometheus.py index 57e5cc0657..72c4943846 100644 --- a/regression-tests.dnsdist/test_Prometheus.py +++ b/regression-tests.dnsdist/test_Prometheus.py @@ -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 -- 2.47.3