diff options
author | Christian Poessinger <christian@poessinger.com> | 2021-03-17 19:12:04 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2021-07-25 21:10:25 +0200 |
commit | fb94d0b6091e09099c972355886918ef63ee9d97 (patch) | |
tree | 3f9d9c09f12d328bac4e79fab697dd19a294f055 /smoketest/scripts/cli/test_policy_local-route.py | |
parent | c114e1904571ff3c323a9068d8b3784d9a238d0a (diff) | |
download | vyos-1x-fb94d0b6091e09099c972355886918ef63ee9d97.tar.gz vyos-1x-fb94d0b6091e09099c972355886918ef63ee9d97.zip |
smoketest: add shim for every test to re-use common tasts
Currently every smoketest does the setup and destruction of the configsession
on its own durin setUp(). This creates a lot of overhead and one configsession
should be re-used during execution of every smoketest script.
In addiion a test that failed will leaf the system in an unconsistent state.
For this reason before the test is executed we will save the running config
to /tmp and the will re-load the config after the test has passed, always
ensuring a clean environment for the next test.
(cherry picked from commit 0f3def974fbaa4a26e6ad590ee37dd965bc2358f)
Diffstat (limited to 'smoketest/scripts/cli/test_policy_local-route.py')
-rwxr-xr-x | smoketest/scripts/cli/test_policy_local-route.py | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/smoketest/scripts/cli/test_policy_local-route.py b/smoketest/scripts/cli/test_policy_local-route.py index de1882a65..c742a930b 100755 --- a/smoketest/scripts/cli/test_policy_local-route.py +++ b/smoketest/scripts/cli/test_policy_local-route.py @@ -17,21 +17,24 @@ import os import unittest +from base_vyostest_shim import VyOSUnitTestSHIM + from vyos.configsession import ConfigSession from vyos.configsession import ConfigSessionError from vyos.util import cmd from vyos.util import process_named_running -class PolicyLocalRouteTest(unittest.TestCase): - def setUp(self): - self.session = ConfigSession(os.getpid()) - self._sources = ['203.0.113.1', '203.0.113.2'] +class PolicyLocalRouteTest(VyOSUnitTestSHIM.TestCase): + @classmethod + def setUpClass(cls): + cls._sources = ['203.0.113.1', '203.0.113.2'] + # call base-classes classmethod + super(cls, cls).setUpClass() def tearDown(self): # Delete all policies - self.session.delete(['policy', 'local-route']) - self.session.commit() - del self.session + self.cli_delete(['policy', 'local-route']) + self.cli_commit() # Test set table for some sources def test_table_id(self): @@ -39,10 +42,10 @@ class PolicyLocalRouteTest(unittest.TestCase): rule = '50' table = '23' for src in self._sources: - self.session.set(base + ['rule', rule, 'set', 'table', table]) - self.session.set(base + ['rule', rule, 'source', src]) + self.cli_set(base + ['rule', rule, 'set', 'table', table]) + self.cli_set(base + ['rule', rule, 'source', src]) - self.session.commit() + self.cli_commit() # Check generated configuration |