def killProcess(cls, p):
# Don't try to kill it if it's already dead
if p.poll() is not None:
- return
+ return p
try:
p.terminate()
for count in range(100): # tsan can be slow
cls.killProcess(auth);
@classmethod
- def tearDownRecursor(cls):
- p = cls.killProcess(cls._recursor)
+ 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)
+ 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))
+ # Wait for it, as the process really should have exited
+ p = cls._recursor
+ for count in range(100): # tsan can be slow
+ if p.poll() is not None:
+ break;
+ time.sleep(0.1)
+ if p.poll() is None:
+ raise AssertionError('Process did not exit on request within 10s')
if p.returncode not in (0, -15):
raise AssertionError('Process exited with return code %d' % (p.returncode))
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
@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)
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
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: