diff options
Diffstat (limited to 'os_net_config/tests')
-rw-r--r-- | os_net_config/tests/test_impl_ifcfg.py | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py index 0e5eca2..2d25a39 100644 --- a/os_net_config/tests/test_impl_ifcfg.py +++ b/os_net_config/tests/test_impl_ifcfg.py @@ -994,6 +994,85 @@ OVS_EXTRA="set Interface dpdk0 mtu_request=$MTU \ self.assertEqual(dpdk_bond_config, self.get_interface_config('dpdkbond0')) + def test_network_ovs_dpdk_bond_with_rx_queue(self): + nic_mapping = {'nic1': 'eth0', 'nic2': 'eth1', 'nic3': 'eth2'} + self.stubbed_mapped_nics = nic_mapping + + iface0 = objects.Interface(name='nic2') + dpdk0 = objects.OvsDpdkPort(name='dpdk0', members=[iface0]) + iface1 = objects.Interface(name='nic3') + dpdk1 = objects.OvsDpdkPort(name='dpdk1', members=[iface1]) + bond = objects.OvsDpdkBond('dpdkbond0', rx_queue=4, + members=[dpdk0, dpdk1]) + bridge = objects.OvsUserBridge('br-link', members=[bond]) + + def test_bind_dpdk_interfaces(ifname, driver, noop): + self.assertIn(ifname, ['eth1', 'eth2']) + self.assertEqual(driver, 'vfio-pci') + self.stubs.Set(utils, 'bind_dpdk_interfaces', + test_bind_dpdk_interfaces) + + self.provider.add_ovs_dpdk_bond(bond) + self.provider.add_ovs_user_bridge(bridge) + + dpdk_bond_config = """# This file is autogenerated by os-net-config +DEVICE=dpdkbond0 +ONBOOT=yes +HOTPLUG=no +NM_CONTROLLED=no +PEERDNS=no +DEVICETYPE=ovs +TYPE=OVSDPDKBond +OVS_BRIDGE=br-link +BOND_IFACES="dpdk0 dpdk1" +RX_QUEUE=4 +OVS_EXTRA="set Interface dpdk0 options:n_rxq=$RX_QUEUE \ +-- set Interface dpdk1 options:n_rxq=$RX_QUEUE" +""" + self.assertEqual(dpdk_bond_config, + self.get_interface_config('dpdkbond0')) + + def test_network_ovs_dpdk_bond_with_mtu_and_rx_queue(self): + nic_mapping = {'nic1': 'eth0', 'nic2': 'eth1', 'nic3': 'eth2'} + self.stubbed_mapped_nics = nic_mapping + + iface0 = objects.Interface(name='nic2') + dpdk0 = objects.OvsDpdkPort(name='dpdk0', members=[iface0]) + iface1 = objects.Interface(name='nic3') + dpdk1 = objects.OvsDpdkPort(name='dpdk1', members=[iface1]) + bond = objects.OvsDpdkBond('dpdkbond0', rx_queue=4, mtu=9000, + members=[dpdk0, dpdk1]) + bridge = objects.OvsUserBridge('br-link', members=[bond]) + + def test_bind_dpdk_interfaces(ifname, driver, noop): + self.assertIn(ifname, ['eth1', 'eth2']) + self.assertEqual(driver, 'vfio-pci') + self.stubs.Set(utils, 'bind_dpdk_interfaces', + test_bind_dpdk_interfaces) + + self.provider.add_ovs_dpdk_bond(bond) + self.provider.add_ovs_user_bridge(bridge) + + dpdk_bond_config = """# This file is autogenerated by os-net-config +DEVICE=dpdkbond0 +ONBOOT=yes +HOTPLUG=no +NM_CONTROLLED=no +PEERDNS=no +DEVICETYPE=ovs +TYPE=OVSDPDKBond +OVS_BRIDGE=br-link +BOND_IFACES="dpdk0 dpdk1" +RX_QUEUE=4 +MTU=9000 +OVS_EXTRA="set Interface dpdk0 mtu_request=$MTU \ +-- set Interface dpdk1 mtu_request=$MTU \ +-- set Interface dpdk0 options:n_rxq=$RX_QUEUE \ +-- set Interface dpdk1 options:n_rxq=$RX_QUEUE" +""" + self.assertEqual(dpdk_bond_config, + self.get_interface_config('dpdkbond0')) + class TestIfcfgNetConfigApply(base.TestCase): |