summaryrefslogtreecommitdiffstats
path: root/test/test_vhost.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_vhost.py')
-rw-r--r--test/test_vhost.py46
1 files changed, 20 insertions, 26 deletions
diff --git a/test/test_vhost.py b/test/test_vhost.py
index aefae90f2f6..01e2151e67f 100644
--- a/test/test_vhost.py
+++ b/test/test_vhost.py
@@ -8,9 +8,8 @@ from vpp_vhost_interface import VppVhostInterface
class TesVhostInterface(VppTestCase):
- """Vhost User Test Case
+ """Vhost User Test Case"""
- """
@classmethod
def setUpClass(cls):
super(TesVhostInterface, cls).setUpClass()
@@ -27,23 +26,23 @@ class TesVhostInterface(VppTestCase):
self.vapi.delete_vhost_user_if(ifc.sw_if_index)
def test_vhost(self):
- """ Vhost User add/delete interface test """
+ """Vhost User add/delete interface test"""
self.logger.info("Vhost User add interfaces")
# create interface 1 (VirtualEthernet0/0/0)
- vhost_if1 = VppVhostInterface(self, sock_filename='/tmp/sock1')
+ vhost_if1 = VppVhostInterface(self, sock_filename="/tmp/sock1")
vhost_if1.add_vpp_config()
vhost_if1.admin_up()
# create interface 2 (VirtualEthernet0/0/1)
- vhost_if2 = VppVhostInterface(self, sock_filename='/tmp/sock2')
+ vhost_if2 = VppVhostInterface(self, sock_filename="/tmp/sock2")
vhost_if2.add_vpp_config()
vhost_if2.admin_up()
# verify both interfaces in the show
ifs = self.vapi.cli("show interface")
- self.assertIn('VirtualEthernet0/0/0', ifs)
- self.assertIn('VirtualEthernet0/0/1', ifs)
+ self.assertIn("VirtualEthernet0/0/0", ifs)
+ self.assertIn("VirtualEthernet0/0/1", ifs)
# verify they are in the dump also
if_dump = self.vapi.sw_interface_vhost_user_dump()
@@ -58,10 +57,10 @@ class TesVhostInterface(VppTestCase):
ifs = self.vapi.cli("show interface")
# verify VirtualEthernet0/0/0 still in the show
- self.assertIn('VirtualEthernet0/0/0', ifs)
+ self.assertIn("VirtualEthernet0/0/0", ifs)
# verify VirtualEthernet0/0/1 not in the show
- self.assertNotIn('VirtualEthernet0/0/1', ifs)
+ self.assertNotIn("VirtualEthernet0/0/1", ifs)
# verify VirtualEthernet0/0/1 is not in the dump
if_dump = self.vapi.sw_interface_vhost_user_dump()
@@ -78,14 +77,14 @@ class TesVhostInterface(VppTestCase):
# verify VirtualEthernet0/0/0 not in the show
ifs = self.vapi.cli("show interface")
- self.assertNotIn('VirtualEthernet0/0/0', ifs)
+ self.assertNotIn("VirtualEthernet0/0/0", ifs)
# verify VirtualEthernet0/0/0 is not in the dump
if_dump = self.vapi.sw_interface_vhost_user_dump()
self.assertFalse(vhost_if1.is_interface_config_in_dump(if_dump))
def test_vhost_interface_state(self):
- """ Vhost User interface states and events test """
+ """Vhost User interface states and events test"""
self.vapi.want_interface_events()
@@ -93,7 +92,7 @@ class TesVhostInterface(VppTestCase):
# (like delete interface events from other tests)
self.vapi.collect_events()
- vhost_if = VppVhostInterface(self, sock_filename='/tmp/sock1')
+ vhost_if = VppVhostInterface(self, sock_filename="/tmp/sock1")
# create vhost interface
vhost_if.add_vpp_config()
@@ -111,8 +110,7 @@ class TesVhostInterface(VppTestCase):
# delete vhost interface
vhost_if.remove_vpp_config()
event = self.vapi.wait_for_event(timeout=1)
- self.assert_equal(event.sw_if_index, vhost_if.sw_if_index,
- "sw_if_index")
+ self.assert_equal(event.sw_if_index, vhost_if.sw_if_index, "sw_if_index")
self.assert_equal(event.deleted, 1, "deleted flag")
# verify there are no more events
@@ -120,32 +118,28 @@ class TesVhostInterface(VppTestCase):
self.assert_equal(len(events), 0, "number of events")
def test_vhost_interface_custom_mac_addr(self):
- """ Vhost User interface custom mac address test """
+ """Vhost User interface custom mac address test"""
mac_addr = "aa:bb:cc:dd:ee:ff"
- vhost_if = VppVhostInterface(self,
- sock_filename='/tmp/sock1',
- use_custom_mac=1,
- mac_address=mac_addr)
+ vhost_if = VppVhostInterface(
+ self, sock_filename="/tmp/sock1", use_custom_mac=1, mac_address=mac_addr
+ )
# create vhost interface
vhost_if.add_vpp_config()
self.sleep(0.1)
# verify mac in the dump
- if_dump_list = self.vapi.sw_interface_dump(
- sw_if_index=vhost_if.sw_if_index
- )
+ if_dump_list = self.vapi.sw_interface_dump(sw_if_index=vhost_if.sw_if_index)
self.assert_equal(len(if_dump_list), 1, "if dump length")
[if_dump] = if_dump_list
- self.assert_equal(
- if_dump.l2_address.mac_string, mac_addr, "MAC Address"
- )
+ self.assert_equal(if_dump.l2_address.mac_string, mac_addr, "MAC Address")
# delete VirtualEthernet
self.logger.info("Deleting VirtualEthernet")
vhost_if.remove_vpp_config()
-if __name__ == '__main__':
+
+if __name__ == "__main__":
unittest.main(testRunner=VppTestRunner)