summaryrefslogtreecommitdiffstats
path: root/test/test_vhost.py
blob: 469fadaf2cdeb9bc23838b0b4bd4a81f189bffcd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/env python

import unittest

from framework import VppTestCase, VppTestRunner

from vpp_vhost_interface import VppVhostInterface


class TesVhostInterface(VppTestCase):
    """Vhost User Test Case

    """

    def tearDown(self):
        super(TesVhostInterface, self).tearDown()
        if not self.vpp_dead:
            if_dump = self.vapi.sw_interface_vhost_user_dump()
            for ifc in if_dump:
                self.vapi.delete_vhost_user_if(ifc.sw_if_index)

    def test_vhost(self):
        """ 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.add_vpp_config()
        vhost_if1.admin_up()

        # create interface 2 (VirtualEthernet0/0/1)
        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.assertNotEqual(ifs.find('VirtualEthernet0/0/0'), -1)
        self.assertNotEqual(ifs.find('VirtualEthernet0/0/1'), -1)

        # verify they are in the dump also
        if_dump = self.vapi.sw_interface_vhost_user_dump()
        self.assertTrue(vhost_if1.is_interface_config_in_dump(if_dump))
        self.assertTrue(vhost_if2.is_interface_config_in_dump(if_dump))

        # delete VirtualEthernet0/0/1
        self.logger.info("Deleting VirtualEthernet0/0/1")
        vhost_if2.remove_vpp_config()

        self.logger.info("Verifying VirtualEthernet0/0/1 is deleted")

        ifs = self.vapi.cli("show interface")
        # verify VirtualEthernet0/0/0 still in the show
        self.assertNotEqual(ifs.find('VirtualEthernet0/0/0'), -1)

        # verify VirtualEthernet0/0/1 not in the show
        self.assertEqual(ifs.find('VirtualEthernet0/0/1'), -1)

        # verify VirtualEthernet0/0/1 is not in the dump
        if_dump = self.vapi.sw_interface_vhost_user_dump()
        self.assertFalse(vhost_if2.is_interface_config_in_dump(if_dump))

        # verify VirtualEthernet0/0/0 is still in the dump
        self.assertTrue(vhost_if1.is_interface_config_in_dump(if_dump))

        # delete VirtualEthernet0/0/0
        self.logger.info("Deleting VirtualEthernet0/0/0")
        vhost_if1.remove_vpp_config()

        self.logger.info("Verifying VirtualEthernet0/0/0 is deleted")

        # verify VirtualEthernet0/0/0 not in the show
        ifs = self.vapi.cli("show interface")
        self.assertEqual(ifs.find('VirtualEthernet0/0/0'), -1)

        # 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 """

        self.vapi.want_interface_events()

        # clear outstanding events
        # (like delete interface events from other tests)
        self.vapi.collect_events()

        vhost_if = VppVhostInterface(self, sock_filename='/tmp/sock1')

        # create vhost interface
        vhost_if.add_vpp_config()
        self.sleep(0.1)
        events = self.vapi.collect_events()
        # creating interface doesn't currently create events
        self.assert_equal(len(events), 0, "number of events")

        vhost_if.admin_up()
        vhost_if.assert_interface_state(1, 0, expect_event=True)

        vhost_if.admin_down()
        vhost_if.assert_interface_state(0, 0, expect_event=True)

        # 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.deleted, 1, "deleted flag")

        # verify there are no more events
        events = self.vapi.collect_events()
        self.assert_equal(len(events), 0, "number of events")

if __name__ == '__main__':
    unittest.main(testRunner=VppTestRunner)
