summaryrefslogtreecommitdiff
path: root/smoketest
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2021-01-16 20:24:53 +0100
committerChristian Poessinger <christian@poessinger.com>2021-01-16 21:34:30 +0100
commitb2b5ea81243f672d3cc3c4082374551f38fd4dde (patch)
treeac8538c79480f6f6236af30c14b8d935ae376979 /smoketest
parentb373d3841608838fd28f98691cb14e42c128c216 (diff)
downloadvyos-1x-b2b5ea81243f672d3cc3c4082374551f38fd4dde.tar.gz
vyos-1x-b2b5ea81243f672d3cc3c4082374551f38fd4dde.zip
smoketest: interfaces: use provided unittest framework assert methods
Diffstat (limited to 'smoketest')
-rw-r--r--smoketest/scripts/cli/base_interfaces_test.py44
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_bonding.py4
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_bridge.py14
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_ethernet.py11
-rwxr-xr-xsmoketest/scripts/cli/test_interfaces_loopback.py5
-rwxr-xr-xsmoketest/scripts/cli/test_vrf.py2
6 files changed, 46 insertions, 34 deletions
diff --git a/smoketest/scripts/cli/base_interfaces_test.py b/smoketest/scripts/cli/base_interfaces_test.py
index 8b25d85e6..6a68bcc26 100644
--- a/smoketest/scripts/cli/base_interfaces_test.py
+++ b/smoketest/scripts/cli/base_interfaces_test.py
@@ -82,26 +82,22 @@ class BasicInterfaceTest:
self.session.set(['interfaces', section, span])
def tearDown(self):
- # Ethernet is handled in its derived class
- if 'ethernet' not in self._base_path:
- self.session.delete(self._base_path)
-
# Tear down mirror interfaces for SPAN (Switch Port Analyzer)
for span in self._mirror_interfaces:
section = Section.section(span)
self.session.delete(['interfaces', section, span])
+ self.session.delete(self._base_path)
self.session.commit()
del self.session
- # Ethernet is handled in its derived class
- if 'ethernet' not in self._base_path:
- for intf in self._interfaces:
- self.assertTrue(intf not in interfaces())
+ # Verify that no previously interface remained on the system
+ for intf in self._interfaces:
+ self.assertNotIn(intf, interfaces())
def test_span_mirror(self):
if not self._mirror_interfaces:
- self.skipTest('not enabled')
+ self.skipTest('not supported')
# Check the two-way mirror rules of ingress and egress
for mirror in self._mirror_interfaces:
@@ -194,7 +190,7 @@ class BasicInterfaceTest:
def test_ipv6_link_local_address(self):
# Common function for IPv6 link-local address assignemnts
if not self._test_ipv6:
- self.skipTest('not enabled')
+ self.skipTest('not supported')
for interface in self._interfaces:
base = self._base_path + [interface]
@@ -221,7 +217,7 @@ class BasicInterfaceTest:
def test_interface_mtu(self):
if not self._test_mtu:
- self.skipTest('not enabled')
+ self.skipTest('not supported')
for intf in self._interfaces:
base = self._base_path + [intf]
@@ -241,7 +237,7 @@ class BasicInterfaceTest:
# Testcase if MTU can be changed to 1200 on non IPv6
# enabled interfaces
if not self._test_mtu:
- self.skipTest('not enabled')
+ self.skipTest('not supported')
old_mtu = self._mtu
self._mtu = '1200'
@@ -264,9 +260,13 @@ class BasicInterfaceTest:
self._mtu = old_mtu
- def test_8021q_vlan_interfaces(self):
+ def test_vif_8021q_interfaces(self):
+ # XXX: This testcase is not allowed to run as first testcase, reason
+ # is the Wireless test will first load the wifi kernel hwsim module
+ # which creates a wlan0 and wlan1 interface which will fail the
+ # tearDown() test in the end that no interface is allowed to survive!
if not self._test_vlan:
- self.skipTest('not enabled')
+ self.skipTest('not supported')
for interface in self._interfaces:
base = self._base_path + [interface]
@@ -292,9 +292,13 @@ class BasicInterfaceTest:
self.assertEqual(Interface(vif).get_admin_state(), 'up')
- def test_8021ad_qinq_vlan_interfaces(self):
+ def test_vif_s_8021ad_vlan_interfaces(self):
+ # XXX: This testcase is not allowed to run as first testcase, reason
+ # is the Wireless test will first load the wifi kernel hwsim module
+ # which creates a wlan0 and wlan1 interface which will fail the
+ # tearDown() test in the end that no interface is allowed to survive!
if not self._test_qinq:
- self.skipTest('not enabled')
+ self.skipTest('not supported')
for interface in self._interfaces:
base = self._base_path + [interface]
@@ -325,7 +329,7 @@ class BasicInterfaceTest:
def test_interface_ip_options(self):
if not self._test_ip:
- self.skipTest('not enabled')
+ self.skipTest('not supported')
for interface in self._interfaces:
arp_tmo = '300'
@@ -376,7 +380,7 @@ class BasicInterfaceTest:
def test_interface_ipv6_options(self):
if not self._test_ipv6:
- self.skipTest('not enabled')
+ self.skipTest('not supported')
for interface in self._interfaces:
dad_transmits = '10'
@@ -400,7 +404,7 @@ class BasicInterfaceTest:
def test_dhcpv6pd_auto_sla_id(self):
if not self._test_ipv6_pd:
- self.skipTest('not enabled')
+ self.skipTest('not supported')
prefix_len = '56'
sla_len = str(64 - int(prefix_len))
@@ -456,7 +460,7 @@ class BasicInterfaceTest:
def test_dhcpv6pd_manual_sla_id(self):
if not self._test_ipv6_pd:
- self.skipTest('not enabled')
+ self.skipTest('not supported')
prefix_len = '56'
sla_len = str(64 - int(prefix_len))
diff --git a/smoketest/scripts/cli/test_interfaces_bonding.py b/smoketest/scripts/cli/test_interfaces_bonding.py
index f42ec3e9b..560bfb92b 100755
--- a/smoketest/scripts/cli/test_interfaces_bonding.py
+++ b/smoketest/scripts/cli/test_interfaces_bonding.py
@@ -60,8 +60,8 @@ class BondingInterfaceTest(BasicInterfaceTest.BaseTest):
slaves = read_file(f'/sys/class/net/{interface}/bonding/slaves').split()
self.assertListEqual(slaves, self._members)
- def test_8021q_vlan_interfaces(self):
- super().test_8021q_vlan_interfaces()
+ def test_vif_8021q_interfaces(self):
+ super().test_vif_8021q_interfaces()
for interface in self._interfaces:
slaves = read_file(f'/sys/class/net/{interface}/bonding/slaves').split()
diff --git a/smoketest/scripts/cli/test_interfaces_bridge.py b/smoketest/scripts/cli/test_interfaces_bridge.py
index 3367cca5c..30364ca37 100755
--- a/smoketest/scripts/cli/test_interfaces_bridge.py
+++ b/smoketest/scripts/cli/test_interfaces_bridge.py
@@ -52,11 +52,11 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest):
self._interfaces = list(self._options)
super().setUp()
-
+
def tearDown(self):
for intf in self._interfaces:
self.session.delete(self._base_path + [intf])
-
+
super().tearDown()
def test_add_remove_bridge_member(self):
@@ -92,15 +92,15 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest):
self.session.delete(self._base_path + [interface, 'member'])
self.session.commit()
-
- def test_8021q_vlan_interfaces(self):
+
+ def test_vif_8021q_interfaces(self):
for interface in self._interfaces:
base = self._base_path + [interface]
self.session.set(base + ['enable-vlan'])
- super().test_8021q_vlan_interfaces()
+ super().test_vif_8021q_interfaces()
def test_bridge_vlan_filter(self):
-
+
vif_vlan = 2
# Add member interface to bridge and set VLAN filter
for interface in self._interfaces:
@@ -175,7 +175,7 @@ class BridgeInterfaceTest(BasicInterfaceTest.BaseTest):
for member in self._members:
self.assertIn(member, bridge_members)
-
+
# delete all members
for interface in self._interfaces:
self.session.delete(self._base_path + [interface, 'member'])
diff --git a/smoketest/scripts/cli/test_interfaces_ethernet.py b/smoketest/scripts/cli/test_interfaces_ethernet.py
index 42c1f15df..9d896f690 100755
--- a/smoketest/scripts/cli/test_interfaces_ethernet.py
+++ b/smoketest/scripts/cli/test_interfaces_ethernet.py
@@ -78,8 +78,13 @@ class EthernetInterfaceTest(BasicInterfaceTest.BaseTest):
self.session.set(self._base_path + [interface, 'speed', 'auto'])
self.session.set(self._base_path + [interface, 'hw-id', self._macs[interface]])
- super().tearDown()
+ # Tear down mirror interfaces for SPAN (Switch Port Analyzer)
+ for span in self._mirror_interfaces:
+ section = Section.section(span)
+ self.session.delete(['interfaces', section, span])
+ self.session.commit()
+ del self.session
def test_dhcp_disable_interface(self):
# When interface is configured as admin down, it must be admin down
@@ -193,12 +198,12 @@ if __name__ == '__main__':
# Generate mandatory SSL certificate
tmp = f'openssl req -newkey rsa:4096 -new -nodes -x509 -days 3650 '\
f'-keyout {ssl_key} -out {ssl_cert} -subj {subject}'
- print(cmd(tmp))
+ cmd(tmp)
if not os.path.isfile(ca_cert):
# Generate "CA"
tmp = f'openssl req -new -x509 -key {ssl_key} -out {ca_cert} -subj {subject}'
- print(cmd(tmp))
+ cmd(tmp)
for file in [ca_cert, ssl_cert, ssl_key]:
cmd(f'sudo chown radius_priv_user:vyattacfg {file}')
diff --git a/smoketest/scripts/cli/test_interfaces_loopback.py b/smoketest/scripts/cli/test_interfaces_loopback.py
index e3538fc59..36000c3ff 100755
--- a/smoketest/scripts/cli/test_interfaces_loopback.py
+++ b/smoketest/scripts/cli/test_interfaces_loopback.py
@@ -36,7 +36,7 @@ class LoopbackInterfaceTest(BasicInterfaceTest.BaseTest):
# loopback interface must persist!
for intf in self._interfaces:
- self.assertTrue(intf in interfaces())
+ self.assertIn(intf, interfaces())
def test_add_single_ip_address(self):
super().test_add_single_ip_address()
@@ -48,5 +48,8 @@ class LoopbackInterfaceTest(BasicInterfaceTest.BaseTest):
for addr in self._loopback_addresses:
self.assertTrue(is_intf_addr_assigned('lo', addr))
+ def test_interface_disable(self):
+ self.skipTest('not supported')
+
if __name__ == '__main__':
unittest.main(verbosity=2)
diff --git a/smoketest/scripts/cli/test_vrf.py b/smoketest/scripts/cli/test_vrf.py
index bd8c5ab02..5270e758a 100755
--- a/smoketest/scripts/cli/test_vrf.py
+++ b/smoketest/scripts/cli/test_vrf.py
@@ -37,7 +37,7 @@ class VRFTest(unittest.TestCase):
self.session.delete(base_path)
self.session.commit()
for vrf in vrfs:
- self.assertTrue(vrf not in interfaces())
+ self.assertNotIn(vrf, interfaces())
def test_vrf_table_id(self):
table = '1000'