def test_run_invalid_inspect_data(self, mock_actions):
        inspect_data = {"numa_topology": {"cpus": []}}

        numa_nodes_cores_count = [2, 1]

        mock_ctx = mock.MagicMock()
        action = derive_params.GetDpdkCoreListAction(inspect_data,
                                                     numa_nodes_cores_count)
        action.run(mock_ctx)
        msg = 'Introspection data does not have numa_topology.cpus'
        mock_actions.assert_called_once_with(error=msg)
    def test_run(self):
        inspect_data = {
            "numa_topology": {
                "cpus": [{
                    "cpu": 21,
                    "numa_node": 1,
                    "thread_siblings": [38, 82]
                }, {
                    "cpu": 27,
                    "numa_node": 0,
                    "thread_siblings": [20, 64]
                }, {
                    "cpu": 3,
                    "numa_node": 1,
                    "thread_siblings": [25, 69]
                }, {
                    "cpu": 20,
                    "numa_node": 0,
                    "thread_siblings": [15, 59]
                }, {
                    "cpu": 17,
                    "numa_node": 1,
                    "thread_siblings": [34, 78]
                }, {
                    "cpu": 16,
                    "numa_node": 0,
                    "thread_siblings": [11, 55]
                }]
            }
        }

        numa_nodes_cores_count = [2, 1]

        expected_result = "20,64,15,59,38,82"

        mock_ctx = mock.MagicMock()
        action = derive_params.GetDpdkCoreListAction(inspect_data,
                                                     numa_nodes_cores_count)
        result = action.run(mock_ctx)
        self.assertEqual(result, expected_result)
    def test_run_invalid_numa_nodes_cores_count(self, mock_actions):
        inspect_data = {
            "numa_topology": {
                "cpus": [{
                    "cpu": 21,
                    "numa_node": 1,
                    "thread_siblings": [38, 82]
                }, {
                    "cpu": 27,
                    "numa_node": 0,
                    "thread_siblings": [20, 64]
                }]
            }
        }

        numa_nodes_cores_count = []

        mock_ctx = mock.MagicMock()
        action = derive_params.GetDpdkCoreListAction(inspect_data,
                                                     numa_nodes_cores_count)
        action.run(mock_ctx)
        msg = 'CPU physical cores count for each NUMA nodes is not available'
        mock_actions.assert_called_once_with(error=msg)