示例#1
0
 def test_cpu_list_per_node(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         cpu_topo = CpuSysCores(ssh_mock)
         cpu_topo.cpuinfo = {
             'cpuinfo': [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                         [1, 1, 0, 0, 0, 1, 1, 1, 0]]
         }
         self.assertEqual([0, 1], cpu_topo.cpu_list_per_node(0, False))
示例#2
0
 def test_is_smt_enabled(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         cpu_topo = CpuSysCores(ssh_mock)
         cpu_topo.cpuinfo = {
             'cpuinfo': [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                         [1, 1, 0, 0, 0, 1, 1, 1, 0]]
         }
         self.assertEqual(False, cpu_topo.is_smt_enabled())
示例#3
0
 def pin_vcpu_for_perf(cls, connection, vm_name, cpu, socket="0"):
     threads = ""
     sys_obj = CpuSysCores(connection)
     soc_cpu = sys_obj.get_core_socket()
     sys_cpu = int(soc_cpu["cores_per_socket"])
     cores = "%s-%s" % (soc_cpu[socket][0], soc_cpu[socket][sys_cpu - 1])
     if int(soc_cpu["thread_per_core"]):
         threads = "%s-%s" % (soc_cpu[socket][sys_cpu], soc_cpu[socket][-1])
     cpuset = "%s,%s" % (cores, threads)
     return cpuset
示例#4
0
 def test_cpu_list_per_node_smt_error(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         cpu_topo = CpuSysCores(ssh_mock)
         cpu_topo.cpuinfo = {
             'cpuinfo': [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                         [1, 1, 0, 0, 0, 1, 1, 1, 0]]
         }
         with self.assertRaises(RuntimeError) as raised:
             cpu_topo.cpu_list_per_node(0, True)
         self.assertIn('SMT is not enabled.', str(raised.exception))
示例#5
0
 def test_cpu_list_per_node_error(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         cpu_topo = CpuSysCores(ssh_mock)
         cpu_topo.cpuinfo = {
             'err': [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                     [1, 1, 0, 0, 0, 1, 1, 1, 0]]
         }
         with self.assertRaises(RuntimeError) as raised:
             cpu_topo.cpu_list_per_node(0, False)
         self.assertIn('Node cpuinfo not available.', str(raised.exception))
示例#6
0
 def test_cpu_slice_of_list_per_node_error(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         cpu_topo = CpuSysCores(ssh_mock)
         cpu_topo.cpuinfo = {
             'cpuinfo': [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                         [1, 1, 0, 0, 0, 1, 1, 1, 0]]
         }
         with self.assertRaises(RuntimeError) as raised:
             cpu_topo.cpu_slice_of_list_per_node(1, 1, 1, False)
         self.assertIn('cpu_cnt + skip_cnt > length(cpu list).',
                       str(raised.exception))
示例#7
0
 def test__get_core_details(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(1, "", ""))
         ssh_mock.put = \
             mock.Mock(return_value=(1, "", ""))
         cpu_topo = CpuSysCores(ssh_mock)
         subprocess.check_output = mock.Mock(return_value=0)
         lines = ["cpu:1", "topo:2", ""]
         self.assertEqual([{
             'topo': '2',
             'cpu': '1'
         }], cpu_topo._get_core_details(lines))
示例#8
0
    def _get_app_cpu(self):
        if self.CORES:
            return self.CORES

        vnf_cfg = self.scenario_helper.vnf_cfg
        sys_obj = CpuSysCores(self.ssh_helper)
        self.sys_cpu = sys_obj.get_core_socket()
        num_core = int(vnf_cfg["worker_threads"])
        if vnf_cfg.get("lb_config", "SW") == 'HW':
            num_core += self.HW_DEFAULT_CORE
        else:
            num_core += self.SW_DEFAULT_CORE
        app_cpu = self.sys_cpu[str(self.socket)][:num_core]
        return app_cpu
示例#9
0
 def test_validate_cpu_cfg(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
                 mock.Mock(return_value=(1, "cpu:1\ntest:2\n \n", ""))
         ssh_mock.put = \
             mock.Mock(return_value=(1, "", ""))
         cpu_topo = CpuSysCores(ssh_mock)
         subprocess.check_output = mock.Mock(return_value=0)
         cpu_topo._get_core_details = \
             mock.Mock(side_effect=[[{'Core(s) per socket': '2', 'Thread(s) per core': '1'}],
                                    [{'physical id': '2', 'processor': '1'}]])
         cpu_topo.core_map = \
             {'thread_per_core': '1', '2':['1'], 'cores_per_socket': '2'}
         self.assertEqual(-1, cpu_topo.validate_cpu_cfg())
示例#10
0
 def test_smt_enabled(self):
     self.assertEqual(
         False,
         CpuSysCores.smt_enabled({
             'cpuinfo': [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                         [1, 1, 0, 0, 0, 1, 1, 1, 0]]
         }))
示例#11
0
 def test_get_cpu_layout(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(
                 return_value=(1, "# CPU,Core,Socket,Node,,L1d,L1i,L2,L3\n'"
                                  "0,0,0,0,,0,0,0,0\n"
                                  "1,1,0,0,,1,1,1,0\n", ""))
         ssh_mock.put = \
             mock.Mock(return_value=(1, "", ""))
         cpu_topo = CpuSysCores(ssh_mock)
         subprocess.check_output = mock.Mock(return_value=0)
         self.assertEqual(
             {
                 'cpuinfo': [[0, 0, 0, 0, 0, 0, 0, 0, 0],
                             [1, 1, 0, 0, 0, 1, 1, 1, 0]]
             }, cpu_topo.get_cpu_layout())
示例#12
0
 def test___init__(self):
     with mock.patch("yardstick.ssh.SSH") as ssh:
         ssh_mock = mock.Mock(autospec=ssh.SSH)
         ssh_mock.execute = \
             mock.Mock(return_value=(1, "", ""))
         ssh_mock.put = \
             mock.Mock(return_value=(1, "", ""))
         cpu_topo = CpuSysCores(ssh_mock)
         self.assertIsNotNone(cpu_topo.connection)
示例#13
0
 def test___init__(self):
     self.mock_ssh.execute.return_value = 1, "", ""
     self.mock_ssh.put.return_value = 1, "", ""
     cpu_topo = CpuSysCores(self.mock_ssh)
     self.assertIsNotNone(cpu_topo.connection)
示例#14
0
 def __init__(self, vnfd_helper, ssh_helper, scenario_helper):
     super(VppSetupEnvHelper, self).__init__(vnfd_helper, ssh_helper,
                                             scenario_helper)
     self.sys_cores = CpuSysCores(self.ssh_helper)
示例#15
0
 def test__str2int_error(self):
     self.assertEqual(0, CpuSysCores._str2int("err"))
示例#16
0
 def test__str2int(self):
     self.assertEqual(1, CpuSysCores._str2int("1"))