1 ##############################################################################
2 # Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
4 # All rights reserved. This program and the accompanying materials
5 # are made available under the terms of the Apache License, Version 2.0
6 # which accompanies this distribution, and is available at
7 # http://www.apache.org/licenses/LICENSE-2.0
8 ##############################################################################
12 from yardstick.benchmark.scenarios.lib.get_numa_info import GetNumaInfo
14 BASE = 'yardstick.benchmark.scenarios.lib.get_numa_info'
17 class GetNumaInfoTestCase(unittest.TestCase):
19 @mock.patch('{}.GetNumaInfo._check_numa_node'.format(BASE))
20 @mock.patch('{}.GetNumaInfo._get_current_host_name'.format(BASE))
21 @mock.patch('yardstick.benchmark.scenarios.lib.get_numa_info.yaml_load')
22 @mock.patch('yardstick.common.task_template.TaskTemplate.render')
23 def test_get_numa_info(self,
26 mock_get_current_host_name,
27 mock_check_numa_node):
33 'file': 'yardstick/ssh.py'
37 mock_safe_load.return_value = {
40 obj = GetNumaInfo(scenario_cfg, {})
42 self.assertTrue(mock_get_current_host_name.called)
43 self.assertTrue(mock_check_numa_node.called)
45 @mock.patch('yardstick.ssh.SSH.from_node')
46 @mock.patch('{}.GetNumaInfo._get_current_host_name'.format(BASE))
47 @mock.patch('yardstick.benchmark.scenarios.lib.get_numa_info.yaml_load')
48 @mock.patch('yardstick.common.task_template.TaskTemplate.render')
49 def test_check_numa_node(self,
52 mock_get_current_host_name,
59 'file': 'yardstick/ssh.py'
63 mock_safe_load.return_value = {
70 mock_from_node().execute.return_value = (0, data, '')
71 obj = GetNumaInfo(scenario_cfg, {})
72 result = obj._check_numa_node('1', 'host4')
73 self.assertEqual(result, {'pinning': [], 'vcpupin': []})
75 @mock.patch('{}.change_obj_to_dict'.format(BASE))
76 @mock.patch('{}.get_nova_client'.format(BASE))
77 @mock.patch('yardstick.benchmark.scenarios.lib.get_numa_info.yaml_load')
78 @mock.patch('yardstick.common.task_template.TaskTemplate.render')
79 def test_get_current_host_name(self,
83 mock_change_obj_to_dict):
89 'file': 'yardstick/ssh.py'
93 mock_get_nova_client().servers.get.return_value = ''
94 mock_change_obj_to_dict.return_value = {'OS-EXT-SRV-ATTR:host': 'host5'}
96 obj = GetNumaInfo(scenario_cfg, {})
97 result = obj._get_current_host_name('1')
98 self.assertEqual(result, 'host5')
105 if __name__ == '__main__':