5 from framework import VppTestCase, VppTestRunner
7 from vpp_vhost_interface import VppVhostInterface
10 class TesVhostInterface(VppTestCase):
11 """Vhost User Test Case
16 """ Vhost User add/delete interface test """
17 self.logger.info("Vhost User add interfaces")
19 # create interface 1 (VirtualEthernet0/0/0)
20 vhost_if1 = VppVhostInterface(self, sock_filename='/tmp/sock1')
21 vhost_if1.add_vpp_config()
24 # create interface 2 (VirtualEthernet0/0/1)
25 vhost_if2 = VppVhostInterface(self, sock_filename='/tmp/sock2')
26 vhost_if2.add_vpp_config()
29 # verify both interfaces in the show
30 ifs = self.vapi.cli("show interface")
31 self.assertNotEqual(ifs.find('VirtualEthernet0/0/0'), -1)
32 self.assertNotEqual(ifs.find('VirtualEthernet0/0/1'), -1)
34 # verify they are in the dump also
35 if_dump = self.vapi.sw_interface_vhost_user_dump()
36 self.assertTrue(vhost_if1.is_interface_config_in_dump(if_dump))
37 self.assertTrue(vhost_if2.is_interface_config_in_dump(if_dump))
39 # delete VirtualEthernet0/0/1
40 self.logger.info("Deleting VirtualEthernet0/0/1")
41 vhost_if2.remove_vpp_config()
43 self.logger.info("Verifying VirtualEthernet0/0/1 is deleted")
45 ifs = self.vapi.cli("show interface")
46 # verify VirtualEthernet0/0/0 still in the show
47 self.assertNotEqual(ifs.find('VirtualEthernet0/0/0'), -1)
49 # verify VirtualEthernet0/0/1 not in the show
50 self.assertEqual(ifs.find('VirtualEthernet0/0/1'), -1)
52 # verify VirtualEthernet0/0/1 is not in the dump
53 if_dump = self.vapi.sw_interface_vhost_user_dump()
54 self.assertFalse(vhost_if2.is_interface_config_in_dump(if_dump))
56 # verify VirtualEthernet0/0/0 is still in the dump
57 self.assertTrue(vhost_if1.is_interface_config_in_dump(if_dump))
59 # delete VirtualEthernet0/0/0
60 self.logger.info("Deleting VirtualEthernet0/0/0")
61 vhost_if1.remove_vpp_config()
63 self.logger.info("Verifying VirtualEthernet0/0/0 is deleted")
65 # verify VirtualEthernet0/0/0 not in the show
66 ifs = self.vapi.cli("show interface")
67 self.assertEqual(ifs.find('VirtualEthernet0/0/0'), -1)
69 # verify VirtualEthernet0/0/0 is not in the dump
70 if_dump = self.vapi.sw_interface_vhost_user_dump()
71 self.assertFalse(vhost_if1.is_interface_config_in_dump(if_dump))
73 if __name__ == '__main__':
74 unittest.main(testRunner=VppTestRunner)