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
15 # pylint: disable=unused-argument
16 # disable this for now because I keep forgetting mock patch arg ordering
19 BASE = 'yardstick.benchmark.scenarios.lib.get_numa_info'
22 class GetNumaInfoTestCase(unittest.TestCase):
24 @mock.patch('{}.GetNumaInfo._check_numa_node'.format(BASE))
25 @mock.patch('{}.GetNumaInfo._get_current_host_name'.format(BASE))
26 @mock.patch('yardstick.benchmark.scenarios.lib.get_numa_info.yaml_load')
27 @mock.patch('yardstick.common.task_template.TaskTemplate.render')
28 def test_get_numa_info(self,
31 mock_get_current_host_name,
32 mock_check_numa_node):
38 'file': 'yardstick/ssh.py'
42 mock_safe_load.return_value = {
45 obj = GetNumaInfo(scenario_cfg, {})
47 mock_get_current_host_name.assert_called_once()
48 mock_check_numa_node.assert_called_once()
50 @mock.patch('yardstick.ssh.SSH.from_node')
51 @mock.patch('{}.GetNumaInfo._get_current_host_name'.format(BASE))
52 @mock.patch('yardstick.benchmark.scenarios.lib.get_numa_info.yaml_load')
53 @mock.patch('yardstick.common.task_template.TaskTemplate.render')
54 def test_check_numa_node(self,
57 mock_get_current_host_name,
64 'file': 'yardstick/ssh.py'
68 mock_safe_load.return_value = {
75 mock_from_node().execute.return_value = (0, data, '')
76 obj = GetNumaInfo(scenario_cfg, {})
77 result = obj._check_numa_node('1', 'host4')
78 self.assertEqual(result, {'pinning': [], 'vcpupin': []})
80 @mock.patch('{}.change_obj_to_dict'.format(BASE))
81 @mock.patch('{}.get_nova_client'.format(BASE))
82 @mock.patch('yardstick.benchmark.scenarios.lib.get_numa_info.yaml_load')
83 @mock.patch('yardstick.common.task_template.TaskTemplate.render')
84 def test_get_current_host_name(self,
88 mock_change_obj_to_dict):
94 'file': 'yardstick/ssh.py'
98 mock_get_nova_client().servers.get.return_value = ''
99 mock_change_obj_to_dict.return_value = {'OS-EXT-SRV-ATTR:host': 'host5'}
101 obj = GetNumaInfo(scenario_cfg, {})
102 result = obj._get_current_host_name('1')
103 self.assertEqual(result, 'host5')