${subid}= | 10 | ${tag_rewrite}= | pop-1 | ${overhead}= | ${4} # Link bonding config | ${bond_mode}= | lacp | ${lb_mode}= | l34 # Socket names | ${sock1}= | /tmp/sock-1 | ${sock2}= | /tmp/sock-2 # X710 bandwidth limit | ${s_limit}= | ${10000000000} # Traffic profile: | ${traffic_profile}= | trex-sl-3n-ethip4-ip4src254 *** Keywords *** | Local Template | | [Documentation] | | ... | [Cfg] DUT runs L2XC switching config. | | ... | Each DUT uses ${phy_cores} physical core(s) for worker threads. | | ... | [Ver] Measure NDR and PDR values using MLRsearch algorithm.\ | | ... | | ... | *Arguments:* | | ... | - framesize - Framesize in Bytes in integer or string (IMIX_v4_1). | | ... | Type: integer, string | | ... | - phy_cores - Number of physical cores. Type: integer | | ... | - rxq - Number of RX queues, default value: ${None}. Type: integer | | ... | | [Arguments] | ${framesize} | ${phy_cores} | ${rxq}=${None} | | ... | | Set Test Variable | ${framesize} | | Set Test Variable | ${min_rate} | ${10000} | | ${dut1_vm_refs}= | Create Dictionary | | ${dut2_vm_refs}= | Create Dictionary | | Set Test Variable | ${dut1_vm_refs} | | Set Test Variable | ${dut2_vm_refs} | | ... | | Given Add worker threads and rxqueues to all DUTs | ${phy_cores} | ${rxq} | | And Add PCI devices to all DUTs | | And Add VLAN Strip Offload switch off between DUTs in 3-node single link topology | | ${max_rate} | ${jumbo} = | Get Max Rate And Jumbo And Handle Multi Seg | | ... | ${s_limit} | ${framesize} | overhead=${overhead} | | And Apply startup configuration on all VPP DUTs | | When Initialize L2 xconnect with Vhost-User and VLAN with VPP link bonding in 3-node circular topology | | ... | ${sock1} | ${sock2} | ${subid} | ${tag_rewrite} | ${bond_mode} | | ... | ${lb_mode} | | ${vm1}= | And Configure guest VM with dpdk-testpmd connected via vhost-user | | ... | DUT1 | ${sock1} | ${sock2} | DUT1_VM1 | jumbo=${jumbo} | | ... | perf_qemu_qsz=${1024} | use_tuned_cfs=${False} | | And Set To Dictionary | ${dut1_vm_refs} | DUT1_VM1 | ${vm1} | | ${vm2}= | And Configure guest VM with dpdk-testpmd connected via vhost-user | | ... | DUT2 | ${sock1} | ${sock2} | DUT2_VM1 | jumbo=${jumbo} | | ... | perf_qemu_qsz=${1024} | use_tuned_cfs=${False} | | And Set To Dictionary | ${dut2_vm_refs} | DUT2_VM1 | ${vm2} | | And All Vpp Interfaces Ready Wait | ${nodes} | | Then Find NDR and PDR intervals using optimized search | | ... | ${framesize} | ${traffic_profile} | ${min_rate} | ${max_rate} *** Test Cases *** | tc01-64B-1c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | 64B | 1C | | framesize=${64} | phy_cores=${1} | tc02-64B-2c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | 64B | 2C | | framesize=${64} | phy_cores=${2} | tc03-64B-4c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | 64B | 4C | | framesize=${64} | phy_cores=${4} | tc04-1518B-1c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | 1518B | 1C | | framesize=${1518} | phy_cores=${1} | tc05-1518B-2c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | 1518B | 2C | | framesize=${1518} | phy_cores=${2} | tc06-1518B-4c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | 1518B | 4C | | framesize=${1518} | phy_cores=${4} | tc07-9000B-1c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | 9000B | 1C | | framesize=${9000} | phy_cores=${1} | tc08-9000B-2c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | 9000B | 2C | | framesize=${9000} | phy_cores=${2} | tc09-9000B-4c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | 9000B | 4C | | framesize=${9000} | phy_cores=${4} | tc10-IMIX-1c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | IMIX | 1C | | framesize=IMIX_v4_1 | phy_cores=${1} | tc11-IMIX-2c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | IMIX | 2C | | framesize=IMIX_v4_1 | phy_cores=${2} | tc12-IMIX-4c-1lbvpplacp-dot1q-l2xcbase-eth-2vhostvr1024-1vm-ndrpdr | | [Tags] | IMIX | 4C | | framesize=IMIX_v4_1 | phy_cores=${4}