aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark')
-rw-r--r--yardstick/benchmark/contexts/standalone/model.py8
-rw-r--r--yardstick/benchmark/contexts/standalone/ovs_dpdk.py12
-rw-r--r--yardstick/benchmark/core/__init__.py12
-rw-r--r--yardstick/benchmark/core/runner.py18
-rw-r--r--yardstick/benchmark/core/scenario.py16
-rwxr-xr-xyardstick/benchmark/scenarios/availability/ha_tools/fault_process_kill.bash2
-rw-r--r--yardstick/benchmark/scenarios/compute/spec_cpu.py18
-rw-r--r--yardstick/benchmark/scenarios/compute/spec_cpu_for_vm.py170
-rw-r--r--yardstick/benchmark/scenarios/lib/create_volume.py9
9 files changed, 227 insertions, 38 deletions
diff --git a/yardstick/benchmark/contexts/standalone/model.py b/yardstick/benchmark/contexts/standalone/model.py
index ea8eb5d09..30170832a 100644
--- a/yardstick/benchmark/contexts/standalone/model.py
+++ b/yardstick/benchmark/contexts/standalone/model.py
@@ -43,6 +43,7 @@ VM_TEMPLATE = """
<hugepages />
</memoryBacking>
<vcpu cpuset='{cpuset}'>{vcpu}</vcpu>
+ {cputune}
<os>
<type arch="x86_64" machine="pc-i440fx-utopic">hvm</type>
<boot dev="hd" />
@@ -217,9 +218,8 @@ class Libvirt(object):
mac.set('address', vf_mac)
source = ET.SubElement(interface, 'source')
- addr = ET.SubElement(source, 'address')
pci_address = PciAddress(vf_pci.strip())
- cls._add_interface_address(addr, pci_address)
+ cls._add_interface_address(source, pci_address)
pci_vm_address = PciAddress(vm_pci.strip())
cls._add_interface_address(interface, pci_vm_address)
@@ -248,6 +248,7 @@ class Libvirt(object):
hw_socket = flavor.get('hw_socket', '0')
cpuset = Libvirt.pin_vcpu_for_perf(connection, hw_socket)
+ cputune = extra_spec.get('cputune', '')
mac = StandaloneContextHelper.get_mac_address(0x00)
image = cls.create_snapshot_qemu(connection, index,
flavor.get("images", None))
@@ -258,7 +259,7 @@ class Libvirt(object):
memory=memory, vcpu=vcpu, cpu=cpu,
numa_cpus=numa_cpus,
socket=socket, threads=threads,
- vm_image=image, cpuset=cpuset)
+ vm_image=image, cpuset=cpuset, cputune=cputune)
write_file(cfg, vm_xml)
@@ -275,6 +276,7 @@ class Libvirt(object):
sys_obj = CpuSysCores(connection)
soc_cpu = sys_obj.get_core_socket()
sys_cpu = int(soc_cpu["cores_per_socket"])
+ socket = str(socket)
cores = "%s-%s" % (soc_cpu[socket][0], soc_cpu[socket][sys_cpu - 1])
if int(soc_cpu["thread_per_core"]) > 1:
threads = "%s-%s" % (soc_cpu[socket][sys_cpu], soc_cpu[socket][-1])
diff --git a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
index a6c35de53..3755b84e9 100644
--- a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
+++ b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
@@ -129,13 +129,21 @@ class OvsDpdkContext(Context):
ovs_sock_path = '/var/run/openvswitch/db.sock'
log_path = '/var/log/openvswitch/ovs-vswitchd.log'
+ pmd_cpu_mask = self.ovs_properties.get("pmd_cpu_mask", '')
pmd_mask = hex(sum(2 ** num for num in range(pmd_nums)) << 1)
+ if pmd_cpu_mask:
+ pmd_mask = pmd_cpu_mask
+
socket0 = self.ovs_properties.get("ram", {}).get("socket_0", "2048")
socket1 = self.ovs_properties.get("ram", {}).get("socket_1", "2048")
ovs_other_config = "ovs-vsctl {0}set Open_vSwitch . other_config:{1}"
detach_cmd = "ovs-vswitchd unix:{0}{1} --pidfile --detach --log-file={2}"
+ lcore_mask = self.ovs_properties.get("lcore_mask", '')
+ if lcore_mask:
+ lcore_mask = ovs_other_config.format("--no-wait ", "dpdk-lcore-mask='%s'" % lcore_mask)
+
cmd_list = [
"mkdir -p /usr/local/var/run/openvswitch",
"mkdir -p {}".format(os.path.dirname(log_path)),
@@ -143,6 +151,7 @@ class OvsDpdkContext(Context):
ovs_sock_path),
ovs_other_config.format("--no-wait ", "dpdk-init=true"),
ovs_other_config.format("--no-wait ", "dpdk-socket-mem='%s,%s'" % (socket0, socket1)),
+ lcore_mask,
detach_cmd.format(vpath, ovs_sock_path, log_path),
ovs_other_config.format("", "pmd-cpu-mask=%s" % pmd_mask),
]
@@ -296,8 +305,7 @@ class OvsDpdkContext(Context):
except StopIteration:
pass
else:
- raise ValueError("Duplicate nodes!!! Nodes: %s %s",
- (node, duplicate))
+ raise ValueError("Duplicate nodes!!! Nodes: %s %s" % (node, duplicate))
node["name"] = attr_name
return node
diff --git a/yardstick/benchmark/core/__init__.py b/yardstick/benchmark/core/__init__.py
index 70036ea1e..3e3aa99a1 100644
--- a/yardstick/benchmark/core/__init__.py
+++ b/yardstick/benchmark/core/__init__.py
@@ -6,10 +6,15 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+"""
+Yardstick benchmark core.
+"""
+
from __future__ import print_function
class Param(object):
+ """This class converts a parameter dictionary to an object."""
def __init__(self, kwargs):
# list
@@ -31,10 +36,3 @@ class Param(object):
# list
self.type = kwargs.get('type')
-
-
-def print_hbar(barlen):
- """print to stdout a horizontal bar"""
- print("+")
- print("-" * barlen)
- print("+")
diff --git a/yardstick/benchmark/core/runner.py b/yardstick/benchmark/core/runner.py
index 64acdaa99..b5e457c41 100644
--- a/yardstick/benchmark/core/runner.py
+++ b/yardstick/benchmark/core/runner.py
@@ -10,9 +10,10 @@
""" Handler for yardstick command 'runner' """
from __future__ import absolute_import
-from __future__ import print_function
+
+import prettytable
+
from yardstick.benchmark.runners.base import Runner
-from yardstick.benchmark.core import print_hbar
class Runners(object): # pragma: no cover
@@ -21,16 +22,15 @@ class Runners(object): # pragma: no cover
Set of commands to discover and display runner types.
"""
- def list_all(self, args):
+ def list_all(self, *args):
"""List existing runner types"""
types = Runner.get_types()
- print_hbar(78)
- print("| %-16s | %-60s" % ("Type", "Description"))
- print_hbar(78)
+ runner_table = prettytable.PrettyTable(['Type', 'Description'])
+ runner_table.align = 'l'
for rtype in types:
- print("| %-16s | %-60s" % (rtype.__execution_type__,
- rtype.__doc__.split("\n")[0]))
- print_hbar(78)
+ runner_table.add_row([rtype.__execution_type__,
+ rtype.__doc__.split("\n")[0]])
+ print(runner_table)
def show(self, args):
"""Show details of a specific runner type"""
diff --git a/yardstick/benchmark/core/scenario.py b/yardstick/benchmark/core/scenario.py
index 28eb65230..3366172a5 100644
--- a/yardstick/benchmark/core/scenario.py
+++ b/yardstick/benchmark/core/scenario.py
@@ -10,8 +10,9 @@
""" Handler for yardstick command 'scenario' """
from __future__ import absolute_import
+import prettytable
+
from yardstick.benchmark.scenarios.base import Scenario
-from yardstick.benchmark.core import print_hbar
class Scenarios(object): # pragma: no cover
@@ -20,16 +21,15 @@ class Scenarios(object): # pragma: no cover
Set of commands to discover and display scenario types.
"""
- def list_all(self, args):
+ def list_all(self, *args):
"""List existing scenario types"""
types = Scenario.get_types()
- print_hbar(78)
- print("| %-16s | %-60s" % ("Type", "Description"))
- print_hbar(78)
+ scenario_table = prettytable.PrettyTable(['Type', 'Description'])
+ scenario_table.align = 'l'
for scenario_class in types:
- print("| %-16s | %-60s" % (scenario_class.get_scenario_type(),
- scenario_class.get_description()))
- print_hbar(78)
+ scenario_table.add_row([scenario_class.get_scenario_type(),
+ scenario_class.get_description()])
+ print(scenario_table)
def show(self, args):
"""Show details of a specific scenario type"""
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/fault_process_kill.bash b/yardstick/benchmark/scenarios/availability/ha_tools/fault_process_kill.bash
index eec86e133..d34ce9338 100755
--- a/yardstick/benchmark/scenarios/availability/ha_tools/fault_process_kill.bash
+++ b/yardstick/benchmark/scenarios/availability/ha_tools/fault_process_kill.bash
@@ -26,7 +26,7 @@ elif [ "$process_name" = "haproxy" ]; then
kill -9 "${pid}"
done
else
- for pid in $(pgrep -f "/usr/.*/${process_name}");
+ for pid in $(pgrep -fa [^-_a-zA-Z0-9]${process_name} | grep -iv heartbeat | awk '{print $1}');
do
kill -9 "${pid}"
done
diff --git a/yardstick/benchmark/scenarios/compute/spec_cpu.py b/yardstick/benchmark/scenarios/compute/spec_cpu.py
index df361cd94..39cd3fb8c 100644
--- a/yardstick/benchmark/scenarios/compute/spec_cpu.py
+++ b/yardstick/benchmark/scenarios/compute/spec_cpu.py
@@ -10,6 +10,7 @@ from __future__ import absolute_import
import logging
import pkg_resources
+import os
import yardstick.ssh as ssh
from yardstick.benchmark.scenarios import base
@@ -66,6 +67,8 @@ class SpecCPU(base.Scenario):
default: na
"""
__scenario_type__ = "SpecCPU2006"
+ CPU2006_DIR = "~/cpu2006"
+ CPU2006_RESULT_FILE = os.path.join(CPU2006_DIR, "result/CINT2006.001.ref.txt")
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
@@ -87,8 +90,9 @@ class SpecCPU(base.Scenario):
"yardstick.resources", 'files/' + self.runspec_config)
# copy SPEC CPU2006 config file to host if given
- self.client._put_file_shell(self.runspec_config_file,
- '/usr/cpu2006/config/yardstick_spec_cpu2006.cfg')
+ cfg_path = os.path.join(self.CPU2006_DIR,
+ 'config/yardstick_spec_cpu2006.cfg')
+ self.client._put_file_shell(self.runspec_config_file, cfg_path)
else:
self.runspec_config = "Example-linux64-amd64-gcc43+.cfg"
@@ -100,7 +104,8 @@ class SpecCPU(base.Scenario):
if not self.setup_done:
self.setup()
- cmd = "cd /usr/cpu2006/ && . ./shrc && runspec --config %s" % self.runspec_config
+ cmd = "cd %s && . ./shrc && runspec --config %s" % (
+ self.CPU2006_DIR, self.runspec_config)
cmd_args = ""
if "rate" in self.options:
@@ -140,5 +145,12 @@ class SpecCPU(base.Scenario):
if status:
raise RuntimeError(stderr)
+ cmd = "cat %s" % self.CPU2006_RESULT_FILE
+ LOG.debug("Executing command: %s", cmd)
+ status, stdout, stderr = self.client.execute(cmd, timeout=30)
+ if status:
+ raise RuntimeError(stderr)
+ if stdout:
+ LOG.info("SPEC CPU2006 result is:\n%s", stdout)
LOG.info('SPEC CPU2006 benchmark completed, please find benchmark reports \
at /tmp/result directory')
diff --git a/yardstick/benchmark/scenarios/compute/spec_cpu_for_vm.py b/yardstick/benchmark/scenarios/compute/spec_cpu_for_vm.py
new file mode 100644
index 000000000..36489b132
--- /dev/null
+++ b/yardstick/benchmark/scenarios/compute/spec_cpu_for_vm.py
@@ -0,0 +1,170 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+from __future__ import absolute_import
+
+import logging
+import pkg_resources
+import os
+
+import yardstick.ssh as ssh
+from yardstick.benchmark.scenarios import base
+from yardstick.common.constants import YARDSTICK_ROOT_PATH
+
+LOG = logging.getLogger(__name__)
+
+
+class SpecCPUforVM(base.Scenario):
+ """Spec CPU2006 benchmark for Virtual Machine
+
+ Parameters
+ benchmark_subset - Specifies a subset of SPEC CPU2006 benchmarks to run
+ type: string
+ unit: na
+ default: na
+
+ SPECint_benchmark - A SPECint benchmark to run
+ type: string
+ unit: na
+ default: na
+
+ SPECfp_benchmark - A SPECfp benchmark to run
+ type: string
+ unit: na
+ default: na
+
+ output_format - Desired report format
+ type: string
+ unit: na
+ default: na
+
+ runspec_config - SPEC CPU2006 config file provided to the runspec binary
+ type: string
+ unit: na
+ default: "Example-linux64-amd64-gcc43+.cfg"
+
+ runspec_iterations - The number of benchmark iterations to execute.
+ For a reportable run, must be 3.
+ type: int
+ unit: na
+ default: na
+
+ runspec_tune - Tuning to use (base, peak, or all). For a reportable run, must be either
+ base or all. Reportable runs do base first, then (optionally) peak.
+ type: string
+ unit: na
+ default: na
+
+ runspec_size - Size of input data to run (test, train, or ref). Reportable runs ensure
+ that your binaries can produce correct results with the test and train
+ workloads.
+ type: string
+ unit: na
+ default: na
+ """
+ __scenario_type__ = "SpecCPU2006_for_VM"
+ CPU2006_ISO = "cpu2006-1.2.iso"
+ CPU2006_DIR = "~/cpu2006"
+ CPU2006_RESULT_FILE = os.path.join(CPU2006_DIR, "result/CINT2006.001.ref.txt")
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.setup_done = False
+ self.options = self.scenario_cfg['options']
+
+ def setup(self):
+ """scenario setup"""
+ host = self.context_cfg['host']
+ LOG.info("user:%s, host:%s", host['user'], host['ip'])
+ self.client = ssh.SSH.from_node(host, defaults={"user": "ubuntu"})
+ self.client.wait(timeout=600)
+
+ spec_cpu_iso = os.path.join(YARDSTICK_ROOT_PATH,
+ "yardstick/resources/files/",
+ self.CPU2006_ISO)
+
+ self.client.put(spec_cpu_iso, "~/cpu2006-1.2.iso")
+ self.client.execute("sudo mount -t iso9660 -o ro,exec ~/cpu2006-1.2.iso /mnt")
+ self.client.execute("/mnt/install.sh -fd ~/cpu2006")
+
+ if "runspec_config" in self.options:
+ self.runspec_config = self.options["runspec_config"]
+
+ self.runspec_config_file = pkg_resources.resource_filename(
+ "yardstick.resources", 'files/' + self.runspec_config)
+
+ # copy SPEC CPU2006 config file to host if given
+ cfg_path = os.path.join(self.CPU2006_DIR,
+ 'config/yardstick_spec_cpu2006.cfg')
+ self.client._put_file_shell(self.runspec_config_file, cfg_path)
+ else:
+ self.runspec_config = "Example-linux64-amd64-gcc43+.cfg"
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the benchmark"""
+
+ if not self.setup_done:
+ self.setup()
+
+ cmd = "cd %s && . ./shrc && runspec --config %s" % (
+ self.CPU2006_DIR, self.runspec_config)
+ cmd_args = ""
+
+ if "rate" in self.options:
+ cmd_args += " --rate %s" % self.options["runspec_rate"]
+
+ if "output_format" in self.options:
+ cmd_args += " --output_format %s" % self.options["output_format"]
+
+ if "runspec_tune" in self.options:
+ cmd_args += " --tune %s" % self.options["runspec_tune"]
+
+ benchmark_subset = self.options.get('benchmark_subset', None)
+ specint_benchmark = self.options.get('SPECint_benchmark', None)
+ specfp_benchmark = self.options.get('SPECfp_benchmark', None)
+
+ if benchmark_subset:
+ cmd_args += " %s" % benchmark_subset
+ else:
+ cmd_args += " --noreportable"
+
+ if "runspec_iterations" in self.options:
+ cmd_args += " --iterations %s" % self.options["runspec_iterations"]
+
+ if "runspec_size" in self.options:
+ cmd_args += " --size %s" % self.options["runspec_size"]
+
+ if specint_benchmark:
+ cmd_args += " %s" % specint_benchmark
+
+ if specfp_benchmark:
+ cmd_args += " %s" % specfp_benchmark
+
+ cmd += "%s" % cmd_args
+
+ LOG.debug("Executing command: %s", cmd)
+ status, stdout, stderr = self.client.execute(cmd, timeout=86400)
+ if status:
+ raise RuntimeError(stderr)
+
+ cmd = "cat %s" % self.CPU2006_RESULT_FILE
+ LOG.debug("Executing command: %s", cmd)
+ status, stdout, stderr = self.client.execute(cmd, timeout=30)
+ if status:
+ raise RuntimeError(stderr)
+ if stdout:
+ LOG.info("SPEC CPU2006 result is:\n%s", stdout)
+
+ result.update({"SPEC_CPU_result": stdout})
+ # fetch SPEC CPU2006 result files
+ self.client.get('~/cpu2006/result', '/tmp/')
+ LOG.info('SPEC CPU2006 benchmark completed, please find benchmark reports \
+ at /tmp/result directory')
diff --git a/yardstick/benchmark/scenarios/lib/create_volume.py b/yardstick/benchmark/scenarios/lib/create_volume.py
index c7086d0ef..df523a5ec 100644
--- a/yardstick/benchmark/scenarios/lib/create_volume.py
+++ b/yardstick/benchmark/scenarios/lib/create_volume.py
@@ -44,22 +44,21 @@ class CreateVolume(base.Scenario):
self.setup_done = True
- def run(self, result):
+ def run(self):
"""execute the test"""
if not self.setup_done:
self.setup()
- if self.image_name:
- self.image_id = op_utils.get_image_id(self.glance_client,
- self.image_name)
+ self.image_id = op_utils.get_image_id(self.glance_client,
+ self.image_name)
volume = op_utils.create_volume(self.cinder_client, self.volume_name,
self.volume_size, self.image_id)
status = volume.status
while(status == 'creating' or status == 'downloading'):
- LOG.info("Volume status is: %s" % status)
+ LOG.info("Volume status is: %s", status)
time.sleep(5)
volume = op_utils.get_volume_by_name(self.volume_name)
status = volume.status