tests: fix router stop logic

Change the public router stop method to always do a two-phase
shutdown - once without waiting and a second time with a wait.
Ordinary callers need to use this approach when stopping routers.
Move the detailed internal details to a private method that tests
should not call directly.

Signed-off-by: Mark Stapp <mjs@voltanet.io>
This commit is contained in:
Mark Stapp 2020-08-25 10:52:17 -04:00
parent a85a3d1ef9
commit 942a224eae

View File

@ -335,9 +335,7 @@ class Topogen(object):
logger.info("stopping topology: {}".format(self.modname))
errors = ""
for gear in self.gears.values():
gear.stop(False, False)
for gear in self.gears.values():
errors += gear.stop(True, False)
errors += gear.stop()
if len(errors) > 0:
assert "Errors found post shutdown - details follow:" == 0, errors
@ -703,14 +701,26 @@ class TopoRouter(TopoGear):
return result
def stop(self, wait=True, assertOnError=True):
def __stop_internal(self, wait=True, assertOnError=True):
"""
Stop router:
Stop router, private internal version
* Kill daemons
"""
self.logger.debug("stopping")
self.logger.debug("stopping: wait {}, assert {}".format(
wait, assertOnError))
return self.tgen.net[self.name].stopRouter(wait, assertOnError)
def stop(self):
"""
Stop router cleanly:
* Signal daemons twice, once without waiting, and then a second time
with a wait to ensure the daemons exit cleanly
"""
self.logger.debug("stopping")
self.__stop_internal(False, False)
return self.__stop_internal()
def startDaemons(self, daemons):
"""
Start Daemons: to start specific daemon(user defined daemon only)
@ -819,8 +829,7 @@ class TopoRouter(TopoGear):
if memleak_file is None:
return
self.stop(False, False)
self.stop(wait=True)
self.stop()
self.logger.info("running memory leak report")
self.tgen.net[self.name].report_memory_leaks(memleak_file, testname)