aboutsummaryrefslogtreecommitdiffstats
path: root/os_net_config/tests
diff options
context:
space:
mode:
Diffstat (limited to 'os_net_config/tests')
-rw-r--r--os_net_config/tests/test_impl_ifcfg.py35
-rw-r--r--os_net_config/tests/test_objects.py13
2 files changed, 38 insertions, 10 deletions
diff --git a/os_net_config/tests/test_impl_ifcfg.py b/os_net_config/tests/test_impl_ifcfg.py
index 74dd1f9..c3acbc8 100644
--- a/os_net_config/tests/test_impl_ifcfg.py
+++ b/os_net_config/tests/test_impl_ifcfg.py
@@ -759,12 +759,21 @@ DNS2=5.6.7.8
self.assertEqual(em1_config, self.get_interface_config('em1'))
def test_network_ovs_dpdk_bridge_and_port(self):
- interface = objects.Interface(name='eth1')
+ nic_mapping = {'nic1': 'eth0', 'nic2': 'eth1', 'nic3': 'eth2'}
+ self.stubbed_mapped_nics = nic_mapping
+
+ interface = objects.Interface(name='nic3')
dpdk_port = objects.OvsDpdkPort(name='dpdk0', members=[interface])
bridge = objects.OvsUserBridge('br-link', members=[dpdk_port])
- self.provider.add_interface(interface)
- self.provider.add_interface(dpdk_port)
- self.provider.add_bridge(bridge)
+
+ def test_bind_dpdk_interfaces(ifname, driver, noop):
+ self.assertEqual(ifname, 'eth2')
+ self.assertEqual(driver, 'vfio-pci')
+ self.stubs.Set(utils, 'bind_dpdk_interfaces',
+ test_bind_dpdk_interfaces)
+
+ self.provider.add_ovs_dpdk_port(dpdk_port)
+ self.provider.add_ovs_user_bridge(bridge)
br_link_config = """# This file is autogenerated by os-net-config
DEVICE=br-link
ONBOOT=yes
@@ -789,14 +798,24 @@ OVS_BRIDGE=br-link
self.assertEqual(dpdk0_config, self.get_interface_config('dpdk0'))
def test_network_ovs_dpdk_bond(self):
- iface0 = objects.Interface(name='eth1')
+ 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='eth2')
+ iface1 = objects.Interface(name='nic3')
dpdk1 = objects.OvsDpdkPort(name='dpdk1', members=[iface1])
bond = objects.OvsDpdkBond('dpdkbond0', members=[dpdk0, dpdk1])
bridge = objects.OvsUserBridge('br-link', members=[bond])
- self.provider.add_bond(bond)
- self.provider.add_bridge(bridge)
+
+ 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
diff --git a/os_net_config/tests/test_objects.py b/os_net_config/tests/test_objects.py
index 92d43b9..2e5fbe4 100644
--- a/os_net_config/tests/test_objects.py
+++ b/os_net_config/tests/test_objects.py
@@ -834,7 +834,16 @@ class TestNicMapping(base.TestCase):
class TestOvsDpdkBond(base.TestCase):
+ # We want to test the function, not the dummy..
+ stub_mapped_nics = False
+
+ def _stub_active_nics(self, nics):
+ def dummy_ordered_active_nics():
+ return nics
+ self.stubs.Set(utils, 'ordered_active_nics', dummy_ordered_active_nics)
+
def test_from_json_dhcp(self):
+ self._stub_active_nics(['eth0', 'eth1', 'eth2'])
data = """{
"type": "ovs_dpdk_bond",
"name": "dpdkbond0",
@@ -846,7 +855,7 @@ class TestOvsDpdkBond(base.TestCase):
"members": [
{
"type": "interface",
- "name": "eth1"
+ "name": "nic2"
}
]
},
@@ -856,7 +865,7 @@ class TestOvsDpdkBond(base.TestCase):
"members": [
{
"type": "interface",
- "name": "eth2"
+ "name": "nic3"
}
]
}