summaryrefslogtreecommitdiff
path: root/smoketest/scripts/cli/test_service_tftp-server.py
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-03-17 19:12:04 +0100
committerChristian Poessinger <christian@poessinger.com>2021-03-17 19:18:17 +0100
commit0f3def974fbaa4a26e6ad590ee37dd965bc2358f (patch)
tree36cc09af1fefbc3f6a4f6ad7b946d00baaecb703 /smoketest/scripts/cli/test_service_tftp-server.py
parent42d3cfbd3ee893ec567582a04467a899191f44fd (diff)
downloadvyos-1x-0f3def974fbaa4a26e6ad590ee37dd965bc2358f.tar.gz
vyos-1x-0f3def974fbaa4a26e6ad590ee37dd965bc2358f.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.
Diffstat (limited to 'smoketest/scripts/cli/test_service_tftp-server.py')
-rwxr-xr-xsmoketest/scripts/cli/test_service_tftp-server.py33
1 files changed, 15 insertions, 18 deletions
diff --git a/smoketest/scripts/cli/test_service_tftp-server.py b/smoketest/scripts/cli/test_service_tftp-server.py
index 82e5811ff..aed4c6beb 100755
--- a/smoketest/scripts/cli/test_service_tftp-server.py
+++ b/smoketest/scripts/cli/test_service_tftp-server.py
@@ -14,11 +14,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
-import re
-import os
import unittest
from psutil import process_iter
+from base_vyostest_shim import VyOSUnitTestSHIM
from vyos.configsession import ConfigSession
from vyos.configsession import ConfigSessionError
@@ -32,28 +31,26 @@ dummy_if_path = ['interfaces', 'dummy', 'dum69']
address_ipv4 = '192.0.2.1'
address_ipv6 = '2001:db8::1'
-class TestServiceTFTPD(unittest.TestCase):
+class TestServiceTFTPD(VyOSUnitTestSHIM.TestCase):
def setUp(self):
- self.session = ConfigSession(os.getpid())
- self.session.set(dummy_if_path + ['address', address_ipv4 + '/32'])
- self.session.set(dummy_if_path + ['address', address_ipv6 + '/128'])
+ self.cli_set(dummy_if_path + ['address', address_ipv4 + '/32'])
+ self.cli_set(dummy_if_path + ['address', address_ipv6 + '/128'])
def tearDown(self):
- self.session.delete(base_path)
- self.session.delete(dummy_if_path)
- self.session.commit()
- del self.session
+ self.cli_delete(base_path)
+ self.cli_delete(dummy_if_path)
+ self.cli_commit()
def test_01_tftpd_single(self):
directory = '/tmp'
port = '69' # default port
- self.session.set(base_path + ['allow-upload'])
- self.session.set(base_path + ['directory', directory])
- self.session.set(base_path + ['listen-address', address_ipv4])
+ self.cli_set(base_path + ['allow-upload'])
+ self.cli_set(base_path + ['directory', directory])
+ self.cli_set(base_path + ['listen-address', address_ipv4])
# commit changes
- self.session.commit()
+ self.cli_commit()
config = read_file('/etc/default/tftpd0')
# verify listen IP address
@@ -71,13 +68,13 @@ class TestServiceTFTPD(unittest.TestCase):
address = [address_ipv4, address_ipv6]
port = '70'
- self.session.set(base_path + ['directory', directory])
+ self.cli_set(base_path + ['directory', directory])
for addr in address:
- self.session.set(base_path + ['listen-address', addr])
- self.session.set(base_path + ['port', port])
+ self.cli_set(base_path + ['listen-address', addr])
+ self.cli_set(base_path + ['port', port])
# commit changes
- self.session.commit()
+ self.cli_commit()
for idx in range(0, len(address)):
config = read_file(f'/etc/default/tftpd{idx}')