2323from time import sleep
2424from typing import Type
2525
26+ from vyos import ConfigError
2627from vyos .configsession import ConfigSession
2728from vyos .configsession import ConfigSessionError
28- from vyos import ConfigError
2929from vyos .defaults import commit_lock
30+ from vyos .frrender import mgmt_daemon
3031from vyos .utils .process import cmd
32+ from vyos .utils .process import process_named_running
3133from vyos .utils .process import run
3234
3335save_config = '/tmp/vyos-smoketest-save'
4244
4345class VyOSUnitTestSHIM :
4446 class TestCase (unittest .TestCase ):
45- # if enabled in derived class, print out each and every set/del command
46- # on the CLI. This is usefull to grap all the commands required to
47- # trigger the certain failure condition.
48- # Use "self.debug = True" in derived classes setUp() method
47+ # If enabled, print out each and every set/del command on stdout.
48+ # This is usefull to grap all the commands required to trigger the
49+ # certain failure condition.
4950 debug = False
51+ mgmt_daemon_pid = 0
5052
5153 @staticmethod
5254 def debug_on ():
@@ -68,7 +70,10 @@ def setUpClass(cls):
6870 cls ._session = ConfigSession (os .getpid ())
6971 cls ._session .save_config (save_config )
7072 cls .debug = cls .debug_on ()
71- pass
73+
74+ # Retrieve FRR mgmtd daemon PID - it is not allowed to crash, thus
75+ # PID must remain the same
76+ cls .mgmt_daemon_pid = process_named_running (mgmt_daemon )
7277
7378 @classmethod
7479 def tearDownClass (cls ):
@@ -83,6 +88,13 @@ def tearDownClass(cls):
8388 cls ._session .discard ()
8489 cls .fail (cls )
8590
91+ def setUp (self ):
92+ pass
93+
94+ def tearDown (self ):
95+ # check process health and continuity
96+ self .assertEqual (self .mgmt_daemon_pid , process_named_running (mgmt_daemon ))
97+
8698 def cli_set (self , path , value = None ):
8799 if self .debug :
88100 str = f'set { " " .join (path )} { value } ' if value else f'set { " " .join (path )} '
0 commit comments