]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Wait until outgoing requests stabilizes before starting tests, rec might stil be...
authorOtto <otto.moerbeek@open-xchange.com>
Mon, 29 Nov 2021 09:56:23 +0000 (10:56 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Tue, 30 Nov 2021 09:56:41 +0000 (10:56 +0100)
regression-tests.recursor-dnssec/test_RootNXTrust.py

index b3b6521455b470d5210f543a3f458282354e4365..372afa01ebb7a0f23e62f54abd74fa6993cc6228 100644 (file)
@@ -1,6 +1,7 @@
 import dns
 import requests
 import socket
+import time
 from recursortests import RecursorTest
 
 class RootNXTrustRecursorTest(RecursorTest):
@@ -19,6 +20,17 @@ class RootNXTrustRecursorTest(RecursorTest):
 
         return 0
 
+    # Recursor can still be busy resolving root hints, so wait a bit until
+    # getOutgoingQueriesCount() stabilizes.
+    # Code below is inherently racey, but better than a fixed sleep
+    def waitForOutgoingToStabilize(self):
+        for count in range(20):
+            outgoing1 = self.getOutgoingQueriesCount();
+            time.sleep(0.1);
+            outgoing2 = self.getOutgoingQueriesCount();
+            if outgoing1 == outgoing2:
+                break
+
 class testRootNXTrustDisabled(RootNXTrustRecursorTest):
     _confdir = 'RootNXTrustDisabled'
     _wsPort = 8042
@@ -42,7 +54,8 @@ api-key=%s
         after receiving a NXD from "." for nx-example. as an answer for www.nx-example.
         """
 
-        # first query nx.example.
+        self.waitForOutgoingToStabilize()
+        # First query nx.example.
         before = self.getOutgoingQueriesCount()
         query = dns.message.make_query('www.nx-example.', 'A')
         res = self.sendUDPQuery(query)
@@ -88,6 +101,7 @@ api-key=%s
         after receiving a NXD from "." for nx-example. as an answer for www.nx-example.
         """
 
+        self.waitForOutgoingToStabilize()
         # first query nx.example.
         before = self.getOutgoingQueriesCount()
         query = dns.message.make_query('www.nx-example.', 'A')