From 942a224eae08e68fda403f3caba1dab4b006b894 Mon Sep 17 00:00:00 2001 From: Mark Stapp Date: Tue, 25 Aug 2020 10:52:17 -0400 Subject: [PATCH] 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 --- tests/topotests/lib/topogen.py | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/tests/topotests/lib/topogen.py b/tests/topotests/lib/topogen.py index 37b9715010..a6cc5280ec 100644 --- a/tests/topotests/lib/topogen.py +++ b/tests/topotests/lib/topogen.py @@ -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) -- 2.39.5