for mocking in mocks:
mocking.assert_not_called()
+ @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
@patch.object(
mock_process_numa_paired_threads,
mock_process_numa_vcpu,
mock_process_numa_memory,
+ mock_process_vio_numa_nodes,
):
"""Process numa parameters, id, memory, vcpu exist, vim type is VIO,
paired-threads, cores, threads do not exist in numa.
extra_specs = {}
expected_extra_specs = {
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
"hw:cpu_sockets": "2",
}
self.vimconn.vim_type = "VIO"
self.assertEqual(mock_process_numa_memory.call_count, 2)
self.assertEqual(mock_process_numa_vcpu.call_count, 2)
+ mock_process_vio_numa_nodes.assert_called_once_with(2, {"hw:numa_nodes": "2"})
_call_mock_process_numa_memory = mock_process_numa_memory.call_args_list
self.assertEqual(
_call_mock_process_numa_memory[0].args,
0,
{
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
},
),
)
{
"hw:cpu_sockets": "2",
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
},
),
)
0,
{
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
},
),
)
{
"hw:cpu_sockets": "2",
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
},
),
)
]
)
+ @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
@patch.object(
mock_process_numa_paired_threads,
mock_process_numa_vcpu,
mock_process_numa_memory,
+ mock_process_vio_numa_nodes,
):
"""Process numa parameters, id, memory, vcpu exist, vim type is openstack,
paired-threads, cores, threads do not exist in numa.
]
)
+ @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
@patch.object(
mock_process_numa_paired_threads,
mock_process_numa_vcpu,
mock_process_numa_memory,
+ mock_process_vio_numa_nodes,
):
"""Process numa parameters, id, paired-threads exist, vim type is openstack.
vcpus calculation according to paired-threads in numa, there is extra_spec.
)
self.assertDictEqual(extra_specs, expected_extra_specs)
+ @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
@patch.object(
mock_process_numa_paired_threads,
mock_process_numa_vcpu,
mock_process_numa_memory,
+ mock_process_vio_numa_nodes,
):
"""Process numa parameters, id, paired-threads exist, vim type is VIO.
vcpus calculation according to paired-threads in numa, there is extra_spec.
extra_specs = {"some-key": "some-value"}
expected_extra_specs = {
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
"hw:cpu_sockets": "2",
"hw:cpu_threads": "8",
"some-key": "some-value",
_call_mock_process_numa_paired_threads = (
mock_process_numa_paired_threads.call_args_list
)
+ mock_process_vio_numa_nodes.assert_called_once_with(
+ 2, {"some-key": "some-value", "hw:numa_nodes": "2"}
+ )
self.assertEqual(
_call_mock_process_numa_paired_threads[0].args,
(
"hw:cpu_sockets": "2",
"hw:numa_nodes": "2",
"some-key": "some-value",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
},
),
)
"hw:cpu_sockets": "2",
"hw:numa_nodes": "2",
"some-key": "some-value",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
},
),
)
self.assertDictEqual(extra_specs, expected_extra_specs)
+ @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
@patch.object(
mock_process_numa_paired_threads,
mock_process_numa_vcpu,
mock_process_numa_memory,
+ mock_process_vio_numa_nodes,
):
"""Process numa parameters, id, cores exist, vim type is openstack.
vcpus calculation according to cores in numa.
)
self.assertDictEqual(extra_specs, expected_extra_specs)
+ @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
@patch.object(
mock_process_numa_paired_threads,
mock_process_numa_vcpu,
mock_process_numa_memory,
+ mock_process_vio_numa_nodes,
):
"""Process numa parameters, id, cores exist, vim type is VIO.
vcpus calculation according to cores in numa.
"hw:cpu_cores": "3",
"hw:cpu_sockets": "2",
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
}
self.vimconn.vim_type = "VIO"
mock_process_numa_cores.side_effect = [1, 2]
self.assertEqual(mock_process_numa_memory.call_count, 2)
self.assertEqual(mock_process_numa_vcpu.call_count, 2)
self.assertEqual(mock_process_numa_cores.call_count, 2)
+ mock_process_vio_numa_nodes.assert_called_once_with(2, {"hw:numa_nodes": "2"})
_call_mock_process_numa_cores = mock_process_numa_cores.call_args_list
self.assertEqual(
_call_mock_process_numa_cores[0].args,
{
"hw:cpu_sockets": "2",
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
},
),
)
{
"hw:cpu_sockets": "2",
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
},
),
)
self.assertDictEqual(extra_specs, expected_extra_specs)
+ @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
@patch.object(
mock_process_numa_paired_threads,
mock_process_numa_vcpu,
mock_process_numa_memory,
+ mock_process_vio_numa_nodes,
):
"""Process numa parameters, memory, vcpu, thread exist, vim type is VIO,
vcpus calculation according threads in numa, there are not numa ids.
extra_specs = {}
expected_extra_specs = {
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
"hw:cpu_sockets": "2",
"hw:cpu_threads": "3",
}
mock_process_numa_paired_threads,
]
)
+ mock_process_vio_numa_nodes.assert_called_once_with(2, {"hw:numa_nodes": "2"})
self.assertEqual(mock_process_numa_threads.call_count, 1)
_call_mock_process_numa_threads = mock_process_numa_threads.call_args_list
self.assertEqual(
{
"hw:cpu_sockets": "2",
"hw:numa_nodes": "2",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
},
),
)
self.assertDictEqual(extra_specs, expected_extra_specs)
+ @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
@patch.object(
mock_process_numa_paired_threads,
mock_process_numa_vcpu,
mock_process_numa_memory,
+ mock_process_vio_numa_nodes,
):
"""Process numa parameters, memory, vcpu, thread exist, vim type is openstack,
vcpus calculation according threads in numa, there are not numa ids.
mock_process_numa_vcpu,
mock_process_numa_cores,
mock_process_numa_paired_threads,
+ mock_process_vio_numa_nodes,
]
)
self.assertEqual(mock_process_numa_threads.call_count, 1)
)
self.assertDictEqual(extra_specs, expected_extra_specs)
+ @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
@patch.object(
mock_process_numa_paired_threads,
mock_process_numa_vcpu,
mock_process_numa_memory,
+ mock_process_vio_numa_nodes,
):
"""Numa list is empty, vim type is VIO."""
numas = []
extra_specs = {}
- expected_extra_specs = {
- "hw:numa_nodes": "0",
- "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
- "vmware:latency_sensitivity_level": "high",
- }
+ expected_extra_specs = {"hw:numa_nodes": "0"}
self.vimconn.vim_type = "VIO"
self.vimconn._process_numa_parameters_of_flavor(numas, extra_specs)
self.check_if_assert_not_called(
mock_process_numa_threads,
]
)
+ mock_process_vio_numa_nodes.assert_called_once_with(0, {"hw:numa_nodes": "0"})
self.assertDictEqual(extra_specs, expected_extra_specs)
+ @patch.object(vimconnector, "process_vio_numa_nodes", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_memory", new_callable=CopyingMock())
@patch.object(vimconnector, "process_numa_vcpu", new_callable=CopyingMock())
@patch.object(
mock_process_numa_paired_threads,
mock_process_numa_vcpu,
mock_process_numa_memory,
+ mock_process_vio_numa_nodes,
):
"""Numa list is empty, vim type is openstack."""
numas = []
mock_process_numa_cores,
mock_process_numa_paired_threads,
mock_process_numa_threads,
+ mock_process_vio_numa_nodes,
]
)
self.assertDictEqual(extra_specs, expected_extra_specs)
)
self.assertEqual(mock_format_exception.call_count, 1)
+ def test_process_process_vio_numa_nodes_without_numa_with_extra_spec(self):
+ numa_nodes = 0
+ extra_specs = {"hw:numa_nodes": "0"}
+ expected_extra_spec = {
+ "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
+ "vmware:latency_sensitivity_level": "high",
+ "hw:numa_nodes": "0",
+ }
+ self.vimconn.process_vio_numa_nodes(numa_nodes, extra_specs)
+ self.assertDictEqual(extra_specs, expected_extra_spec)
+
+ def test_process_process_vio_numa_nodes_list_type_numa_nodes_empty_extra_spec(self):
+ numa_nodes = [7, 9, 4]
+ extra_specs = {}
+ expected_extra_spec = {
+ "vmware:latency_sensitivity_level": "high",
+ }
+ self.vimconn.process_vio_numa_nodes(numa_nodes, extra_specs)
+ self.assertDictEqual(extra_specs, expected_extra_spec)
+
+ def test_process_process_vio_numa_nodes_with_numa_with_extra_spec(self):
+ numa_nodes = 5
+ extra_specs = {"hw:numa_nodes": "5"}
+ expected_extra_spec = {
+ "vmware:latency_sensitivity_level": "high",
+ "hw:numa_nodes": "5",
+ }
+ self.vimconn.process_vio_numa_nodes(numa_nodes, extra_specs)
+ self.assertDictEqual(extra_specs, expected_extra_spec)
+
+ def test_process_process_vio_numa_nodes_none_numa_nodes(self):
+ numa_nodes = None
+ extra_specs = {"hw:numa_nodes": "None"}
+ expected_extra_spec = {
+ "vmware:latency_sensitivity_level": "high",
+ "hw:numa_nodes": "None",
+ "vmware:extra_config": '{"numa.nodeAffinity":"0"}',
+ }
+ self.vimconn.process_vio_numa_nodes(numa_nodes, extra_specs)
+ self.assertDictEqual(extra_specs, expected_extra_spec)
+
+ def test_process_process_vio_numa_nodes_invalid_type_extra_specs(self):
+ numa_nodes = 5
+ extra_specs = []
+ with self.assertRaises(TypeError):
+ self.vimconn.process_vio_numa_nodes(numa_nodes, extra_specs)
+
if __name__ == "__main__":
unittest.main()