diff options
author | Christian Poessinger <christian@poessinger.com> | 2020-07-17 20:14:38 +0200 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2020-07-17 20:14:38 +0200 |
commit | 9579cc1a7d5bf74d6dfa0f55b198dc8a3bdfcfe1 (patch) | |
tree | 326e42d67eeb57696297782e93dcc534e7d45075 /scripts | |
parent | 1316e493983fd14e2282dfc6b107ddf68b16ed8a (diff) | |
download | vyos-1x-9579cc1a7d5bf74d6dfa0f55b198dc8a3bdfcfe1.tar.gz vyos-1x-9579cc1a7d5bf74d6dfa0f55b198dc8a3bdfcfe1.zip |
vlan: add basic test
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/cli/base_interfaces_test.py | 31 | ||||
-rwxr-xr-x | scripts/cli/test_interfaces_ethernet.py | 1 |
2 files changed, 31 insertions, 1 deletions
diff --git a/scripts/cli/base_interfaces_test.py b/scripts/cli/base_interfaces_test.py index 489871b8b..242f9e44c 100644 --- a/scripts/cli/base_interfaces_test.py +++ b/scripts/cli/base_interfaces_test.py @@ -114,7 +114,7 @@ class BasicInterfaceTest: Check if MTU can be changed on interface. Test MTU size will be 1400 bytes. """ - if self._test_mtu is False: + if not self._test_mtu: return None # choose MTU which works on every interface - 1280 is minimum for IPv6 so @@ -132,3 +132,32 @@ class BasicInterfaceTest: with open('/sys/class/net/{}/mtu'.format(intf), 'r') as f: tmp = f.read().rstrip() self.assertEqual(tmp, mtu) + + + def test_8021q_vlan(self): + if not self._test_vlan: + return None + + vlan_range = ['100', '200', '300', '2000'] + for intf in self._interfaces: + for vlan in vlan_range: + address = '192.0.2.1/24' + # choose MTU which works on every interface - 1280 is minimum for IPv6 so + # it will always work. + mtu = '1280' + + base = self._base_path + [intf, 'vif', vlan] + self.session.set(base + ['address', address]) + self.session.set(base + ['mtu', mtu]) + + self.session.commit() + + # Validate interface description + for intf in self._interfaces: + for vlan in vlan_range: + vif = f'{intf}.{vlan}' + with open(f'/sys/class/net/{vif}/mtu', 'r') as f: + tmp = f.read().rstrip() + self.assertEqual(tmp, mtu) + + self.assertTrue(is_intf_addr_assigned(vif, address)) diff --git a/scripts/cli/test_interfaces_ethernet.py b/scripts/cli/test_interfaces_ethernet.py index 919caab8c..9ca8a7a02 100755 --- a/scripts/cli/test_interfaces_ethernet.py +++ b/scripts/cli/test_interfaces_ethernet.py @@ -26,6 +26,7 @@ class EthernetInterfaceTest(BasicInterfaceTest.BaseTest): self._base_path = ['interfaces', 'ethernet'] self._test_mtu = True + self._test_vlan = True self._interfaces = [] # we need to filter out VLAN interfaces identified by a dot (.) |