aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark')
-rw-r--r--yardstick/benchmark/contexts/standalone/model.py102
-rw-r--r--yardstick/benchmark/contexts/standalone/ovs_dpdk.py25
-rw-r--r--yardstick/benchmark/contexts/standalone/sriov.py24
-rw-r--r--yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py2
-rw-r--r--yardstick/benchmark/scenarios/availability/attacker/baseattacker.py1
-rwxr-xr-xyardstick/benchmark/scenarios/availability/serviceha.py6
-rw-r--r--yardstick/benchmark/scenarios/storage/storperf.py92
7 files changed, 204 insertions, 48 deletions
diff --git a/yardstick/benchmark/contexts/standalone/model.py b/yardstick/benchmark/contexts/standalone/model.py
index ecddcbbe0..962cb48e2 100644
--- a/yardstick/benchmark/contexts/standalone/model.py
+++ b/yardstick/benchmark/contexts/standalone/model.py
@@ -89,6 +89,17 @@ VM_TEMPLATE = """
</devices>
</domain>
"""
+
+USER_DATA_TEMPLATE = """
+cat > {user_file} <<EOF
+#cloud-config
+preserve_hostname: false
+hostname: {host}
+users:
+{user_config}
+EOF
+"""
+
WAIT_FOR_BOOT = 30
@@ -268,7 +279,7 @@ class Libvirt(object):
return vm_image
@classmethod
- def build_vm_xml(cls, connection, flavor, vm_name, index):
+ def build_vm_xml(cls, connection, flavor, vm_name, index, cdrom_img):
"""Build the XML from the configuration parameters"""
memory = flavor.get('ram', '4096')
extra_spec = flavor.get('extra_specs', {})
@@ -293,6 +304,9 @@ class Libvirt(object):
socket=socket, threads=threads,
vm_image=image, cpuset=cpuset, cputune=cputune)
+ # Add CD-ROM device
+ vm_xml = Libvirt.add_cdrom(cdrom_img, vm_xml)
+
return vm_xml, mac
@staticmethod
@@ -320,6 +334,71 @@ class Libvirt(object):
et = ET.ElementTree(element=root)
et.write(file_name, encoding='utf-8', method='xml')
+ @classmethod
+ def add_cdrom(cls, file_path, xml_str):
+ """Add a CD-ROM disk XML node in 'devices' node
+
+ <devices>
+ <disk type='file' device='cdrom'>
+ <driver name='qemu' type='raw'/>
+ <source file='/var/lib/libvirt/images/data.img'/>
+ <target dev='hdb'/>
+ <readonly/>
+ </disk>
+ ...
+ </devices>
+ """
+
+ root = ET.fromstring(xml_str)
+ device = root.find('devices')
+
+ disk = ET.SubElement(device, 'disk')
+ disk.set('type', 'file')
+ disk.set('device', 'cdrom')
+
+ driver = ET.SubElement(disk, 'driver')
+ driver.set('name', 'qemu')
+ driver.set('type', 'raw')
+
+ source = ET.SubElement(disk, 'source')
+ source.set('file', file_path)
+
+ target = ET.SubElement(disk, 'target')
+ target.set('dev', 'hdb')
+
+ ET.SubElement(disk, 'readonly')
+ return ET.tostring(root)
+
+ @staticmethod
+ def gen_cdrom_image(connection, file_path, vm_name, vm_user, key_filename):
+ """Generate ISO image for CD-ROM """
+
+ user_config = [" - name: {user_name}",
+ " ssh_authorized_keys:",
+ " - {pub_key_str}"]
+ if vm_user != "root":
+ user_config.append(" sudo: ALL=(ALL) NOPASSWD:ALL")
+
+ meta_data = "/tmp/meta-data"
+ user_data = "/tmp/user-data"
+ with open(".".join([key_filename, "pub"]), "r") as pub_key_file:
+ pub_key_str = pub_key_file.read().rstrip()
+ user_conf = os.linesep.join(user_config).format(pub_key_str=pub_key_str, user_name=vm_user)
+
+ cmd_lst = [
+ "touch %s" % meta_data,
+ USER_DATA_TEMPLATE.format(user_file=user_data, host=vm_name, user_config=user_conf),
+ "genisoimage -output {0} -volid cidata -joliet -r {1} {2}".format(file_path,
+ meta_data,
+ user_data),
+ "rm {0} {1}".format(meta_data, user_data),
+ ]
+ for cmd in cmd_lst:
+ LOG.info(cmd)
+ status, _, error = connection.execute(cmd)
+ if status:
+ raise exceptions.LibvirtQemuImageCreateError(error=error)
+
class StandaloneContextHelper(object):
""" This class handles all the common code for standalone
@@ -331,7 +410,7 @@ class StandaloneContextHelper(object):
@staticmethod
def install_req_libs(connection, extra_pkgs=None):
extra_pkgs = extra_pkgs or []
- pkgs = ["qemu-kvm", "libvirt-bin", "bridge-utils", "numactl", "fping"]
+ pkgs = ["qemu-kvm", "libvirt-bin", "bridge-utils", "numactl", "fping", "genisoimage"]
pkgs.extend(extra_pkgs)
cmd_template = "dpkg-query -W --showformat='${Status}\\n' \"%s\"|grep 'ok installed'"
for pkg in pkgs:
@@ -457,6 +536,25 @@ class StandaloneContextHelper(object):
node["ip"] = ip
return nodes
+ @classmethod
+ def check_update_key(cls, connection, node, vm_name, id_name, cdrom_img):
+ # Generate public/private keys if private key file is not provided
+ user_name = node.get('user')
+ if not user_name:
+ node['user'] = 'root'
+ user_name = node.get('user')
+ if not node.get('key_filename'):
+ key_filename = ''.join(
+ [constants.YARDSTICK_ROOT_PATH,
+ 'yardstick/resources/files/yardstick_key-',
+ id_name])
+ ssh.SSH.gen_keys(key_filename)
+ node['key_filename'] = key_filename
+ # Update image with public key
+ key_filename = node.get('key_filename')
+ Libvirt.gen_cdrom_image(connection, cdrom_img, vm_name, user_name, key_filename)
+ return node
+
class Server(object):
""" This class handles geting vnf nodes
diff --git a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
index 88ad598c3..5891f798e 100644
--- a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
+++ b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
@@ -394,13 +394,14 @@ class OvsDpdkContext(base.Context):
for index, (key, vnf) in enumerate(collections.OrderedDict(
self.servers).items()):
cfg = '/tmp/vm_ovs_%d.xml' % index
- vm_name = "vm_%d" % index
+ vm_name = "vm-%d" % index
+ cdrom_img = "/var/lib/libvirt/images/cdrom-%d.img" % index
# 1. Check and delete VM if already exists
model.Libvirt.check_if_vm_exists_and_delete(vm_name,
self.connection)
xml_str, mac = model.Libvirt.build_vm_xml(
- self.connection, self.vm_flavor, vm_name, index)
+ self.connection, self.vm_flavor, vm_name, index, cdrom_img)
# 2: Cleanup already available VMs
for vfs in [vfs for vfs_name, vfs in vnf["network_ports"].items()
@@ -411,16 +412,24 @@ class OvsDpdkContext(base.Context):
model.Libvirt.write_file(cfg, xml_str)
self.connection.put(cfg, cfg)
+ node = self.vnf_node.generate_vnf_instance(self.vm_flavor,
+ self.networks,
+ self.host_mgmt.get('ip'),
+ key, vnf, mac)
+ # Generate public/private keys if password or private key file is not provided
+ node = model.StandaloneContextHelper.check_update_key(self.connection,
+ node,
+ vm_name,
+ self.name,
+ cdrom_img)
+
+ # store vnf node details
+ nodes.append(node)
+
# NOTE: launch through libvirt
LOG.info("virsh create ...")
model.Libvirt.virsh_create_vm(self.connection, cfg)
self.vm_names.append(vm_name)
- # build vnf node details
- nodes.append(self.vnf_node.generate_vnf_instance(self.vm_flavor,
- self.networks,
- self.host_mgmt.get('ip'),
- key, vnf, mac))
-
return nodes
diff --git a/yardstick/benchmark/contexts/standalone/sriov.py b/yardstick/benchmark/contexts/standalone/sriov.py
index 3da12a9a8..8d410b2f3 100644
--- a/yardstick/benchmark/contexts/standalone/sriov.py
+++ b/yardstick/benchmark/contexts/standalone/sriov.py
@@ -225,13 +225,14 @@ class SriovContext(base.Context):
for index, (key, vnf) in enumerate(collections.OrderedDict(
self.servers).items()):
cfg = '/tmp/vm_sriov_%s.xml' % str(index)
- vm_name = "vm_%s" % str(index)
+ vm_name = "vm-%s" % str(index)
+ cdrom_img = "/var/lib/libvirt/images/cdrom-%d.img" % index
# 1. Check and delete VM if already exists
model.Libvirt.check_if_vm_exists_and_delete(vm_name,
self.connection)
xml_str, mac = model.Libvirt.build_vm_xml(
- self.connection, self.vm_flavor, vm_name, index)
+ self.connection, self.vm_flavor, vm_name, index, cdrom_img)
# 2: Cleanup already available VMs
network_ports = collections.OrderedDict(
@@ -243,17 +244,26 @@ class SriovContext(base.Context):
model.Libvirt.write_file(cfg, xml_str)
self.connection.put(cfg, cfg)
+ node = self.vnf_node.generate_vnf_instance(self.vm_flavor,
+ self.networks,
+ self.host_mgmt.get('ip'),
+ key, vnf, mac)
+ # Generate public/private keys if password or private key file is not provided
+ node = model.StandaloneContextHelper.check_update_key(self.connection,
+ node,
+ vm_name,
+ self.name,
+ cdrom_img)
+
+ # store vnf node details
+ nodes.append(node)
+
# NOTE: launch through libvirt
LOG.info("virsh create ...")
model.Libvirt.virsh_create_vm(self.connection, cfg)
self.vm_names.append(vm_name)
- # build vnf node details
- nodes.append(self.vnf_node.generate_vnf_instance(
- self.vm_flavor, self.networks, self.host_mgmt.get('ip'),
- key, vnf, mac))
-
return nodes
def _get_vf_data(self, value, vfmac, pfif):
diff --git a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py
index 53abd586b..4c79a4931 100644
--- a/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py
+++ b/yardstick/benchmark/scenarios/availability/attacker/attacker_baremetal.py
@@ -34,6 +34,8 @@ class BaremetalAttacker(BaseAttacker):
__attacker_type__ = 'bare-metal-down'
def setup(self):
+ # baremetal down need to recover even sla pass
+ self.mandatory = True
LOG.debug("config:%s context:%s", self._config, self._context)
host = self._context.get(self._config['host'], None)
diff --git a/yardstick/benchmark/scenarios/availability/attacker/baseattacker.py b/yardstick/benchmark/scenarios/availability/attacker/baseattacker.py
index d67a16b98..7871cc918 100644
--- a/yardstick/benchmark/scenarios/availability/attacker/baseattacker.py
+++ b/yardstick/benchmark/scenarios/availability/attacker/baseattacker.py
@@ -63,6 +63,7 @@ class BaseAttacker(object):
self.data = {}
self.setup_done = False
self.intermediate_variables = {}
+ self.mandatory = False
@staticmethod
def get_attacker_cls(attacker_cfg):
diff --git a/yardstick/benchmark/scenarios/availability/serviceha.py b/yardstick/benchmark/scenarios/availability/serviceha.py
index 7f976fdbc..fdfe7cbbe 100755
--- a/yardstick/benchmark/scenarios/availability/serviceha.py
+++ b/yardstick/benchmark/scenarios/availability/serviceha.py
@@ -88,9 +88,9 @@ class ServiceHA(base.Scenario):
def teardown(self):
"""scenario teardown"""
- # only recover when sla not pass
- if not self.sla_pass:
- for attacker in self.attackers:
+ # recover when mandatory or sla not pass
+ for attacker in self.attackers:
+ if attacker.mandatory or not self.sla_pass:
attacker.recover()
diff --git a/yardstick/benchmark/scenarios/storage/storperf.py b/yardstick/benchmark/scenarios/storage/storperf.py
index f0b2361d6..8093cd2d2 100644
--- a/yardstick/benchmark/scenarios/storage/storperf.py
+++ b/yardstick/benchmark/scenarios/storage/storperf.py
@@ -8,15 +8,16 @@
##############################################################################
from __future__ import absolute_import
-import os
import logging
+import os
import time
-import requests
from oslo_serialization import jsonutils
+import requests
from yardstick.benchmark.scenarios import base
+
LOG = logging.getLogger(__name__)
@@ -43,12 +44,6 @@ class StorPerf(base.Scenario):
wr: 100% Write, random access
rw: 70% Read / 30% write, random access
- nossd (Optional):
- Do not perform SSD style preconditioning.
-
- nowarm (Optional):
- Do not perform a warmup prior to measurements.
-
report = [job_id] (Optional):
Query the status of the supplied job_id and report on metrics.
If a workload is supplied, will report on only that subset.
@@ -79,10 +74,13 @@ class StorPerf(base.Scenario):
setup_query_content = jsonutils.loads(
setup_query.content)
- if setup_query_content["stack_created"]:
- self.setup_done = True
+ if ("stack_created" in setup_query_content and
+ setup_query_content["stack_created"]):
LOG.debug("stack_created: %s",
setup_query_content["stack_created"])
+ return True
+
+ return False
def setup(self):
"""Set the configuration."""
@@ -111,9 +109,13 @@ class StorPerf(base.Scenario):
elif setup_res.status_code == 200:
LOG.info("stack_id: %s", setup_res_content["stack_id"])
- while not self.setup_done:
- self._query_setup_state()
- time.sleep(self.query_interval)
+ while not self._query_setup_state():
+ time.sleep(self.query_interval)
+
+ # We do not want to load the results of the disk initialization,
+ # so it is not added to the results here.
+ self.initialize_disks()
+ self.setup_done = True
def _query_job_state(self, job_id):
"""Query the status of the supplied job_id and report on metrics"""
@@ -149,7 +151,8 @@ class StorPerf(base.Scenario):
if not self.setup_done:
self.setup()
- metadata = {"build_tag": "latest", "test_case": "opnfv_yardstick_tc074"}
+ metadata = {"build_tag": "latest",
+ "test_case": "opnfv_yardstick_tc074"}
metadata_payload_dict = {"pod_name": "NODE_NAME",
"scenario_name": "DEPLOY_SCENARIO",
"version": "YARDSTICK_BRANCH"}
@@ -162,7 +165,9 @@ class StorPerf(base.Scenario):
job_args = {"metadata": metadata}
job_args_payload_list = ["block_sizes", "queue_depths", "deadline",
- "target", "nossd", "nowarm", "workload"]
+ "target", "workload", "workloads",
+ "agent_count", "steady_state_samples"]
+ job_args["deadline"] = self.options["timeout"]
for job_argument in job_args_payload_list:
try:
@@ -170,8 +175,16 @@ class StorPerf(base.Scenario):
except KeyError:
pass
+ api_version = "v1.0"
+
+ if ("workloads" in job_args and
+ job_args["workloads"] is not None and
+ len(job_args["workloads"])) > 0:
+ api_version = "v2.0"
+
LOG.info("Starting a job with parameters %s", job_args)
- job_res = requests.post('http://%s:5000/api/v1.0/jobs' % self.target,
+ job_res = requests.post('http://%s:5000/api/%s/jobs' % (self.target,
+ api_version),
json=job_args)
job_res_content = jsonutils.loads(job_res.content)
@@ -187,15 +200,6 @@ class StorPerf(base.Scenario):
self._query_job_state(job_id)
time.sleep(self.query_interval)
- terminate_res = requests.delete('http://%s:5000/api/v1.0/jobs' %
- self.target)
-
- if terminate_res.status_code != 200:
- terminate_res_content = jsonutils.loads(
- terminate_res.content)
- raise RuntimeError("Failed to start a job, error message:",
- terminate_res_content["message"])
-
# TODO: Support using ETA to polls for completion.
# Read ETA, next poll in 1/2 ETA time slot.
# If ETA is greater than the maximum allowed job time,
@@ -216,14 +220,46 @@ class StorPerf(base.Scenario):
result.update(result_res_content)
+ def initialize_disks(self):
+ """Fills the target with random data prior to executing workloads"""
+
+ job_args = {}
+ job_args_payload_list = ["target"]
+
+ for job_argument in job_args_payload_list:
+ try:
+ job_args[job_argument] = self.options[job_argument]
+ except KeyError:
+ pass
+
+ LOG.info("Starting initialization with parameters %s", job_args)
+ job_res = requests.post('http://%s:5000/api/v1.0/initializations' %
+ self.target, json=job_args)
+
+ job_res_content = jsonutils.loads(job_res.content)
+
+ if job_res.status_code != 200:
+ raise RuntimeError(
+ "Failed to start initialization job, error message:",
+ job_res_content["message"])
+ elif job_res.status_code == 200:
+ job_id = job_res_content["job_id"]
+ LOG.info("Started initialization as job id: %s...", job_id)
+
+ while not self.job_completed:
+ self._query_job_state(job_id)
+ time.sleep(self.query_interval)
+
+ self.job_completed = False
+
def teardown(self):
"""Deletes the agent configuration and the stack"""
- teardown_res = requests.delete('http://%s:5000/api/v1.0/\
- configurations' % self.target)
+ teardown_res = requests.delete(
+ 'http://%s:5000/api/v1.0/configurations' % self.target)
if teardown_res.status_code == 400:
teardown_res_content = jsonutils.loads(
- teardown_res.content)
+ teardown_res.json_data)
raise RuntimeError("Failed to reset environment, error message:",
teardown_res_content['message'])