]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: make the chain test more reliable by using TCP 15270/head
authorOtto Moerbeek <otto@drijf.net>
Mon, 10 Mar 2025 10:16:39 +0000 (11:16 +0100)
committerOtto Moerbeek <otto@drijf.net>
Mon, 10 Mar 2025 11:16:08 +0000 (12:16 +0100)
UDP is more or less kaput on GitHub, even for the local interface. If
this works on GH as expected/hoped for, we have more strict consistency
checks.

regression-tests.recursor-dnssec/recursortests.py
regression-tests.recursor-dnssec/test_Chain.py

index 6ca75e2dc383828d6572cc8ef14d7137cc29e79b..f8aada98ed66dc6ddfee6896ca4d4df6fa107340 100644 (file)
@@ -1234,8 +1234,8 @@ distributor-threads={threads}""".format(confdir=confdir,
                 if entry['name'] == key:
                     value = int(entry['value'])
                     if callable(expected):
-                        self.assertTrue(expected(value))
+                        self.assertTrue(expected(value), key + ": value " + str(value) + " is not expected")
                     else:
-                        self.assertEqual(value, expected)
+                        self.assertEqual(value, expected, key + ": value " + str(value) + " is not expected")
                     count += 1
         self.assertEqual(count, len(map))
index 3c20da0fc75897b55fbd68cd6671d389b923c454..d98fdad4c55331ca0aa1f0c9cf242856ec1572ba 100644 (file)
@@ -8,6 +8,7 @@ class ChainTest(RecursorTest):
     """
     These regression tests test the chaining of outgoing requests.
     """
+    _chainSize = 200
     _confdir = 'Chain'
     _wsPort = 8042
     _wsTimeout = 2
@@ -22,35 +23,36 @@ class ChainTest(RecursorTest):
     webserver-address=127.0.0.1
     webserver-password=%s
     api-key=%s
-""" % (_wsPort, _wsPassword, _apiKey)
+    max-concurrent-requests-per-tcp-connection=%s
+""" % (_wsPort, _wsPassword, _apiKey, _chainSize)
 
-    @pytest.mark.unreliable_on_gh
+    # @pytest.mark.unreliable_on_gh Not any more?
     def testBasic(self):
         """
-        Tests the case of #14624. Sending many equal requests could lead to ServFail because of clashing
-        waiter ids.
+        Tests the case of #14624. Sending many equal requests could lead to ServFail because of
+        clashing waiter ids.
         """
-        # We actually do not check all responses, as experience show that packets may be dropped by the OS
-        # Instead, we check if a few counters in rec have the expected values.
-        count = 200
+        count = self._chainSize
         name = '9.delay1.example.'
         exp = dns.rrset.from_text(name, 0, dns.rdataclass.IN, 'TXT', 'a')
+        queries = []
         for i in range(count):
             query = dns.message.make_query(name, 'TXT', want_dnssec=True)
             query.flags |= dns.flags.AD
-            self._sock.send(query.to_wire())
+            queries.append(query)
 
-        # Just check one, as OS emptying of socket buffers can work against us
-        data = self._sock.recv(4096)
-        res = dns.message.from_wire(data)
-        self.assertRcodeEqual(res, dns.rcode.NOERROR)
-        self.assertMessageIsAuthenticated(res)
-        self.assertRRsetInAnswer(res, exp)
-        self.assertMatchingRRSIGInAnswer(res, exp)
-        time.sleep(1)
+        answers = self.sendTCPQueries(queries)
+        self.assertEqual(len(answers), count)
+
+        for i in range(count):
+            res = answers[i]
+            self.assertRcodeEqual(res, dns.rcode.NOERROR)
+            self.assertMessageIsAuthenticated(res)
+            self.assertRRsetInAnswer(res, exp)
+            self.assertMatchingRRSIGInAnswer(res, exp)
 
         self.checkMetrics({
-            'max-chain-length': (lambda x: x <= count-1), # first request has count - 1 requests chained to it
+            'max-chain-length': count - 1, # first request has count - 1 requests chained to it
             'servfail-answers': 0,
-            'noerror-answers': (lambda x: x <= count),
+            'noerror-answers': count,
         })