def test_network_ovs_dpdk_bond(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', 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" """ self.assertEqual(dpdk_bond_config, self.get_interface_config('dpdkbond0'))
def test_ovs_restart_called(self): interface = objects.Interface('em1') dpdk_port = objects.OvsDpdkPort('dpdk0', members=[interface]) execute_strings = [] def test_execute(*args, **kwargs): execute_strings.append(args[1]) pass self.stubs.Set(NetConfig, 'execute', test_execute) self.provider.noop = True self.provider.add_ovs_dpdk_port(dpdk_port) self.provider.apply() self.assertIn('Restart openvswitch', execute_strings)
def test_network_ovs_dpdk_bridge_and_port(self): 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]) 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 HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs TYPE=OVSUserBridge """ dpdk0_config = """# This file is autogenerated by os-net-config DEVICE=dpdk0 ONBOOT=yes HOTPLUG=no NM_CONTROLLED=no PEERDNS=no DEVICETYPE=ovs TYPE=OVSDPDKPort OVS_BRIDGE=br-link """ self.assertEqual(br_link_config, self.provider.bridge_data['br-link']) self.assertEqual(dpdk0_config, self.get_interface_config('dpdk0'))