summaryrefslogtreecommitdiffstats
path: root/test/test_vhost.py
diff options
context:
space:
mode:
authorKlement Sekera <klement.sekera@gmail.com>2022-04-26 19:02:15 +0200
committerOle Tr�an <otroan@employees.org>2022-05-10 18:52:08 +0000
commitd9b0c6fbf7aa5bd9af84264105b39c82028a4a29 (patch)
tree4f786cfd8ebc2443cb11e11b74c8657204068898 /test/test_vhost.py
parentf90348bcb4afd0af2611cefc43b17ef3042b511c (diff)
tests: replace pycodestyle with black
Drop pycodestyle for code style checking in favor of black. Black is much faster, stable PEP8 compliant code style checker offering also automatic formatting. It aims to be very stable and produce smallest diffs. It's used by many small and big projects. Running checkstyle with black takes a few seconds with a terse output. Thus, test-checkstyle-diff is no longer necessary. Expand scope of checkstyle to all python files in the repo, replacing test-checkstyle with checkstyle-python. Also, fixstyle-python is now available for automatic style formatting. Note: python virtualenv has been consolidated in test/Makefile, test/requirements*.txt which will eventually be moved to a central location. This is required to simply the automated generation of docker executor images in the CI. Type: improvement Change-Id: I022a326603485f58585e879ac0f697fceefbc9c8 Signed-off-by: Klement Sekera <klement.sekera@gmail.com> Signed-off-by: Dave Wallace <dwallacelf@gmail.com>
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)