summaryrefslogtreecommitdiff
path: root/scripts/cli
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/cli')
-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()