]> git.proxmox.com Git - mirror_frr.git/commitdiff
tests: fix router stop logic
authorMark Stapp <mjs@voltanet.io>
Tue, 25 Aug 2020 14:52:17 +0000 (10:52 -0400)
committerMark Stapp <mjs@voltanet.io>
Tue, 25 Aug 2020 14:52:17 +0000 (10:52 -0400)
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>
tests/topotests/lib/topogen.py

index 37b97150106581ed520fcf99edd97e1490414f1b..a6cc5280ece0b37362a379b4aa038ff9cee4dbea 100644 (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)