From e7246d1eb9eedeca0a1bce02b9c6c3bd29e2c29f Mon Sep 17 00:00:00 2001 From: Otto Date: Mon, 29 Nov 2021 10:56:23 +0100 Subject: [PATCH] Wait until outgoing requests stabilizes before starting tests, rec might stil be busy resolving hints. --- .../test_RootNXTrust.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/regression-tests.recursor-dnssec/test_RootNXTrust.py b/regression-tests.recursor-dnssec/test_RootNXTrust.py index b3b6521455..372afa01eb 100644 --- a/regression-tests.recursor-dnssec/test_RootNXTrust.py +++ b/regression-tests.recursor-dnssec/test_RootNXTrust.py @@ -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') -- 2.47.2