_dnsdistStartupDelay = 2.0
_dnsdist = None
_responsesCounter = {}
- _shutUp = True
_config_template = """
"""
_config_params = ['_testServerPort']
cls._TCPResponder.start()
@classmethod
- def startDNSDist(cls, shutUp=True):
+ def startDNSDist(cls):
print("Launching dnsdist..")
- conffile = 'dnsdist_test.conf'
+ confFile = os.path.join('configs', 'dnsdist_%s.conf' % (cls.__name__))
params = tuple([getattr(cls, param) for param in cls._config_params])
print(params)
- with open(conffile, 'w') as conf:
+ with open(confFile, 'w') as conf:
conf.write("-- Autogenerated by dnsdisttests.py\n")
conf.write(cls._config_template % params)
- dnsdistcmd = [os.environ['DNSDISTBIN'], '-C', conffile,
+ dnsdistcmd = [os.environ['DNSDISTBIN'], '-C', confFile,
'-l', '%s:%d' % (cls._dnsDistListeningAddr, cls._dnsDistPort) ]
for acl in cls._acl:
dnsdistcmd.extend(['--acl', acl])
output = subprocess.check_output(testcmd, stderr=subprocess.STDOUT, close_fds=True)
except subprocess.CalledProcessError as exc:
raise AssertionError('dnsdist --check-config failed (%d): %s' % (exc.returncode, exc.output))
- if output != b'Configuration \'dnsdist_test.conf\' OK!\n':
+ expectedOutput = ('Configuration \'%s\' OK!\n' % (confFile)).encode()
+ if output != expectedOutput:
raise AssertionError('dnsdist --check-config failed: %s' % output)
- if shutUp:
- with open(os.devnull, 'w') as fdDevNull:
- cls._dnsdist = subprocess.Popen(dnsdistcmd, close_fds=True, stdout=fdDevNull)
- else:
- cls._dnsdist = subprocess.Popen(dnsdistcmd, close_fds=True)
+ logFile = os.path.join('configs', 'dnsdist_%s.log' % (cls.__name__))
+ with open(logFile, 'w') as fdLog:
+ cls._dnsdist = subprocess.Popen(dnsdistcmd, close_fds=True, stdout=fdLog, stderr=fdLog)
if 'DNSDIST_FAST_TESTS' in os.environ:
delay = 0.5
def setUpClass(cls):
cls.startResponders()
- cls.startDNSDist(cls._shutUp)
+ cls.startDNSDist()
cls.setUpSockets()
print("Launching tests..")
protoc -I=../pdns/ --python_out=. ../pdns/dnsmessage.proto
protoc -I=../pdns/ --python_out=. ../pdns/dnstap.proto
+mkdir -p configs
+
if [ -z "${DNSDISTBIN}" ]; then
DNSDISTBIN=$(ls ../pdns/dnsdistdist/dnsdist-*/dnsdist)
fi
# Generate a chain
cat server.pem ca.pem >> server.chain
-nosetests --with-xunit $@
+if ! nosetests --with-xunit $@; then
+ for log in configs/*.log; do
+ echo "=== ${log} ==="
+ cat "${log}"
+ done
+ false
+fi
rm ca.key ca.pem ca.srl server.csr server.key server.pem server.chain