def test_run_no_inspect_interfaces(self, mock_actions): network_configs = [{ "members": [{ "members": [{ "name": "nic5", "type": "interface" }], "name": "dpdk0", "type": "ovs_dpdk_port", "mtu": 8192, "rx_queue": 4 }], "name": "br-link", "type": "ovs_user_bridge" }] inspect_data = { "numa_topology": { "nics": [] }, "inventory": { "interfaces": [] } } mock_ctx = mock.MagicMock() action = derive_params.GetDpdkNicsNumaInfoAction( network_configs, inspect_data) action.run(mock_ctx) msg = 'Introspection data does not have inventory.interfaces' mock_actions.assert_called_once_with(error=msg)
def test_run_no_numa_node(self, mock_actions): network_configs = [{ "members": [{ "members": [{ "name": "nic5", "type": "interface" }], "name": "dpdk0", "type": "ovs_dpdk_port", "mtu": 8192, "rx_queue": 4 }], "name": "br-link", "type": "ovs_user_bridge" }] inspect_data = { "numa_topology": { "nics": [{ "name": "ens802f1" }, { "name": "ens802f0", "numa_node": 1 }, { "name": "eno1", "numa_node": 0 }, { "name": "eno2", "numa_node": 0 }, { "name": "enp12s0f1", "numa_node": 0 }, { "name": "enp12s0f0", "numa_node": 0 }, { "name": "enp13s0f0", "numa_node": 0 }, { "name": "enp13s0f1", "numa_node": 0 }] }, "inventory": { "interfaces": [{ "has_carrier": True, "name": "ens802f1" }, { "has_carrier": True, "name": "ens802f0" }, { "has_carrier": True, "name": "eno1" }, { "has_carrier": True, "name": "eno2" }, { "has_carrier": True, "name": "enp12s0f0" }, { "has_carrier": False, "name": "enp13s0f0" }, { "has_carrier": False, "name": "enp13s0f1" }] } } mock_ctx = mock.MagicMock() action = derive_params.GetDpdkNicsNumaInfoAction( network_configs, inspect_data) action.run(mock_ctx) msg = 'Unable to determine NUMA node for DPDK NIC: ens802f1' mock_actions.assert_called_once_with(error=msg)
def test_run_dpdk_port(self): network_configs = [{ "members": [{ "members": [{ "name": "nic5", "type": "interface" }], "name": "dpdk0", "type": "ovs_dpdk_port", "mtu": 8192, "rx_queue": 4 }], "name": "br-link", "type": "ovs_user_bridge" }] inspect_data = { "numa_topology": { "nics": [{ "name": "ens802f1", "numa_node": 1 }, { "name": "ens802f0", "numa_node": 1 }, { "name": "eno1", "numa_node": 0 }, { "name": "eno2", "numa_node": 0 }, { "name": "enp12s0f1", "numa_node": 0 }, { "name": "enp12s0f0", "numa_node": 0 }, { "name": "enp13s0f0", "numa_node": 0 }, { "name": "enp13s0f1", "numa_node": 0 }] }, "inventory": { "interfaces": [{ "has_carrier": True, "name": "ens802f1" }, { "has_carrier": True, "name": "ens802f0" }, { "has_carrier": True, "name": "eno1" }, { "has_carrier": True, "name": "eno2" }, { "has_carrier": True, "name": "enp12s0f0" }, { "has_carrier": False, "name": "enp13s0f0" }, { "has_carrier": False, "name": "enp13s0f1" }] } } expected_result = [{'name': 'ens802f1', 'mtu': 8192, 'numa_node': 1}] mock_ctx = mock.MagicMock() action = derive_params.GetDpdkNicsNumaInfoAction( network_configs, inspect_data) result = action.run(mock_ctx) self.assertEqual(result, expected_result)
def test_run_dpdk_bond(self): network_configs = [{ "members": [{ "type": "ovs_dpdk_bond", "name": "dpdkbond0", "mtu": 9000, "rx_queue": 4, "members": [{ "type": "ovs_dpdk_port", "name": "dpdk0", "members": [{ "type": "interface", "name": "nic4" }] }, { "type": "ovs_dpdk_port", "name": "dpdk1", "members": [{ "type": "interface", "name": "nic5" }] }] }], "name": "br-link", "type": "ovs_user_bridge", "addresses": [{ "ip_netmask": "172.16.10.0/24" }] }] inspect_data = { "numa_topology": { "nics": [{ "name": "ens802f1", "numa_node": 1 }, { "name": "ens802f0", "numa_node": 1 }, { "name": "eno1", "numa_node": 0 }, { "name": "eno2", "numa_node": 0 }, { "name": "enp12s0f1", "numa_node": 0 }, { "name": "enp12s0f0", "numa_node": 0 }, { "name": "enp13s0f0", "numa_node": 0 }, { "name": "enp13s0f1", "numa_node": 0 }] }, "inventory": { "interfaces": [{ "has_carrier": True, "name": "ens802f1" }, { "has_carrier": True, "name": "ens802f0" }, { "has_carrier": True, "name": "eno1" }, { "has_carrier": True, "name": "eno2" }, { "has_carrier": True, "name": "enp12s0f0" }, { "has_carrier": False, "name": "enp13s0f0" }, { "has_carrier": False, "name": "enp13s0f1" }] } } expected_result = [{ 'bridge_name': 'br-link', 'mtu': 9000, 'numa_node': 1, 'name': 'ens802f0', 'addresses': [{ 'ip_netmask': '172.16.10.0/24' }] }, { 'bridge_name': 'br-link', 'mtu': 9000, 'numa_node': 1, 'name': 'ens802f1', 'addresses': [{ 'ip_netmask': '172.16.10.0/24' }] }] mock_ctx = mock.MagicMock() action = derive_params.GetDpdkNicsNumaInfoAction( network_configs, inspect_data) result = action.run(mock_ctx) self.assertEqual(result, expected_result)