diff options
| author | Christian Breunig <christian@breunig.cc> | 2025-10-20 18:52:10 +0200 |
|---|---|---|
| committer | Christian Breunig <christian@breunig.cc> | 2025-10-21 21:03:16 +0200 |
| commit | 4995a58f998d3bdd055e49e919945bc0aa939be4 (patch) | |
| tree | e067681c524a9a9bc25f297731da6d837356193e /smoketest/scripts/cli/test_configd_init.py | |
| parent | 9e1cb14a5eb1eedd1fce67732ad84f6528e30314 (diff) | |
| download | vyos-1x-4995a58f998d3bdd055e49e919945bc0aa939be4.tar.gz vyos-1x-4995a58f998d3bdd055e49e919945bc0aa939be4.zip | |
T7948: always call setUp() and tearDown() base class methods
While working on task T7664 (FRR 10.4 upgrade), I identified the need for
additional validation and safeguards around the FRR management daemon. The
most appropriate place for this logic is in the setUp() and tearDown() methods
of the smoketest base class, VyOSUnitTestSHIM.
However, during implementation, it became apparent that test cases do not
consistently invoke the base class's setup and teardown methods. This
inconsistency complicates the process of capturing the FRR mgmtd PID at the
start of a test and verifying that it remains unchanged by the end - a key step
in detecting crashes or unexpected terminations (e.g., SIGSEGV) of the FRR
management daemon during tests.
Diffstat (limited to 'smoketest/scripts/cli/test_configd_init.py')
| -rwxr-xr-x | smoketest/scripts/cli/test_configd_init.py | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/smoketest/scripts/cli/test_configd_init.py b/smoketest/scripts/cli/test_configd_init.py index c367736fc..cf9d40b94 100755 --- a/smoketest/scripts/cli/test_configd_init.py +++ b/smoketest/scripts/cli/test_configd_init.py @@ -22,20 +22,26 @@ from base_vyostest_shim import VyOSUnitTestSHIM from vyos.utils.process import is_systemd_service_running from vyos.utils.process import cmd +service_name = 'vyos-configd.service' + class TestConfigdInit(unittest.TestCase): def setUp(self): - self.running_state = is_systemd_service_running('vyos-configd.service') + self.running_state = is_systemd_service_running(service_name) + # always forward to base class + super().setUp() + + def tearDown(self): + if not self.running_state: + cmd(f'sudo systemctl stop {service_name}') + # always forward to base class + super().tearDown() def test_configd_init(self): if not self.running_state: - cmd('sudo systemctl start vyos-configd.service') + cmd(f'sudo systemctl start {service_name}') # allow time for init to succeed/fail sleep(2) - self.assertTrue(is_systemd_service_running('vyos-configd.service')) - - def tearDown(self): - if not self.running_state: - cmd('sudo systemctl stop vyos-configd.service') + self.assertTrue(is_systemd_service_running(service_name)) if __name__ == '__main__': unittest.main(verbosity=2, failfast=VyOSUnitTestSHIM.TestCase.debug_on()) |
