diff --git a/regression-tests.recursor-dnssec/recursortests.py b/regression-tests.recursor-dnssec/recursortests.py index 284b94255291..a04d78a17d4a 100644 --- a/regression-tests.recursor-dnssec/recursortests.py +++ b/regression-tests.recursor-dnssec/recursortests.py @@ -791,10 +791,22 @@ def tearDownAuth(cls): cls.killProcess(auth); @classmethod - def tearDownRecursor(cls): - p = cls.killProcess(cls._recursor) - if p.returncode not in (0, -15): - raise AssertionError('Process exited with return code %d' % (p.returncode)) + def tearDownRecursor(cls, subdir=None): + # We now kill the recursor in a friendly way, as systemd is doing the same. + if subdir is None: + confdir = os.path.join('configs', cls._confdir) + else: + confdir = os.path.join('configs', cls._confdir, subdir) + dirlist = os.listdir(confdir) + print(dirlist) + rec_controlCmd = [os.environ['RECCONTROL'], + '--config-dir=%s' % confdir, + '--timeout=20', + 'quit-nicely'] + try: + subprocess.check_output(rec_controlCmd, stderr=subprocess.STDOUT) + except subprocess.CalledProcessError as e: + raise AssertionError('%s failed (%d): %s' % (rec_controlCmd, e.returncode, e.output)) @classmethod def sendUDPQuery(cls, query, timeout=2.0, decode=True, fwparams=dict()): diff --git a/regression-tests.recursor-dnssec/runtests b/regression-tests.recursor-dnssec/runtests index 3543dd2b79c5..0553e0747407 100755 --- a/regression-tests.recursor-dnssec/runtests +++ b/regression-tests.recursor-dnssec/runtests @@ -3,6 +3,9 @@ if pgrep pdns_server; then echo 'There are (stray?) pdns_servers running that might interfere with these tests!' fi +if pgrep pdns_recursor; then + echo 'There are (stray?) pdns_recursors running that might interfere with these tests!' +fi export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python diff --git a/regression-tests.recursor-dnssec/test_Flags.py b/regression-tests.recursor-dnssec/test_Flags.py index 702d44de1d97..da6d46eb5dbb 100644 --- a/regression-tests.recursor-dnssec/test_Flags.py +++ b/regression-tests.recursor-dnssec/test_Flags.py @@ -72,9 +72,9 @@ def sendUDPQuery(cls, query, dnssec_setting, timeout=2.0): @classmethod def tearDownClass(cls): cls.tearDownAuth() - for _, recursor in cls._recursors.items(): + for subdir, recursor in cls._recursors.items(): cls._recursor = recursor - cls.tearDownRecursor() + cls.tearDownRecursor(subdir) def getQueryForSecure(self, flags='', ednsflags=''): return self.createQuery('ns1.example.', 'A', flags, ednsflags) diff --git a/regression-tests.recursor-dnssec/test_RecDnstap.py b/regression-tests.recursor-dnssec/test_RecDnstap.py index 025b32c17a8f..c5dd367eda7a 100644 --- a/regression-tests.recursor-dnssec/test_RecDnstap.py +++ b/regression-tests.recursor-dnssec/test_RecDnstap.py @@ -191,10 +191,9 @@ def FrameStreamUnixListener(cls, conn, param): if e.errno in (errno.EBADF, errno.EPIPE): break sys.stderr.write("Unexpected socket error %s\n" % str(e)) - sys.exit(1) - except exception as e: + except Exception as e: sys.stderr.write("Unexpected socket error %s\n" % str(e)) - sys.exit(1) + break conn.close() @classmethod @@ -208,8 +207,7 @@ def FrameStreamUnixListenerMain(cls, param): sock.bind(param.path) sock.listen(100) except socket.error as e: - sys.stderr.write("Error binding/listening in the framestream listener: %s\n" % str(e)) - sys.exit(1) + raise Exception("Error binding/listening in the framestream listener: %s\n" % str(e)) DNSTapListeners.append(sock) while True: try: