From: Otto Moerbeek Date: Mon, 24 Mar 2025 11:58:14 +0000 (+0100) Subject: Fix regression tests X-Git-Tag: rec-5.4.0-alpha1~279^2~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cb6a7d527d198744740ccb63f474f792b8d45cfa;p=thirdparty%2Fpdns.git Fix regression tests --- diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index 6c008be018..531a1ac3dd 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -5480,7 +5480,7 @@ bool SyncRes::doResolveAtThisIP(const std::string& prefix, const DNSName& qname, LOG(prefix << qname << ": Answer has no ECS, trying again without EDNS Client Subnet Mask" << endl); updateQueryCounts(prefix, qname, remoteIP, doTCP, doDoT); match = d_eventTrace.add(RecEventTrace::AuthRequest, qname.toLogString() + '/' + qtype.toString(), true, 0); - resolveret = asyncresolveWrapper(remoteIP, d_doDNSSEC, qname, auth, qtype.getCode(), + resolveret = asyncresolveWrapper(LogObject(prefix), remoteIP, d_doDNSSEC, qname, auth, qtype.getCode(), doTCP, sendRDQuery, &d_now, ednsmask, &lwr, &chained, nsName); // <- we go out on the wire! d_eventTrace.add(RecEventTrace::AuthRequest, static_cast(lwr.d_rcode), false, match); } diff --git a/regression-tests.recursor-dnssec/recursortests.py b/regression-tests.recursor-dnssec/recursortests.py index 3b4d3c71e0..5314e2c7b2 100644 --- a/regression-tests.recursor-dnssec/recursortests.py +++ b/regression-tests.recursor-dnssec/recursortests.py @@ -445,6 +445,8 @@ PrivateKey: Ep9uo6+wwjb4MaOmqq7LHav2FLrjotVOeZg8JT1Qk04= # 22: test_EDNSBuffer.py # 23: test_Lua.py # 24: test_RoutingTag.py + # 25: test_Cookies.py + # 26: test_Cookies.py _auth_cmd = ['authbind', os.environ['PDNS']] diff --git a/regression-tests.recursor-dnssec/test_Cookies.py b/regression-tests.recursor-dnssec/test_Cookies.py index 6ec7467912..490f5a31d1 100644 --- a/regression-tests.recursor-dnssec/test_Cookies.py +++ b/regression-tests.recursor-dnssec/test_Cookies.py @@ -2,14 +2,19 @@ import dns import socket import os import time -import threading + from twisted.internet.protocol import Factory from twisted.internet.protocol import Protocol from twisted.internet.protocol import DatagramProtocol from twisted.internet import reactor +import clientsubnetoption +import cookiesoption + from recursortests import RecursorTest +cookieReactorRunning = False + class CookiesTest(RecursorTest): _confdir = 'Cookies' _config_template = """ @@ -45,21 +50,21 @@ outgoing: @classmethod def startResponders(cls): + global cookieReactorRunning print("Launching responders..") address1 = cls._PREFIX + '.25' address2 = cls._PREFIX + '.26' port = 53 - reactor.listenUDP(port, UDPResponder(), interface=address1) - reactor.listenTCP(port, TCPFactory(), interface=address1) - reactor.listenUDP(port, UDPResponder(), interface=address2) - reactor.listenTCP(port, TCPFactory(), interface=address2) + if not cookieReactorRunning: + reactor.listenUDP(port, UDPResponder(), interface=address1) + reactor.listenTCP(port, TCPFactory(), interface=address1) + reactor.listenUDP(port, UDPResponder(), interface=address2) + reactor.listenTCP(port, TCPFactory(), interface=address2) + cookieReactorRunning = True - if not reactor.running: - cls.Responder = threading.Thread(name='Responder', target=reactor.run, args=(False,)) - cls.Responder.daemon = True - cls.Responder.start() + cls.startReactor() def checkCookies(self, support, server='127.0.0.25'): confdir = os.path.join('configs', self._confdir) @@ -140,8 +145,11 @@ outgoing: class UDPResponder(DatagramProtocol): def getCookie(self, message): for option in message.options: - if option.otype == dns.edns.COOKIE: #and isinstance(option, dns.edns.CookieOption): - return option.data + if option.otype == dns.edns.COOKIE and isinstance(option, cookiesoption.CookiesOption): + data = option.client + if option.server is not None: + data += option.server + return data return None def createCookie(self, clientcookie): diff --git a/regression-tests.recursor-dnssec/test_EDNSBufferSize.py b/regression-tests.recursor-dnssec/test_EDNSBufferSize.py index 34c31d4b45..319c3866aa 100644 --- a/regression-tests.recursor-dnssec/test_EDNSBufferSize.py +++ b/regression-tests.recursor-dnssec/test_EDNSBufferSize.py @@ -65,11 +65,7 @@ edns-outgoing-bufsize=%d reactor.listenUDP(port, UDPLargeResponder(), interface=address) ednsBufferReactorRunning = True - if not reactor.running: - cls._UDPResponder = threading.Thread( - name='UDP Responder', target=reactor.run, args=(False,)) - cls._UDPResponder.setDaemon(True) - cls._UDPResponder.start() + cls.startReactor() def getMessage(self, testnum, payload=0): do_edns = payload > 0 diff --git a/regression-tests.recursor-dnssec/test_Interop.py b/regression-tests.recursor-dnssec/test_Interop.py index 33800beee9..aa3d5125e7 100644 --- a/regression-tests.recursor-dnssec/test_Interop.py +++ b/regression-tests.recursor-dnssec/test_Interop.py @@ -147,10 +147,7 @@ forward-zones+=undelegated.insecure.example=%s.12 reactor.listenUDP(port, UDPResponder(), interface=address) - if not reactor.running: - cls._UDPResponder = threading.Thread(name='UDP Responder', target=reactor.run, args=(False,)) - cls._UDPResponder.setDaemon(True) - cls._UDPResponder.start() + cls.startReactor() class InteropProcessTest(RecursorTest): _confdir = 'InteropProcess' diff --git a/regression-tests.recursor-dnssec/test_Lua.py b/regression-tests.recursor-dnssec/test_Lua.py index 4079944907..57fbe0a465 100644 --- a/regression-tests.recursor-dnssec/test_Lua.py +++ b/regression-tests.recursor-dnssec/test_Lua.py @@ -338,10 +338,7 @@ quiet=no reactor.listenUDP(port, UDPHooksResponder(), interface=address) hooksReactorRunning = True - if not reactor.running: - cls._UDPResponder = threading.Thread(name='UDP Hooks Responder', target=reactor.run, args=(False,)) - cls._UDPResponder.setDaemon(True) - cls._UDPResponder.start() + cls.startReactor() def testNoData(self): expected = dns.rrset.from_text('nodata.luahooks.example.', 3600, dns.rdataclass.IN, 'AAAA', '2001:DB8::1') diff --git a/regression-tests.recursor-dnssec/test_RoutingTag.py b/regression-tests.recursor-dnssec/test_RoutingTag.py index 9f0631b582..24ddd5fa6d 100644 --- a/regression-tests.recursor-dnssec/test_RoutingTag.py +++ b/regression-tests.recursor-dnssec/test_RoutingTag.py @@ -81,10 +81,7 @@ ecs-add-for=0.0.0.0/0 reactor.listenUDP(port, UDPRoutingResponder(), interface=address) routingReactorRunning = True - if not reactor.running: - cls._UDPResponder = threading.Thread(name='UDP Routing Responder', target=reactor.run, args=(False,)) - cls._UDPResponder.setDaemon(True) - cls._UDPResponder.start() + cls.startReactor() @classmethod def tearDownClass(cls): diff --git a/regression-tests.recursor-dnssec/test_SimpleCookies.py b/regression-tests.recursor-dnssec/test_SimpleCookies.py index d6a7ccb8ee..a6f0004e73 100644 --- a/regression-tests.recursor-dnssec/test_SimpleCookies.py +++ b/regression-tests.recursor-dnssec/test_SimpleCookies.py @@ -4,6 +4,7 @@ from recursortests import RecursorTest class SimpleCookiesTest(RecursorTest): _confdir = 'SimpleCookies' + _auth_zones = RecursorTest._default_auth_zones _config_template = """ recursor: @@ -15,7 +16,7 @@ dnssec: outgoing: cookies: true""" % _confdir - _expectedCookies = 'no' + _expectedCookies = 'Unsupported' @classmethod def generateRecursorConfig(cls, confdir): authzonepath = os.path.join(confdir, 'authzone.zone') @@ -134,7 +135,8 @@ outgoing: class SimpleCookiesAuthEnabledTest(SimpleCookiesTest): _confdir = 'SimpleCookiesAuthEnabled' - _expectedCookies = 'yes' + _auth_zones = SimpleCookiesTest._auth_zones + _expectedCookies = 'Supported' @classmethod def generateAuthConfig(cls, confdir, threads):