summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThomas Mangin <thomas.mangin@exa.net.uk>2020-03-22 20:55:19 +0000
committerThomas Mangin <thomas.mangin@exa.net.uk>2020-03-22 20:55:19 +0000
commit442dd75b3635428824f1e0921846b0a2a7012b14 (patch)
tree5142729efef58d4604a639082b47c8b235e92417 /scripts
parentfc44f25ea39deff5953933e821fb9d47cd6c603a (diff)
downloadvyos-1x-442dd75b3635428824f1e0921846b0a2a7012b14.tar.gz
vyos-1x-442dd75b3635428824f1e0921846b0a2a7012b14.zip
vxlan: add basic testing
Diffstat (limited to 'scripts')
-rw-r--r--scripts/cli/base_interfaces_test.py14
-rw-r--r--scripts/cli/test_interfaces_vxlan.py37
2 files changed, 51 insertions, 0 deletions
diff --git a/scripts/cli/base_interfaces_test.py b/scripts/cli/base_interfaces_test.py
index 11a7031ef..9fa0fb49e 100644
--- a/scripts/cli/base_interfaces_test.py
+++ b/scripts/cli/base_interfaces_test.py
@@ -22,12 +22,18 @@ from vyos.interfaces import list_interfaces_of_type
class BasicInterfaceTest:
class BaseTest(unittest.TestCase):
+ _test_mtu = False
+ _base_path = []
+ _options = {}
+ _interfaces = []
+
def setUp(self):
self.session = ConfigSession(os.getpid())
self._test_addr = ['192.0.2.1/26', '192.0.2.255/31', '192.0.2.64/32',
'2001:db8:1::ffff/64', '2001:db8:101::1/112']
self._test_mtu = False
+ self._options = {}
def tearDown(self):
# we should not remove ethernet from the overall CLI
@@ -48,6 +54,9 @@ class BasicInterfaceTest:
for intf in self._interfaces:
test_string='Description-Test-{}'.format(intf)
self.session.set(self._base_path + [intf, 'description', test_string])
+ for option in self._options.get(intf, []):
+ self.session.set(self._base_path + [intf] + option.split())
+
self.session.commit()
# Validate interface description
@@ -66,6 +75,9 @@ class BasicInterfaceTest:
for intf in self._interfaces:
for addr in self._test_addr:
self.session.set(self._base_path + [intf, 'address', addr])
+ for option in self._options.get(intf, []):
+ self.session.set(self._base_path + [intf] + option.split())
+
self.session.commit()
# Validate address
@@ -91,6 +103,8 @@ class BasicInterfaceTest:
mtu = '1400'
for intf in self._interfaces:
self.session.set(self._base_path + [intf, 'mtu', mtu])
+ for option in self._options.get(intf, []):
+ self.session.set(self._base_path + [intf] + option.split())
self.session.commit()
diff --git a/scripts/cli/test_interfaces_vxlan.py b/scripts/cli/test_interfaces_vxlan.py
new file mode 100644
index 000000000..dc5502838
--- /dev/null
+++ b/scripts/cli/test_interfaces_vxlan.py
@@ -0,0 +1,37 @@
+#!/usr/bin/env python3
+#
+# Copyright (C) 2020 VyOS maintainers and contributors
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 or later as
+# published by the Free Software Foundation.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# 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 os
+import unittest
+
+from vyos.configsession import ConfigSession, ConfigSessionError
+from base_interfaces_test import BasicInterfaceTest
+
+
+class VXLANInterfaceTest(BasicInterfaceTest.BaseTest):
+ def setUp(self):
+ super().setUp()
+
+ self._test_mtu = True
+ self._base_path = ['interfaces', 'vxlan']
+ self._options = {
+ 'vxlan0': ['vni 10', 'remote 127.0.0.2'],
+ 'vxlan1': ['vni 20', 'group 239.1.1.1', 'link eth0'],
+ }
+ self._interfaces = list(self._options)
+
+if __name__ == '__main__':
+ unittest.main()