aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark')
-rw-r--r--yardstick/benchmark/contexts/base.py7
-rw-r--r--yardstick/benchmark/contexts/heat.py9
-rw-r--r--yardstick/benchmark/contexts/standalone/model.py92
-rw-r--r--yardstick/benchmark/contexts/standalone/ovs_dpdk.py207
-rw-r--r--yardstick/benchmark/contexts/standalone/sriov.py63
-rw-r--r--yardstick/benchmark/core/task.py45
-rwxr-xr-xyardstick/benchmark/runners/base.py2
-rw-r--r--yardstick/benchmark/runners/duration.py6
-rw-r--r--yardstick/benchmark/runners/iteration.py6
-rw-r--r--yardstick/benchmark/scenarios/availability/scenario_general.py28
-rwxr-xr-xyardstick/benchmark/scenarios/availability/serviceha.py19
-rw-r--r--yardstick/benchmark/scenarios/base.py30
-rw-r--r--yardstick/benchmark/scenarios/compute/unixbench_benchmark.bash2
-rw-r--r--yardstick/benchmark/scenarios/lib/attach_volume.py35
-rw-r--r--yardstick/benchmark/scenarios/lib/create_floating_ip.py32
-rw-r--r--yardstick/benchmark/scenarios/lib/create_keypair.py49
-rw-r--r--yardstick/benchmark/scenarios/lib/create_sec_group.py40
-rw-r--r--yardstick/benchmark/scenarios/lib/create_server.py74
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_floating_ip.py26
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_keypair.py29
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_network.py24
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_router_interface.py28
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_server.py33
-rw-r--r--yardstick/benchmark/scenarios/lib/get_flavor.py37
-rw-r--r--yardstick/benchmark/scenarios/lib/get_server.py84
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen_dpdk.py23
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen_dpdk_latency_benchmark.bash32
-rw-r--r--yardstick/benchmark/scenarios/networking/testpmd_fwd.bash16
-rw-r--r--yardstick/benchmark/scenarios/networking/vnf_generic.py9
29 files changed, 594 insertions, 493 deletions
diff --git a/yardstick/benchmark/contexts/base.py b/yardstick/benchmark/contexts/base.py
index ae8319e37..692c16892 100644
--- a/yardstick/benchmark/contexts/base.py
+++ b/yardstick/benchmark/contexts/base.py
@@ -6,17 +6,20 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
+
import abc
import six
-import yardstick.common.utils as utils
+from yardstick.common import constants
+from yardstick.common import utils
class Flags(object):
"""Class to represent the status of the flags in a context"""
_FLAGS = {'no_setup': False,
- 'no_teardown': False}
+ 'no_teardown': False,
+ 'os_cloud_config': constants.OS_CLOUD_DEFAULT_CONFIG}
def __init__(self, **kwargs):
for name, value in self._FLAGS.items():
diff --git a/yardstick/benchmark/contexts/heat.py b/yardstick/benchmark/contexts/heat.py
index 0d1dfb86f..82861829e 100644
--- a/yardstick/benchmark/contexts/heat.py
+++ b/yardstick/benchmark/contexts/heat.py
@@ -7,9 +7,6 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import absolute_import
-from __future__ import print_function
-
import collections
import logging
import os
@@ -328,8 +325,10 @@ class HeatContext(Context):
if not os.path.exists(self.key_filename):
SSH.gen_keys(self.key_filename)
- heat_template = HeatTemplate(self.name, self.template_file,
- self.heat_parameters)
+ heat_template = HeatTemplate(
+ self.name, template_file=self.template_file,
+ heat_parameters=self.heat_parameters,
+ os_cloud_config=self._flags.os_cloud_config)
if self.template_file is None:
self._add_resources_to_template(heat_template)
diff --git a/yardstick/benchmark/contexts/standalone/model.py b/yardstick/benchmark/contexts/standalone/model.py
index 14738da8a..4d43f2611 100644
--- a/yardstick/benchmark/contexts/standalone/model.py
+++ b/yardstick/benchmark/contexts/standalone/model.py
@@ -12,7 +12,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import absolute_import
import os
import re
import time
@@ -25,11 +24,12 @@ from netaddr import IPNetwork
import xml.etree.ElementTree as ET
from yardstick import ssh
-from yardstick.common.constants import YARDSTICK_ROOT_PATH
+from yardstick.common import constants
+from yardstick.common import exceptions
from yardstick.common.yaml_loader import yaml_load
from yardstick.network_services.utils import PciAddress
from yardstick.network_services.helpers.cpu import CpuSysCores
-from yardstick.common.utils import write_file
+
LOG = logging.getLogger(__name__)
@@ -106,12 +106,17 @@ class Libvirt(object):
@staticmethod
def virsh_create_vm(connection, cfg):
- err = connection.execute("virsh create %s" % cfg)[0]
- LOG.info("VM create status: %s", err)
+ LOG.info('VM create, XML config: %s', cfg)
+ status, _, error = connection.execute('virsh create %s' % cfg)
+ if status:
+ raise exceptions.LibvirtCreateError(error=error)
@staticmethod
def virsh_destroy_vm(vm_name, connection):
- connection.execute("virsh destroy %s" % vm_name)
+ LOG.info('VM destroy, VM name: %s', vm_name)
+ status, _, error = connection.execute('virsh destroy %s' % vm_name)
+ if status:
+ LOG.warning('Error destroying VM %s. Error: %s', vm_name, error)
@staticmethod
def _add_interface_address(interface, pci_address):
@@ -132,7 +137,7 @@ class Libvirt(object):
return vm_pci
@classmethod
- def add_ovs_interface(cls, vpath, port_num, vpci, vports_mac, xml):
+ def add_ovs_interface(cls, vpath, port_num, vpci, vports_mac, xml_str):
"""Add a DPDK OVS 'interface' XML node in 'devices' node
<devices>
@@ -156,7 +161,7 @@ class Libvirt(object):
vhost_path = ('{0}/var/run/openvswitch/dpdkvhostuser{1}'.
format(vpath, port_num))
- root = ET.parse(xml)
+ root = ET.fromstring(xml_str)
pci_address = PciAddress(vpci.strip())
device = root.find('devices')
@@ -181,10 +186,10 @@ class Libvirt(object):
cls._add_interface_address(interface, pci_address)
- root.write(xml)
+ return ET.tostring(root)
@classmethod
- def add_sriov_interfaces(cls, vm_pci, vf_pci, vf_mac, xml):
+ def add_sriov_interfaces(cls, vm_pci, vf_pci, vf_mac, xml_str):
"""Add a SR-IOV 'interface' XML node in 'devices' node
<devices>
@@ -207,7 +212,7 @@ class Libvirt(object):
-sr_iov-how_sr_iov_libvirt_works
"""
- root = ET.parse(xml)
+ root = ET.fromstring(xml_str)
device = root.find('devices')
interface = ET.SubElement(device, 'interface')
@@ -224,20 +229,47 @@ class Libvirt(object):
pci_vm_address = PciAddress(vm_pci.strip())
cls._add_interface_address(interface, pci_vm_address)
- root.write(xml)
+ return ET.tostring(root)
@staticmethod
- def create_snapshot_qemu(connection, index, vm_image):
- # build snapshot image
- image = "/var/lib/libvirt/images/%s.qcow2" % index
- connection.execute("rm %s" % image)
- qemu_template = "qemu-img create -f qcow2 -o backing_file=%s %s"
- connection.execute(qemu_template % (vm_image, image))
+ def create_snapshot_qemu(connection, index, base_image):
+ """Create the snapshot image for a VM using a base image
- return image
+ :param connection: SSH connection to the remote host
+ :param index: index of the VM to be spawn
+ :param base_image: path of the VM base image in the remote host
+ :return: snapshot image path
+ """
+ vm_image = '/var/lib/libvirt/images/%s.qcow2' % index
+ connection.execute('rm -- "%s"' % vm_image)
+ status, _, _ = connection.execute('test -r %s' % base_image)
+ if status:
+ if not os.access(base_image, os.R_OK):
+ raise exceptions.LibvirtQemuImageBaseImageNotPresent(
+ vm_image=vm_image, base_image=base_image)
+ # NOTE(ralonsoh): done in two steps to avoid root permission
+ # issues.
+ LOG.info('Copy %s from execution host to remote host', base_image)
+ file_name = os.path.basename(os.path.normpath(base_image))
+ connection.put_file(base_image, '/tmp/%s' % file_name)
+ status, _, error = connection.execute(
+ 'mv -- "/tmp/%s" "%s"' % (file_name, base_image))
+ if status:
+ raise exceptions.LibvirtQemuImageCreateError(
+ vm_image=vm_image, base_image=base_image, error=error)
+
+ LOG.info('Convert image %s to %s', base_image, vm_image)
+ qemu_cmd = ('qemu-img create -f qcow2 -o backing_file=%s %s' %
+ (base_image, vm_image))
+ status, _, error = connection.execute(qemu_cmd)
+ if status:
+ raise exceptions.LibvirtQemuImageCreateError(
+ vm_image=vm_image, base_image=base_image, error=error)
+ return vm_image
@classmethod
- def build_vm_xml(cls, connection, flavor, cfg, vm_name, index):
+ def build_vm_xml(cls, connection, flavor, vm_name, index):
+ """Build the XML from the configuration parameters"""
memory = flavor.get('ram', '4096')
extra_spec = flavor.get('extra_specs', {})
cpu = extra_spec.get('hw:cpu_cores', '2')
@@ -261,9 +293,7 @@ class Libvirt(object):
socket=socket, threads=threads,
vm_image=image, cpuset=cpuset, cputune=cputune)
- write_file(cfg, vm_xml)
-
- return [vcpu, mac]
+ return vm_xml, mac
@staticmethod
def update_interrupts_hugepages_perf(connection):
@@ -283,6 +313,13 @@ class Libvirt(object):
cpuset = "%s,%s" % (cores, threads)
return cpuset
+ @classmethod
+ def write_file(cls, file_name, xml_str):
+ """Dump a XML string to a file"""
+ root = ET.fromstring(xml_str)
+ et = ET.ElementTree(element=root)
+ et.write(file_name, encoding='utf-8', method='xml')
+
class StandaloneContextHelper(object):
""" This class handles all the common code for standalone
@@ -374,7 +411,8 @@ class StandaloneContextHelper(object):
except IOError as io_error:
if io_error.errno != errno.ENOENT:
raise
- self.file_path = os.path.join(YARDSTICK_ROOT_PATH, file_path)
+ self.file_path = os.path.join(constants.YARDSTICK_ROOT_PATH,
+ file_path)
cfg = self.read_config_file()
nodes.extend([node for node in cfg["nodes"] if str(node["role"]) != nfvi_role])
@@ -506,7 +544,7 @@ class OvsDeploy(object):
StandaloneContextHelper.install_req_libs(self.connection, pkgs)
def ovs_deploy(self):
- ovs_deploy = os.path.join(YARDSTICK_ROOT_PATH,
+ ovs_deploy = os.path.join(constants.YARDSTICK_ROOT_PATH,
"yardstick/resources/scripts/install/",
self.OVS_DEPLOY_SCRIPT)
if os.path.isfile(ovs_deploy):
@@ -522,4 +560,6 @@ class OvsDeploy(object):
cmd = "sudo -E %s --ovs='%s' --dpdk='%s' -p='%s'" % (remote_ovs_deploy,
ovs, dpdk, http_proxy)
- self.connection.execute(cmd)
+ exit_status, _, stderr = self.connection.execute(cmd)
+ if exit_status:
+ raise exceptions.OVSDeployError(stderr=stderr)
diff --git a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
index a18b42ea5..b9e66a481 100644
--- a/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
+++ b/yardstick/benchmark/contexts/standalone/ovs_dpdk.py
@@ -12,26 +12,25 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-from __future__ import absolute_import
-import os
-import logging
+import io
import collections
+import logging
+import os
+import re
import time
-from collections import OrderedDict
-
from yardstick import ssh
from yardstick.network_services.utils import get_nsb_option
-from yardstick.network_services.utils import provision_tool
from yardstick.benchmark.contexts.base import Context
-from yardstick.benchmark.contexts.standalone.model import Libvirt
-from yardstick.benchmark.contexts.standalone.model import StandaloneContextHelper
-from yardstick.benchmark.contexts.standalone.model import Server
-from yardstick.benchmark.contexts.standalone.model import OvsDeploy
-from yardstick.network_services.utils import PciAddress
+from yardstick.benchmark.contexts.standalone import model
+from yardstick.common import exceptions
+from yardstick.network_services import utils
+
LOG = logging.getLogger(__name__)
+MAIN_BRIDGE = 'br0'
+
class OvsDpdkContext(Context):
""" This class handles OVS standalone nodes - VM running on Non-Managed NFVi
@@ -50,14 +49,15 @@ class OvsDpdkContext(Context):
}
DEFAULT_OVS = '2.6.0'
-
- PKILL_TEMPLATE = "pkill %s %s"
+ CMD_TIMEOUT = 30
+ DEFAULT_USER_PATH = '/usr/local'
def __init__(self):
self.file_path = None
self.sriov = []
self.first_run = True
- self.dpdk_devbind = ''
+ self.dpdk_devbind = os.path.join(get_nsb_option('bin_path'),
+ 'dpdk-devbind.py')
self.vm_names = []
self.nfvi_host = []
self.nodes = []
@@ -65,8 +65,8 @@ class OvsDpdkContext(Context):
self.attrs = {}
self.vm_flavor = None
self.servers = None
- self.helper = StandaloneContextHelper()
- self.vnf_node = Server()
+ self.helper = model.StandaloneContextHelper()
+ self.vnf_node = model.Server()
self.ovs_properties = {}
self.wait_for_vswitchd = 10
super(OvsDpdkContext, self).__init__()
@@ -93,34 +93,32 @@ class OvsDpdkContext(Context):
LOG.debug("Networks: %r", self.networks)
def setup_ovs(self):
- vpath = self.ovs_properties.get("vpath", "/usr/local")
- xargs_kill_cmd = self.PKILL_TEMPLATE % ('-9', 'ovs')
-
+ """Initialize OVS-DPDK"""
+ vpath = self.ovs_properties.get('vpath', self.DEFAULT_USER_PATH)
create_from = os.path.join(vpath, 'etc/openvswitch/conf.db')
create_to = os.path.join(vpath, 'share/openvswitch/vswitch.ovsschema')
cmd_list = [
- "chmod 0666 /dev/vfio/*",
- "chmod a+x /dev/vfio",
- "pkill -9 ovs",
- xargs_kill_cmd,
- "killall -r 'ovs*'",
- "mkdir -p {0}/etc/openvswitch".format(vpath),
- "mkdir -p {0}/var/run/openvswitch".format(vpath),
- "rm {0}/etc/openvswitch/conf.db".format(vpath),
- "ovsdb-tool create {0} {1}".format(create_from, create_to),
- "modprobe vfio-pci",
- "chmod a+x /dev/vfio",
- "chmod 0666 /dev/vfio/*",
+ 'killall -r "ovs.*" -q | true',
+ 'mkdir -p {0}/etc/openvswitch'.format(vpath),
+ 'mkdir -p {0}/var/run/openvswitch'.format(vpath),
+ 'rm {0}/etc/openvswitch/conf.db | true'.format(vpath),
+ 'ovsdb-tool create {0} {1}'.format(create_from, create_to),
+ 'modprobe vfio-pci',
+ 'chmod a+x /dev/vfio',
+ 'chmod 0666 /dev/vfio/*',
]
- for cmd in cmd_list:
- self.connection.execute(cmd)
- bind_cmd = "{dpdk_devbind} --force -b {driver} {port}"
- phy_driver = "vfio-pci"
+
+ bind_cmd = '%s --force -b vfio-pci {port}' % self.dpdk_devbind
for port in self.networks.values():
- vpci = port.get("phy_port")
- self.connection.execute(bind_cmd.format(
- dpdk_devbind=self.dpdk_devbind, driver=phy_driver, port=vpci))
+ cmd_list.append(bind_cmd.format(port=port.get('phy_port')))
+
+ for cmd in cmd_list:
+ LOG.info(cmd)
+ exit_status, _, stderr = self.connection.execute(
+ cmd, timeout=self.CMD_TIMEOUT)
+ if exit_status:
+ raise exceptions.OVSSetupError(command=cmd, error=stderr)
def start_ovs_serverswitch(self):
vpath = self.ovs_properties.get("vpath")
@@ -166,56 +164,78 @@ class OvsDpdkContext(Context):
vpath = self.ovs_properties.get("vpath", "/usr/local")
version = self.ovs_properties.get('version', {})
ovs_ver = [int(x) for x in version.get('ovs', self.DEFAULT_OVS).split('.')]
- ovs_add_port = \
- "ovs-vsctl add-port {br} {port} -- set Interface {port} type={type_}{dpdk_args}"
- ovs_add_queue = "ovs-vsctl set Interface {port} options:n_rxq={queue}"
- chmod_vpath = "chmod 0777 {0}/var/run/openvswitch/dpdkvhostuser*"
-
- cmd_dpdk_list = [
- "ovs-vsctl del-br br0",
- "rm -rf {0}/var/run/openvswitch/dpdkvhostuser*".format(vpath),
- "ovs-vsctl add-br br0 -- set bridge br0 datapath_type=netdev",
+ ovs_add_port = ('ovs-vsctl add-port {br} {port} -- '
+ 'set Interface {port} type={type_}{dpdk_args}')
+ ovs_add_queue = 'ovs-vsctl set Interface {port} options:n_rxq={queue}'
+ chmod_vpath = 'chmod 0777 {0}/var/run/openvswitch/dpdkvhostuser*'
+
+ cmd_list = [
+ 'ovs-vsctl --if-exists del-br {0}'.format(MAIN_BRIDGE),
+ 'rm -rf {0}/var/run/openvswitch/dpdkvhostuser*'.format(vpath),
+ 'ovs-vsctl add-br {0} -- set bridge {0} datapath_type=netdev'.
+ format(MAIN_BRIDGE)
]
- ordered_network = OrderedDict(self.networks)
+ ordered_network = collections.OrderedDict(self.networks)
for index, vnf in enumerate(ordered_network.values()):
if ovs_ver >= [2, 7, 0]:
dpdk_args = " options:dpdk-devargs=%s" % vnf.get("phy_port")
- dpdk_list.append(ovs_add_port.format(br='br0', port='dpdk%s' % vnf.get("port_num", 0),
- type_='dpdk', dpdk_args=dpdk_args))
- dpdk_list.append(ovs_add_queue.format(port='dpdk%s' % vnf.get("port_num", 0),
- queue=self.ovs_properties.get("queues", 1)))
+ dpdk_list.append(ovs_add_port.format(
+ br=MAIN_BRIDGE, port='dpdk%s' % vnf.get("port_num", 0),
+ type_='dpdk', dpdk_args=dpdk_args))
+ dpdk_list.append(ovs_add_queue.format(
+ port='dpdk%s' % vnf.get("port_num", 0),
+ queue=self.ovs_properties.get("queues", 1)))
# Sorting the array to make sure we execute dpdk0... in the order
list.sort(dpdk_list)
- cmd_dpdk_list.extend(dpdk_list)
+ cmd_list.extend(dpdk_list)
# Need to do two for loop to maintain the dpdk/vhost ports.
for index, _ in enumerate(ordered_network):
- cmd_dpdk_list.append(ovs_add_port.format(br='br0', port='dpdkvhostuser%s' % index,
- type_='dpdkvhostuser', dpdk_args=""))
-
- for cmd in cmd_dpdk_list:
- LOG.info(cmd)
- self.connection.execute(cmd)
-
- # Fixme: add flows code
- ovs_flow = "ovs-ofctl add-flow br0 in_port=%s,action=output:%s"
+ cmd_list.append(ovs_add_port.format(
+ br=MAIN_BRIDGE, port='dpdkvhostuser%s' % index,
+ type_='dpdkvhostuser', dpdk_args=""))
+ ovs_flow = ("ovs-ofctl add-flow {0} in_port=%s,action=output:%s".
+ format(MAIN_BRIDGE))
network_count = len(ordered_network) + 1
for in_port, out_port in zip(range(1, network_count),
range(network_count, network_count * 2)):
- self.connection.execute(ovs_flow % (in_port, out_port))
- self.connection.execute(ovs_flow % (out_port, in_port))
+ cmd_list.append(ovs_flow % (in_port, out_port))
+ cmd_list.append(ovs_flow % (out_port, in_port))
- self.connection.execute(chmod_vpath.format(vpath))
+ cmd_list.append(chmod_vpath.format(vpath))
+
+ for cmd in cmd_list:
+ LOG.info(cmd)
+ exit_status, _, stderr = self.connection.execute(
+ cmd, timeout=self.CMD_TIMEOUT)
+ if exit_status:
+ raise exceptions.OVSSetupError(command=cmd, error=stderr)
+
+ def _check_hugepages(self):
+ meminfo = io.BytesIO()
+ self.connection.get_file_obj('/proc/meminfo', meminfo)
+ regex = re.compile(r"HugePages_Total:\s+(?P<hp_total>\d+)[\n\r]"
+ r"HugePages_Free:\s+(?P<hp_free>\d+)")
+ match = regex.search(meminfo.getvalue().decode('utf-8'))
+ if not match:
+ raise exceptions.OVSHugepagesInfoError()
+ if int(match.group('hp_total')) == 0:
+ raise exceptions.OVSHugepagesNotConfigured()
+ if int(match.group('hp_free')) == 0:
+ raise exceptions.OVSHugepagesZeroFree(
+ total_hugepages=int(match.group('hp_total')))
def cleanup_ovs_dpdk_env(self):
- self.connection.execute("ovs-vsctl del-br br0")
+ self.connection.execute(
+ 'ovs-vsctl --if-exists del-br {0}'.format(MAIN_BRIDGE))
self.connection.execute("pkill -9 ovs")
def check_ovs_dpdk_env(self):
self.cleanup_ovs_dpdk_env()
+ self._check_hugepages()
version = self.ovs_properties.get("version", {})
ovs_ver = version.get("ovs", self.DEFAULT_OVS)
@@ -223,13 +243,15 @@ class OvsDpdkContext(Context):
supported_version = self.SUPPORTED_OVS_TO_DPDK_MAP.get(ovs_ver, None)
if supported_version is None or supported_version.split('.')[:2] != dpdk_ver[:2]:
- raise Exception("Unsupported ovs '{}'. Please check the config...".format(ovs_ver))
+ raise exceptions.OVSUnsupportedVersion(
+ ovs_version=ovs_ver,
+ ovs_to_dpdk_map=self.SUPPORTED_OVS_TO_DPDK_MAP)
status = self.connection.execute("ovs-vsctl -V | grep -i '%s'" % ovs_ver)[0]
if status:
- deploy = OvsDeploy(self.connection,
- get_nsb_option("bin_path"),
- self.ovs_properties)
+ deploy = model.OvsDeploy(self.connection,
+ utils.get_nsb_option("bin_path"),
+ self.ovs_properties)
deploy.ovs_deploy()
def deploy(self):
@@ -240,15 +262,12 @@ class OvsDpdkContext(Context):
return
self.connection = ssh.SSH.from_node(self.host_mgmt)
- self.dpdk_devbind = provision_tool(
- self.connection,
- os.path.join(get_nsb_option("bin_path"), "dpdk-devbind.py"))
# Check dpdk/ovs version, if not present install
self.check_ovs_dpdk_env()
# Todo: NFVi deploy (sriov, vswitch, ovs etc) based on the config.
- StandaloneContextHelper.install_req_libs(self.connection)
- self.networks = StandaloneContextHelper.get_nic_details(
+ model.StandaloneContextHelper.install_req_libs(self.connection)
+ self.networks = model.StandaloneContextHelper.get_nic_details(
self.connection, self.networks, self.dpdk_devbind)
self.setup_ovs()
@@ -256,9 +275,8 @@ class OvsDpdkContext(Context):
self.setup_ovs_bridge_add_flows()
self.nodes = self.setup_ovs_dpdk_context()
LOG.debug("Waiting for VM to come up...")
- self.nodes = StandaloneContextHelper.wait_for_vnfs_to_start(self.connection,
- self.servers,
- self.nodes)
+ self.nodes = model.StandaloneContextHelper.wait_for_vnfs_to_start(
+ self.connection, self.servers, self.nodes)
def undeploy(self):
@@ -278,7 +296,7 @@ class OvsDpdkContext(Context):
# Todo: NFVi undeploy (sriov, vswitch, ovs etc) based on the config.
for vm in self.vm_names:
- Libvirt.check_if_vm_exists_and_delete(vm, self.connection)
+ model.Libvirt.check_if_vm_exists_and_delete(vm, self.connection)
def _get_server(self, attr_name):
"""lookup server info by name from context
@@ -333,50 +351,53 @@ class OvsDpdkContext(Context):
return result
def configure_nics_for_ovs_dpdk(self):
- portlist = OrderedDict(self.networks)
+ portlist = collections.OrderedDict(self.networks)
for key in portlist:
- mac = StandaloneContextHelper.get_mac_address()
+ mac = model.StandaloneContextHelper.get_mac_address()
portlist[key].update({'mac': mac})
self.networks = portlist
LOG.info("Ports %s", self.networks)
- def _enable_interfaces(self, index, vfs, cfg):
+ def _enable_interfaces(self, index, vfs, xml_str):
vpath = self.ovs_properties.get("vpath", "/usr/local")
vf = self.networks[vfs[0]]
port_num = vf.get('port_num', 0)
- vpci = PciAddress(vf['vpci'].strip())
+ vpci = utils.PciAddress(vf['vpci'].strip())
# Generate the vpci for the interfaces
slot = index + port_num + 10
vf['vpci'] = \
"{}:{}:{:02x}.{}".format(vpci.domain, vpci.bus, slot, vpci.function)
- Libvirt.add_ovs_interface(vpath, port_num, vf['vpci'], vf['mac'], str(cfg))
+ return model.Libvirt.add_ovs_interface(
+ vpath, port_num, vf['vpci'], vf['mac'], xml_str)
def setup_ovs_dpdk_context(self):
nodes = []
self.configure_nics_for_ovs_dpdk()
- for index, (key, vnf) in enumerate(OrderedDict(self.servers).items()):
+ for index, (key, vnf) in enumerate(collections.OrderedDict(
+ self.servers).items()):
cfg = '/tmp/vm_ovs_%d.xml' % index
vm_name = "vm_%d" % index
# 1. Check and delete VM if already exists
- Libvirt.check_if_vm_exists_and_delete(vm_name, self.connection)
+ 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)
- _, mac = Libvirt.build_vm_xml(self.connection, self.vm_flavor,
- cfg, vm_name, index)
# 2: Cleanup already available VMs
- for vkey, vfs in OrderedDict(vnf["network_ports"]).items():
- if vkey == "mgmt":
- continue
- self._enable_interfaces(index, vfs, cfg)
+ for vfs in [vfs for vfs_name, vfs in vnf["network_ports"].items()
+ if vfs_name != 'mgmt']:
+ xml_str = self._enable_interfaces(index, vfs, xml_str)
# copy xml to target...
+ model.Libvirt.write_file(cfg, xml_str)
self.connection.put(cfg, cfg)
# NOTE: launch through libvirt
LOG.info("virsh create ...")
- Libvirt.virsh_create_vm(self.connection, cfg)
+ model.Libvirt.virsh_create_vm(self.connection, cfg)
self.vm_names.append(vm_name)
diff --git a/yardstick/benchmark/contexts/standalone/sriov.py b/yardstick/benchmark/contexts/standalone/sriov.py
index d7620552b..95472fdda 100644
--- a/yardstick/benchmark/contexts/standalone/sriov.py
+++ b/yardstick/benchmark/contexts/standalone/sriov.py
@@ -16,15 +16,11 @@ from __future__ import absolute_import
import os
import logging
import collections
-from collections import OrderedDict
from yardstick import ssh
from yardstick.network_services.utils import get_nsb_option
-from yardstick.network_services.utils import provision_tool
from yardstick.benchmark.contexts.base import Context
-from yardstick.benchmark.contexts.standalone.model import Libvirt
-from yardstick.benchmark.contexts.standalone.model import StandaloneContextHelper
-from yardstick.benchmark.contexts.standalone.model import Server
+from yardstick.benchmark.contexts.standalone import model
from yardstick.network_services.utils import PciAddress
LOG = logging.getLogger(__name__)
@@ -41,7 +37,8 @@ class SriovContext(Context):
self.file_path = None
self.sriov = []
self.first_run = True
- self.dpdk_devbind = ''
+ self.dpdk_devbind = os.path.join(get_nsb_option('bin_path'),
+ 'dpdk-devbind.py')
self.vm_names = []
self.nfvi_host = []
self.nodes = []
@@ -49,8 +46,8 @@ class SriovContext(Context):
self.attrs = {}
self.vm_flavor = None
self.servers = None
- self.helper = StandaloneContextHelper()
- self.vnf_node = Server()
+ self.helper = model.StandaloneContextHelper()
+ self.vnf_node = model.Server()
self.drivers = []
super(SriovContext, self).__init__()
@@ -82,20 +79,16 @@ class SriovContext(Context):
return
self.connection = ssh.SSH.from_node(self.host_mgmt)
- self.dpdk_devbind = provision_tool(
- self.connection,
- os.path.join(get_nsb_option("bin_path"), "dpdk-devbind.py"))
# Todo: NFVi deploy (sriov, vswitch, ovs etc) based on the config.
- StandaloneContextHelper.install_req_libs(self.connection)
- self.networks = StandaloneContextHelper.get_nic_details(
+ model.StandaloneContextHelper.install_req_libs(self.connection)
+ self.networks = model.StandaloneContextHelper.get_nic_details(
self.connection, self.networks, self.dpdk_devbind)
self.nodes = self.setup_sriov_context()
LOG.debug("Waiting for VM to come up...")
- self.nodes = StandaloneContextHelper.wait_for_vnfs_to_start(self.connection,
- self.servers,
- self.nodes)
+ self.nodes = model.StandaloneContextHelper.wait_for_vnfs_to_start(
+ self.connection, self.servers, self.nodes)
def undeploy(self):
"""don't need to undeploy"""
@@ -105,7 +98,7 @@ class SriovContext(Context):
# Todo: NFVi undeploy (sriov, vswitch, ovs etc) based on the config.
for vm in self.vm_names:
- Libvirt.check_if_vm_exists_and_delete(vm, self.connection)
+ model.Libvirt.check_if_vm_exists_and_delete(vm, self.connection)
# Bind nics back to kernel
for ports in self.networks.values():
@@ -136,8 +129,8 @@ class SriovContext(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
@@ -179,7 +172,7 @@ class SriovContext(Context):
self.connection.execute(build_vfs.format(ports.get('phy_port')))
# configure VFs...
- mac = StandaloneContextHelper.get_mac_address()
+ mac = model.StandaloneContextHelper.get_mac_address()
interface = ports.get('interface')
if interface is not None:
self.connection.execute(vf_cmd.format(interface, mac))
@@ -201,7 +194,7 @@ class SriovContext(Context):
slot = index + idx + 10
vf['vpci'] = \
"{}:{}:{:02x}.{}".format(vpci.domain, vpci.bus, slot, vpci.function)
- Libvirt.add_sriov_interfaces(
+ model.Libvirt.add_sriov_interfaces(
vf['vpci'], vf['vf_pci']['vf_pci'], vf['mac'], str(cfg))
self.connection.execute("ifconfig %s up" % vf['interface'])
self.connection.execute(vf_spoofchk.format(vf['interface']))
@@ -212,34 +205,37 @@ class SriovContext(Context):
# 1 : modprobe host_driver with num_vfs
self.configure_nics_for_sriov()
- for index, (key, vnf) in enumerate(OrderedDict(self.servers).items()):
+ 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)
# 1. Check and delete VM if already exists
- Libvirt.check_if_vm_exists_and_delete(vm_name, self.connection)
+ 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)
- _, mac = Libvirt.build_vm_xml(self.connection, self.vm_flavor, cfg, vm_name, index)
# 2: Cleanup already available VMs
- for idx, (vkey, vfs) in enumerate(OrderedDict(vnf["network_ports"]).items()):
- if vkey == "mgmt":
- continue
+ network_ports = collections.OrderedDict(
+ {k: v for k, v in vnf["network_ports"].items() if k != 'mgmt'})
+ for idx, vfs in enumerate(network_ports.values()):
self._enable_interfaces(index, idx, vfs, cfg)
# copy xml to target...
+ model.Libvirt.write_file(cfg, xml_str)
self.connection.put(cfg, cfg)
# NOTE: launch through libvirt
LOG.info("virsh create ...")
- Libvirt.virsh_create_vm(self.connection, cfg)
+ 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))
+ nodes.append(self.vnf_node.generate_vnf_instance(
+ self.vm_flavor, self.networks, self.host_mgmt.get('ip'),
+ key, vnf, mac))
return nodes
@@ -248,7 +244,8 @@ class SriovContext(Context):
"mac": vfmac,
"pf_if": pfif
}
- vfs = StandaloneContextHelper.get_virtual_devices(self.connection, value)
+ vfs = model.StandaloneContextHelper.get_virtual_devices(
+ self.connection, value)
for k, v in vfs.items():
m = PciAddress(k.strip())
m1 = PciAddress(value.strip())
diff --git a/yardstick/benchmark/core/task.py b/yardstick/benchmark/core/task.py
index 4272a6db9..697cc007f 100644
--- a/yardstick/benchmark/core/task.py
+++ b/yardstick/benchmark/core/task.py
@@ -112,9 +112,9 @@ class Task(object): # pragma: no cover
continue
try:
- data = self._run(tasks[i]['scenarios'],
- tasks[i]['run_in_parallel'],
- output_config)
+ success, data = self._run(tasks[i]['scenarios'],
+ tasks[i]['run_in_parallel'],
+ output_config)
except KeyboardInterrupt:
raise
except Exception: # pylint: disable=broad-except
@@ -123,9 +123,15 @@ class Task(object): # pragma: no cover
testcases[tasks[i]['case_name']] = {'criteria': 'FAIL',
'tc_data': []}
else:
- LOG.info('Testcase: "%s" SUCCESS!!!', tasks[i]['case_name'])
- testcases[tasks[i]['case_name']] = {'criteria': 'PASS',
- 'tc_data': data}
+ if success:
+ LOG.info('Testcase: "%s" SUCCESS!!!', tasks[i]['case_name'])
+ testcases[tasks[i]['case_name']] = {'criteria': 'PASS',
+ 'tc_data': data}
+ else:
+ LOG.error('Testcase: "%s" FAILED!!!', tasks[i]['case_name'],
+ exc_info=True)
+ testcases[tasks[i]['case_name']] = {'criteria': 'FAIL',
+ 'tc_data': data}
if args.keep_deploy:
# keep deployment, forget about stack
@@ -240,6 +246,7 @@ class Task(object): # pragma: no cover
background_runners = []
+ task_success = True
result = []
# Start all background scenarios
for scenario in filter(_is_background_scenario, scenarios):
@@ -258,8 +265,8 @@ class Task(object): # pragma: no cover
for runner in runners:
status = runner_join(runner, background_runners, self.outputs, result)
if status != 0:
- raise RuntimeError(
- "{0} runner status {1}".format(runner.__execution_type__, status))
+ LOG.error("%s runner status %s", runner.__execution_type__, status)
+ task_success = False
LOG.info("Runner ended")
else:
# run serially
@@ -271,8 +278,8 @@ class Task(object): # pragma: no cover
LOG.error('Scenario NO.%s: "%s" ERROR!',
scenarios.index(scenario) + 1,
scenario.get('type'))
- raise RuntimeError(
- "{0} runner status {1}".format(runner.__execution_type__, status))
+ LOG.error("%s runner status %s", runner.__execution_type__, status)
+ task_success = False
LOG.info("Runner ended")
# Abort background runners
@@ -289,7 +296,7 @@ class Task(object): # pragma: no cover
base_runner.Runner.release(runner)
print("Background task ended")
- return result
+ return task_success, result
def atexit_handler(self):
"""handler for process termination"""
@@ -614,15 +621,25 @@ class TaskParser(object): # pragma: no cover
vnf__0: vnf_0.yardstick
"""
def qualified_name(name):
- node_name, context_name = name.split('.')
+ try:
+ # for openstack
+ node_name, context_name = name.split('.')
+ sep = '.'
+ except ValueError:
+ # for kubernetes, some kubernetes resources don't support
+ # name format like 'xxx.xxx', so we use '-' instead
+ # need unified later
+ node_name, context_name = name.split('-')
+ sep = '-'
+
try:
ctx = next((context for context in contexts
- if context.assigned_name == context_name))
+ if context.assigned_name == context_name))
except StopIteration:
raise y_exc.ScenarioConfigContextNameNotFound(
context_name=context_name)
- return '{}.{}'.format(node_name, ctx.name)
+ return '{}{}{}'.format(node_name, sep, ctx.name)
if 'host' in scenario:
scenario['host'] = qualified_name(scenario['host'])
diff --git a/yardstick/benchmark/runners/base.py b/yardstick/benchmark/runners/base.py
index 99386a440..fbdf6c281 100755
--- a/yardstick/benchmark/runners/base.py
+++ b/yardstick/benchmark/runners/base.py
@@ -121,7 +121,7 @@ class Runner(object):
@staticmethod
def terminate_all():
"""Terminate all runners (subprocesses)"""
- log.debug("Terminating all runners", exc_info=True)
+ log.debug("Terminating all runners")
# release dumper process as some errors before any runner is created
if not Runner.runners:
diff --git a/yardstick/benchmark/runners/duration.py b/yardstick/benchmark/runners/duration.py
index fbf72a74c..60b0348c3 100644
--- a/yardstick/benchmark/runners/duration.py
+++ b/yardstick/benchmark/runners/duration.py
@@ -66,6 +66,8 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
data = {}
errors = ""
+ benchmark.pre_run_wait_time(interval)
+
try:
result = method(data)
except AssertionError as assertion:
@@ -77,7 +79,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
errors = assertion.args
# catch all exceptions because with multiprocessing we can have un-picklable exception
# problems https://bugs.python.org/issue9400
- except Exception:
+ except Exception: # pylint: disable=broad-except
errors = traceback.format_exc()
LOG.exception("")
else:
@@ -86,7 +88,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
# if we do timeout we don't care about dropping individual KPIs
output_queue.put(result, True, QUEUE_PUT_TIMEOUT)
- time.sleep(interval)
+ benchmark.post_run_wait_time(interval)
benchmark_output = {
'timestamp': time.time(),
diff --git a/yardstick/benchmark/runners/iteration.py b/yardstick/benchmark/runners/iteration.py
index cb0424377..20d6da054 100644
--- a/yardstick/benchmark/runners/iteration.py
+++ b/yardstick/benchmark/runners/iteration.py
@@ -71,6 +71,8 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
data = {}
errors = ""
+ benchmark.pre_run_wait_time(interval)
+
try:
result = method(data)
except AssertionError as assertion:
@@ -90,7 +92,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
scenario_cfg['options']['rate'] -= delta
sequence = 1
continue
- except Exception:
+ except Exception: # pylint: disable=broad-except
errors = traceback.format_exc()
LOG.exception("")
else:
@@ -99,7 +101,7 @@ def _worker_process(queue, cls, method_name, scenario_cfg,
# if we do timeout we don't care about dropping individual KPIs
output_queue.put(result, True, QUEUE_PUT_TIMEOUT)
- time.sleep(interval)
+ benchmark.post_run_wait_time(interval)
benchmark_output = {
'timestamp': time.time(),
diff --git a/yardstick/benchmark/scenarios/availability/scenario_general.py b/yardstick/benchmark/scenarios/availability/scenario_general.py
index 9ac55471d..1fadd2532 100644
--- a/yardstick/benchmark/scenarios/availability/scenario_general.py
+++ b/yardstick/benchmark/scenarios/availability/scenario_general.py
@@ -26,7 +26,6 @@ class ScenarioGeneral(base.Scenario):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
self.intermediate_variables = {}
- self.pass_flag = True
def setup(self):
self.director = Director(self.scenario_cfg, self.context_cfg)
@@ -47,7 +46,7 @@ class ScenarioGeneral(base.Scenario):
step['actionType'], step['actionKey'])
if actionRollbacker:
self.director.executionSteps.append(actionRollbacker)
- except Exception:
+ except Exception: # pylint: disable=broad-except
LOG.exception("Exception")
LOG.debug(
"\033[91m exception when running step: %s .... \033[0m",
@@ -59,31 +58,16 @@ class ScenarioGeneral(base.Scenario):
self.director.stopMonitors()
verify_result = self.director.verify()
-
- self.director.store_result(result)
-
for k, v in self.director.data.items():
if v == 0:
result['sla_pass'] = 0
verify_result = False
- self.pass_flag = False
- LOG.info(
- "\033[92m The service process not found in the host \
-envrioment, the HA test case NOT pass")
+ LOG.info("\033[92m The service process (%s) not found in the host environment", k)
- if verify_result:
- result['sla_pass'] = 1
- LOG.info(
- "\033[92m Congratulations, "
- "the HA test case PASS! \033[0m")
- else:
- result['sla_pass'] = 0
- self.pass_flag = False
- LOG.info(
- "\033[91m Aoh, the HA test case FAIL,"
- "please check the detail debug information! \033[0m")
+ result['sla_pass'] = 1 if verify_result else 0
+ self.director.store_result(result)
+
+ assert verify_result is True, "The HA test case NOT passed"
def teardown(self):
self.director.knockoff()
-
- assert self.pass_flag, "The HA test case NOT passed"
diff --git a/yardstick/benchmark/scenarios/availability/serviceha.py b/yardstick/benchmark/scenarios/availability/serviceha.py
index 6d0d812af..dcd0fe598 100755
--- a/yardstick/benchmark/scenarios/availability/serviceha.py
+++ b/yardstick/benchmark/scenarios/availability/serviceha.py
@@ -29,7 +29,6 @@ class ServiceHA(base.Scenario):
self.context_cfg = context_cfg
self.setup_done = False
self.data = {}
- self.pass_flag = True
def setup(self):
"""scenario setup"""
@@ -73,18 +72,12 @@ class ServiceHA(base.Scenario):
sla_pass = self.monitorMgr.verify_SLA()
for k, v in self.data.items():
if v == 0:
- result['sla_pass'] = 0
- self.pass_flag = False
- LOG.info("The service process not found in the host envrioment, \
-the HA test case NOT pass")
- return
+ sla_pass = False
+ LOG.info("The service process (%s) not found in the host envrioment", k)
+
+ result['sla_pass'] = 1 if sla_pass else 0
self.monitorMgr.store_result(result)
- if sla_pass:
- result['sla_pass'] = 1
- LOG.info("The HA test case PASS the SLA")
- else:
- result['sla_pass'] = 0
- self.pass_flag = False
+
assert sla_pass is True, "The HA test case NOT pass the SLA"
return
@@ -94,8 +87,6 @@ the HA test case NOT pass")
for attacker in self.attackers:
attacker.recover()
- assert self.pass_flag, "The HA test case NOT passed"
-
def _test(): # pragma: no cover
"""internal test function"""
diff --git a/yardstick/benchmark/scenarios/base.py b/yardstick/benchmark/scenarios/base.py
index 10a728828..58a02805c 100644
--- a/yardstick/benchmark/scenarios/base.py
+++ b/yardstick/benchmark/scenarios/base.py
@@ -13,9 +13,10 @@
# License for the specific language governing permissions and limitations
# under the License.
-# yardstick comment: this is a modified copy of
-# rally/rally/benchmark/scenarios/base.py
+import abc
+import time
+import six
from stevedore import extension
import yardstick.common.utils as utils
@@ -37,20 +38,29 @@ def _iter_scenario_classes(scenario_type=None):
yield scenario
+@six.add_metaclass(abc.ABCMeta)
class Scenario(object):
def setup(self):
- """ default impl for scenario setup """
+ """Default setup implementation for Scenario classes"""
pass
+ @abc.abstractmethod
def run(self, *args):
- """ catcher for not implemented run methods in subclasses """
- raise RuntimeError("run method not implemented")
+ """Entry point for scenario classes, called from runner worker"""
def teardown(self):
- """ default impl for scenario teardown """
+ """Default teardown implementation for Scenario classes"""
pass
+ def pre_run_wait_time(self, time_seconds):
+ """Time waited before executing the run method"""
+ pass
+
+ def post_run_wait_time(self, time_seconds):
+ """Time waited after executing the run method"""
+ time.sleep(time_seconds)
+
@staticmethod
def get_types():
"""return a list of known runner type (class) names"""
@@ -88,10 +98,14 @@ class Scenario(object):
"""
return cls.__doc__.splitlines()[0] if cls.__doc__ else str(None)
- def _push_to_outputs(self, keys, values):
+ @staticmethod
+ def _push_to_outputs(keys, values):
+ """Return a dictionary given the keys and the values"""
return dict(zip(keys, values))
- def _change_obj_to_dict(self, obj):
+ @staticmethod
+ def _change_obj_to_dict(obj):
+ """Return a dictionary from the __dict__ attribute of an object"""
dic = {}
for k, v in vars(obj).items():
try:
diff --git a/yardstick/benchmark/scenarios/compute/unixbench_benchmark.bash b/yardstick/benchmark/scenarios/compute/unixbench_benchmark.bash
index 5a5dbc394..9f1804819 100644
--- a/yardstick/benchmark/scenarios/compute/unixbench_benchmark.bash
+++ b/yardstick/benchmark/scenarios/compute/unixbench_benchmark.bash
@@ -18,7 +18,7 @@ OUTPUT_FILE=/tmp/unixbench-out.log
# run unixbench test
run_unixbench()
{
- cd /opt/tempT/UnixBench/
+ cd /opt/tempT/UnixBench/UnixBench/
./Run $OPTIONS > $OUTPUT_FILE
}
diff --git a/yardstick/benchmark/scenarios/lib/attach_volume.py b/yardstick/benchmark/scenarios/lib/attach_volume.py
index 88124964b..96dd130b1 100644
--- a/yardstick/benchmark/scenarios/lib/attach_volume.py
+++ b/yardstick/benchmark/scenarios/lib/attach_volume.py
@@ -6,30 +6,31 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
-from __future__ import print_function
-from __future__ import absolute_import
-
import logging
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
LOG = logging.getLogger(__name__)
class AttachVolume(base.Scenario):
- """Attach a volmeu to an instance"""
+ """Attach a volume to an instance"""
__scenario_type__ = "AttachVolume"
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.options = self.scenario_cfg['options']
+ self.options = self.scenario_cfg["options"]
- self.server_id = self.options.get("server_id", "TestServer")
- self.volume_id = self.options.get("volume_id", None)
+ self.server_name_or_id = self.options["server_name_or_id"]
+ self.volume_name_or_id = self.options["volume_name_or_id"]
+ self.device = self.options.get("device")
+ self.wait = self.options.get("wait", True)
+ self.timeout = self.options.get("timeout")
+ self.shade_client = openstack_utils.get_shade_client()
self.setup_done = False
@@ -44,10 +45,14 @@ class AttachVolume(base.Scenario):
if not self.setup_done:
self.setup()
- status = op_utils.attach_server_volume(self.server_id,
- self.volume_id)
+ status = openstack_utils.attach_volume_to_server(
+ self.shade_client, self.server_name_or_id, self.volume_name_or_id,
+ device=self.device, wait=self.wait, timeout=self.timeout)
+
+ if not status:
+ result.update({"attach_volume": 0})
+ LOG.error("Attach volume to server failed!")
+ raise exceptions.ScenarioAttachVolumeError
- if status:
- LOG.info("Attach volume to server successful!")
- else:
- LOG.info("Attach volume to server failed!")
+ result.update({"attach_volume": 1})
+ LOG.info("Attach volume to server successful!")
diff --git a/yardstick/benchmark/scenarios/lib/create_floating_ip.py b/yardstick/benchmark/scenarios/lib/create_floating_ip.py
index 7108722af..e29f9d1fc 100644
--- a/yardstick/benchmark/scenarios/lib/create_floating_ip.py
+++ b/yardstick/benchmark/scenarios/lib/create_floating_ip.py
@@ -11,7 +11,8 @@ import logging
import os
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
LOG = logging.getLogger(__name__)
@@ -26,9 +27,18 @@ class CreateFloatingIp(base.Scenario):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
self.ext_net_id = os.getenv("EXTERNAL_NETWORK", "external")
+ self.options = self.scenario_cfg["options"]
+
+ self.network_name_or_id = self.options.get("network_name_or_id", self.ext_net_id)
+ self.server = self.options.get("server")
+ self.fixed_address = self.options.get("fixed_address")
+ self.nat_destination = self.options.get("nat_destination")
+ self.port = self.options.get("port")
+ self.wait = self.options.get("wait", False)
+ self.timeout = self.options.get("timeout", 60)
+
+ self.shade_client = openstack_utils.get_shade_client()
- self.neutron_client = op_utils.get_neutron_client()
- self.shade_client = op_utils.get_shade_client()
self.setup_done = False
def setup(self):
@@ -36,21 +46,25 @@ class CreateFloatingIp(base.Scenario):
self.setup_done = True
- def run(self, *args):
+ def run(self, result):
"""execute the test"""
if not self.setup_done:
self.setup()
- net_id = op_utils.get_network_id(self.shade_client, self.ext_net_id)
- floating_info = op_utils.create_floating_ip(self.neutron_client,
- extnet_id=net_id)
+ floating_info = openstack_utils.create_floating_ip(
+ self.shade_client, network_name_or_id=self.network_name_or_id,
+ server=self.server, fixed_address=self.fixed_address,
+ nat_destination=self.nat_destination, port=self.port,
+ wait=self.wait, timeout=self.timeout)
if not floating_info:
+ result.update({"floating_ip_create": 0})
LOG.error("Creating floating ip failed!")
- return
+ raise exceptions.ScenarioCreateFloatingIPError
+ result.update({"floating_ip_create": 1})
LOG.info("Creating floating ip successful!")
- keys = self.scenario_cfg.get('output', '').split()
+ keys = self.scenario_cfg.get("output", '').split()
values = [floating_info["fip_id"], floating_info["fip_addr"]]
return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_keypair.py b/yardstick/benchmark/scenarios/lib/create_keypair.py
index f5b1fff7a..ee9bc440a 100644
--- a/yardstick/benchmark/scenarios/lib/create_keypair.py
+++ b/yardstick/benchmark/scenarios/lib/create_keypair.py
@@ -6,15 +6,11 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
-from __future__ import print_function
-from __future__ import absolute_import
-
import logging
-import paramiko
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
LOG = logging.getLogger(__name__)
@@ -27,10 +23,11 @@ class CreateKeypair(base.Scenario):
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.options = self.scenario_cfg['options']
+ self.options = self.scenario_cfg["options"]
- self.key_name = self.options.get("key_name", "yardstick_key")
- self.key_filename = self.options.get("key_path", "/tmp/yardstick_key")
+ self.name = self.options["key_name"]
+ self.public_key = self.options.get("public_key")
+ self.shade_client = openstack_utils.get_shade_client()
self.setup_done = False
@@ -45,27 +42,17 @@ class CreateKeypair(base.Scenario):
if not self.setup_done:
self.setup()
- rsa_key = paramiko.RSAKey.generate(bits=2048, progress_func=None)
- rsa_key.write_private_key_file(self.key_filename)
- LOG.info("Writing key_file %s ...", self.key_filename)
- with open(self.key_filename + ".pub", "w") as pubkey_file:
- pubkey_file.write(
- "%s %s\n" % (rsa_key.get_name(), rsa_key.get_base64()))
- del rsa_key
-
- keypair = op_utils.create_keypair(self.key_name,
- self.key_filename + ".pub")
+ keypair = openstack_utils.create_keypair(
+ self.shade_client, self.name, public_key=self.public_key)
- if keypair:
- result.update({"keypair_create": 1})
- LOG.info("Create keypair successful!")
- else:
+ if not keypair:
result.update({"keypair_create": 0})
- LOG.info("Create keypair failed!")
- try:
- keys = self.scenario_cfg.get('output', '').split()
- except KeyError:
- pass
- else:
- values = [keypair.id]
- return self._push_to_outputs(keys, values)
+ LOG.error("Create keypair failed!")
+ raise exceptions.ScenarioCreateKeypairError
+
+ result.update({"keypair_create": 1})
+ LOG.info("Create keypair successful!")
+ keys = self.scenario_cfg.get("output", '').split()
+ keypair_id = keypair["id"]
+ values = [keypair_id]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_sec_group.py b/yardstick/benchmark/scenarios/lib/create_sec_group.py
index 3d1aec9e8..1d2e36488 100644
--- a/yardstick/benchmark/scenarios/lib/create_sec_group.py
+++ b/yardstick/benchmark/scenarios/lib/create_sec_group.py
@@ -7,13 +7,11 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import print_function
-from __future__ import absolute_import
-
import logging
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
LOG = logging.getLogger(__name__)
@@ -26,11 +24,12 @@ class CreateSecgroup(base.Scenario):
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.options = self.scenario_cfg['options']
+ self.options = self.scenario_cfg["options"]
- self.sg_name = self.options.get("sg_name", "yardstick_sec_group")
- self.description = self.options.get("description", None)
- self.neutron_client = op_utils.get_neutron_client()
+ self.sg_name = self.options["sg_name"]
+ self.description = self.options.get("description", "")
+ self.project_id = self.options.get("project_id")
+ self.shade_client = openstack_utils.get_shade_client()
self.setup_done = False
@@ -45,21 +44,16 @@ class CreateSecgroup(base.Scenario):
if not self.setup_done:
self.setup()
- sg_id = op_utils.create_security_group_full(self.neutron_client,
- sg_name=self.sg_name,
- sg_description=self.description)
-
- if sg_id:
- result.update({"sg_create": 1})
- LOG.info("Create security group successful!")
- else:
+ sg_id = openstack_utils.create_security_group_full(
+ self.shade_client, self.sg_name, sg_description=self.description,
+ project_id=self.project_id)
+ if not sg_id:
result.update({"sg_create": 0})
LOG.error("Create security group failed!")
+ raise exceptions.ScenarioCreateSecurityGroupError
- try:
- keys = self.scenario_cfg.get('output', '').split()
- except KeyError:
- pass
- else:
- values = [sg_id]
- return self._push_to_outputs(keys, values)
+ result.update({"sg_create": 1})
+ LOG.info("Create security group successful!")
+ keys = self.scenario_cfg.get("output", '').split()
+ values = [sg_id]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_server.py b/yardstick/benchmark/scenarios/lib/create_server.py
index 31ba18ed4..e2748aecf 100644
--- a/yardstick/benchmark/scenarios/lib/create_server.py
+++ b/yardstick/benchmark/scenarios/lib/create_server.py
@@ -6,14 +6,11 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
-from __future__ import print_function
-from __future__ import absolute_import
-
import logging
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
LOG = logging.getLogger(__name__)
@@ -26,15 +23,27 @@ class CreateServer(base.Scenario):
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.options = self.scenario_cfg['options']
-
- self.image_name = self.options.get("image_name", None)
- self.flavor_name = self.options.get("flavor_name", None)
- self.openstack = self.options.get("openstack_paras", None)
-
- self.glance_client = op_utils.get_glance_client()
- self.neutron_client = op_utils.get_neutron_client()
- self.nova_client = op_utils.get_nova_client()
+ self.options = self.scenario_cfg["options"]
+
+ self.name = self.options["name"]
+ self.image = self.options["image"]
+ self.flavor = self.options["flavor"]
+ self.auto_ip = self.options.get("auto_ip", True)
+ self.ips = self.options.get("ips")
+ self.ip_pool = self.options.get("ip_pool")
+ self.root_volume = self.options.get("root_volume")
+ self.terminate_volume = self.options.get("terminate_volume", False)
+ self.wait = self.options.get("wait", True)
+ self.timeout = self.options.get("timeout", 180)
+ self.reuse_ips = self.options.get("reuse_ips", True)
+ self.network = self.options.get("network")
+ self.boot_from_volume = self.options.get("boot_from_volume", False)
+ self.volume_size = self.options.get("volume_size", "20")
+ self.boot_volume = self.options.get("boot_volume")
+ self.volumes = self.options.get("volumes")
+ self.nat_destination = self.options.get("nat_destination")
+
+ self.shade_client = openstack_utils.get_shade_client()
self.setup_done = False
@@ -49,26 +58,23 @@ class CreateServer(base.Scenario):
if not self.setup_done:
self.setup()
- if self.image_name is not None:
- self.openstack['image'] = op_utils.get_image_id(self.glance_client,
- self.image_name)
- if self.flavor_name is not None:
- self.openstack['flavor'] = op_utils.get_flavor_id(self.nova_client,
- self.flavor_name)
-
- vm = op_utils.create_instance_and_wait_for_active(self.openstack)
-
- if vm:
- result.update({"instance_create": 1})
- LOG.info("Create server successful!")
- else:
+ server = openstack_utils.create_instance_and_wait_for_active(
+ self.shade_client, self.name, self.image,
+ self.flavor, auto_ip=self.auto_ip, ips=self.ips,
+ ip_pool=self.ip_pool, root_volume=self.root_volume,
+ terminate_volume=self.terminate_volume, wait=self.wait,
+ timeout=self.timeout, reuse_ips=self.reuse_ips,
+ network=self.network, boot_from_volume=self.boot_from_volume,
+ volume_size=self.volume_size, boot_volume=self.boot_volume,
+ volumes=self.volumes, nat_destination=self.nat_destination)
+
+ if not server:
result.update({"instance_create": 0})
LOG.error("Create server failed!")
+ raise exceptions.ScenarioCreateServerError
- try:
- keys = self.scenario_cfg.get('output', '').split()
- except KeyError:
- pass
- else:
- values = [vm.id]
- return self._push_to_outputs(keys, values)
+ result.update({"instance_create": 1})
+ LOG.info("Create instance successful!")
+ keys = self.scenario_cfg.get("output", '').split()
+ values = [server["id"]]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/delete_floating_ip.py b/yardstick/benchmark/scenarios/lib/delete_floating_ip.py
index 4314952fb..a35445f6f 100644
--- a/yardstick/benchmark/scenarios/lib/delete_floating_ip.py
+++ b/yardstick/benchmark/scenarios/lib/delete_floating_ip.py
@@ -7,13 +7,12 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import print_function
-from __future__ import absolute_import
-
import logging
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+
LOG = logging.getLogger(__name__)
@@ -28,9 +27,10 @@ class DeleteFloatingIp(base.Scenario):
self.context_cfg = context_cfg
self.options = self.scenario_cfg['options']
- self.floating_ip_id = self.options.get("floating_ip_id", None)
+ self.floating_ip_id = self.options["floating_ip_id"]
+ self.retry = self.options.get("retry", 1)
- self.nova_client = op_utils.get_nova_client()
+ self.shade_client = openstack_utils.get_shade_client()
self.setup_done = False
def setup(self):
@@ -44,11 +44,13 @@ class DeleteFloatingIp(base.Scenario):
if not self.setup_done:
self.setup()
- status = op_utils.delete_floating_ip(nova_client=self.nova_client,
- floatingip_id=self.floating_ip_id)
- if status:
- result.update({"delete_floating_ip": 1})
- LOG.info("Delete floating ip successful!")
- else:
+ status = openstack_utils.delete_floating_ip(
+ self.shade_client, self.floating_ip_id,
+ retry=self.retry)
+ if not status:
result.update({"delete_floating_ip": 0})
LOG.error("Delete floating ip failed!")
+ raise exceptions.ScenarioDeleteFloatingIPError
+
+ result.update({"delete_floating_ip": 1})
+ LOG.info("Delete floating ip successful!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_keypair.py b/yardstick/benchmark/scenarios/lib/delete_keypair.py
index 135139959..a52a38567 100644
--- a/yardstick/benchmark/scenarios/lib/delete_keypair.py
+++ b/yardstick/benchmark/scenarios/lib/delete_keypair.py
@@ -6,14 +6,12 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
-from __future__ import print_function
-from __future__ import absolute_import
-
import logging
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+
LOG = logging.getLogger(__name__)
@@ -26,11 +24,11 @@ class DeleteKeypair(base.Scenario):
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.options = self.scenario_cfg['options']
+ self.options = self.scenario_cfg["options"]
- self.key_name = self.options.get("key_name", "yardstick_key")
+ self.key_name = self.options["key_name"]
- self.nova_client = op_utils.get_nova_client()
+ self.shade_client = openstack_utils.get_shade_client()
self.setup_done = False
@@ -45,12 +43,13 @@ class DeleteKeypair(base.Scenario):
if not self.setup_done:
self.setup()
- status = op_utils.delete_keypair(self.nova_client,
- self.key_name)
+ status = openstack_utils.delete_keypair(self.shade_client,
+ self.key_name)
- if status:
- result.update({"delete_keypair": 1})
- LOG.info("Delete keypair successful!")
- else:
+ if not status:
result.update({"delete_keypair": 0})
- LOG.info("Delete keypair failed!")
+ LOG.error("Delete keypair failed!")
+ raise exceptions.ScenarioDeleteKeypairError
+
+ result.update({"delete_keypair": 1})
+ LOG.info("Delete keypair successful!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_network.py b/yardstick/benchmark/scenarios/lib/delete_network.py
index 2e8b595f9..8874e8b1e 100644
--- a/yardstick/benchmark/scenarios/lib/delete_network.py
+++ b/yardstick/benchmark/scenarios/lib/delete_network.py
@@ -10,7 +10,8 @@
import logging
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
LOG = logging.getLogger(__name__)
@@ -24,11 +25,11 @@ class DeleteNetwork(base.Scenario):
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.options = self.scenario_cfg['options']
+ self.options = self.scenario_cfg["options"]
- self.network_id = self.options.get("network_id", None)
+ self.network_name_or_id = self.options["network_name_or_id"]
- self.shade_client = op_utils.get_shade_client()
+ self.shade_client = openstack_utils.get_shade_client()
self.setup_done = False
@@ -43,12 +44,13 @@ class DeleteNetwork(base.Scenario):
if not self.setup_done:
self.setup()
- status = op_utils.delete_neutron_net(self.shade_client,
- network_id=self.network_id)
- if status:
- result.update({"delete_network": 1})
- LOG.info("Delete network successful!")
- else:
+ status = openstack_utils.delete_neutron_net(self.shade_client,
+ self.network_name_or_id)
+
+ if not status:
result.update({"delete_network": 0})
LOG.error("Delete network failed!")
- return status
+ raise exceptions.ScenarioDeleteNetworkError
+
+ result.update({"delete_network": 1})
+ LOG.info("Delete network successful!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_router_interface.py b/yardstick/benchmark/scenarios/lib/delete_router_interface.py
index 117c80811..e71aed3ef 100644
--- a/yardstick/benchmark/scenarios/lib/delete_router_interface.py
+++ b/yardstick/benchmark/scenarios/lib/delete_router_interface.py
@@ -7,13 +7,11 @@
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-from __future__ import print_function
-from __future__ import absolute_import
-
import logging
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
LOG = logging.getLogger(__name__)
@@ -28,10 +26,11 @@ class DeleteRouterInterface(base.Scenario):
self.context_cfg = context_cfg
self.options = self.scenario_cfg['options']
- self.subnet_id = self.options.get("subnet_id", None)
- self.router_id = self.options.get("router_id", None)
+ self.router = self.options["router"]
+ self.subnet_id = self.options.get("subnet_id")
+ self.port_id = self.options.get("port_id")
- self.neutron_client = op_utils.get_neutron_client()
+ self.shade_client = openstack_utils.get_shade_client()
self.setup_done = False
@@ -46,12 +45,13 @@ class DeleteRouterInterface(base.Scenario):
if not self.setup_done:
self.setup()
- status = op_utils.remove_interface_router(self.neutron_client,
- router_id=self.router_id,
- subnet_id=self.subnet_id)
- if status:
- result.update({"delete_router_interface": 1})
- LOG.info("Delete router interface successful!")
- else:
+ status = openstack_utils.remove_router_interface(
+ self.shade_client, self.router, subnet_id=self.subnet_id,
+ port_id=self.port_id)
+ if not status:
result.update({"delete_router_interface": 0})
LOG.error("Delete router interface failed!")
+ raise exceptions.ScenarioRemoveRouterIntError
+
+ result.update({"delete_router_interface": 1})
+ LOG.info("Delete router interface successful!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_server.py b/yardstick/benchmark/scenarios/lib/delete_server.py
index bcd8faba7..46229ff04 100644
--- a/yardstick/benchmark/scenarios/lib/delete_server.py
+++ b/yardstick/benchmark/scenarios/lib/delete_server.py
@@ -6,14 +6,11 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
-from __future__ import print_function
-from __future__ import absolute_import
-
import logging
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
LOG = logging.getLogger(__name__)
@@ -26,9 +23,13 @@ class DeleteServer(base.Scenario):
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.options = self.scenario_cfg['options']
- self.server_id = self.options.get("server_id", None)
- self.nova_client = op_utils.get_nova_client()
+ self.options = self.scenario_cfg["options"]
+ self.server_name_or_id = self.options["name_or_id"]
+ self.wait = self.options.get("wait", False)
+ self.timeout = self.options.get("timeout", 180)
+ self.delete_ips = self.options.get("delete_ips", False)
+ self.delete_ip_retry = self.options.get("delete_ip_retry", 1)
+ self.shade_client = openstack_utils.get_shade_client()
self.setup_done = False
@@ -43,9 +44,15 @@ class DeleteServer(base.Scenario):
if not self.setup_done:
self.setup()
- status = op_utils.delete_instance(self.nova_client,
- instance_id=self.server_id)
- if status:
- LOG.info("Delete server successful!")
- else:
+ status = openstack_utils.delete_instance(
+ self.shade_client, self.server_name_or_id, wait=self.wait,
+ timeout=self.timeout, delete_ips=self.delete_ips,
+ delete_ip_retry=self.delete_ip_retry)
+
+ if not status:
+ result.update({"delete_server": 0})
LOG.error("Delete server failed!")
+ raise exceptions.ScenarioDeleteServerError
+
+ result.update({"delete_server": 1})
+ LOG.info("Delete server successful!")
diff --git a/yardstick/benchmark/scenarios/lib/get_flavor.py b/yardstick/benchmark/scenarios/lib/get_flavor.py
index d5e33947e..6727a7343 100644
--- a/yardstick/benchmark/scenarios/lib/get_flavor.py
+++ b/yardstick/benchmark/scenarios/lib/get_flavor.py
@@ -6,14 +6,11 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
-from __future__ import print_function
-from __future__ import absolute_import
-
import logging
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
LOG = logging.getLogger(__name__)
@@ -26,8 +23,12 @@ class GetFlavor(base.Scenario):
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.options = self.scenario_cfg['options']
- self.flavor_name = self.options.get("flavor_name", "TestFlavor")
+ self.options = self.scenario_cfg["options"]
+ self.name_or_id = self.options["name_or_id"]
+ self.filters = self.options.get("filters")
+ self.get_extra = self.options.get("get_extra", True)
+ self.shade_client = openstack_utils.get_shade_client()
+
self.setup_done = False
def setup(self):
@@ -41,14 +42,18 @@ class GetFlavor(base.Scenario):
if not self.setup_done:
self.setup()
- LOG.info("Querying flavor: %s", self.flavor_name)
- flavor = op_utils.get_flavor_by_name(self.flavor_name)
- if flavor:
- LOG.info("Get flavor successful!")
- values = [self._change_obj_to_dict(flavor)]
- else:
- LOG.info("Get flavor: no flavor matched!")
- values = []
+ LOG.info("Querying flavor: %s", self.name_or_id)
+ flavor = openstack_utils.get_flavor(
+ self.shade_client, self.name_or_id, filters=self.filters,
+ get_extra=self.get_extra)
+
+ if not flavor:
+ result.update({"get_flavor": 0})
+ LOG.error("Get flavor failed!")
+ raise exceptions.ScenarioGetFlavorError
- keys = self.scenario_cfg.get('output', '').split()
+ result.update({"get_flavor": 1})
+ LOG.info("Get flavor successful!")
+ values = [flavor]
+ keys = self.scenario_cfg.get("output", '').split()
return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/get_server.py b/yardstick/benchmark/scenarios/lib/get_server.py
index fcf47c80d..f65fa9ebf 100644
--- a/yardstick/benchmark/scenarios/lib/get_server.py
+++ b/yardstick/benchmark/scenarios/lib/get_server.py
@@ -6,14 +6,11 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-
-from __future__ import print_function
-from __future__ import absolute_import
-
import logging
from yardstick.benchmark.scenarios import base
-import yardstick.common.openstack_utils as op_utils
+from yardstick.common import openstack_utils
+from yardstick.common import exceptions
LOG = logging.getLogger(__name__)
@@ -21,63 +18,58 @@ LOG = logging.getLogger(__name__)
class GetServer(base.Scenario):
"""Get a server instance
- Parameters
- server_id - ID of the server
- type: string
- unit: N/A
- default: null
- server_name - name of the server
- type: string
- unit: N/A
- default: null
-
- Either server_id or server_name is required.
-
- Outputs
+ Parameters:
+ name_or_id - Name or ID of the server
+ type: string
+ filters - meta data to use for further filtering
+ type: dict
+ detailed: Whether or not to add detailed additional information.
+ type: bool
+ bare: Whether to skip adding any additional information to the server
+ record.
+ type: bool
+ all_projects: Whether to get server from all projects or just the current
+ auth scoped project.
+ type: bool
+
+ Outputs:
rc - response code of getting server instance
- 0 for success
- 1 for failure
+ 1 for success
+ 0 for failure
type: int
- unit: N/A
server - instance of the server
type: dict
- unit: N/A
+
"""
- __scenario_type__ = "GetServer"
+ __scenario_type__ = 'GetServer'
def __init__(self, scenario_cfg, context_cfg):
self.scenario_cfg = scenario_cfg
self.context_cfg = context_cfg
- self.options = self.scenario_cfg.get('options', {})
+ self.options = self.scenario_cfg['options']
- self.server_id = self.options.get("server_id")
- if self.server_id:
- LOG.debug('Server id is %s', self.server_id)
+ self.server_name_or_id = self.options.get('name_or_id')
+ self.filters = self.options.get('filters')
+ self.detailed = self.options.get('detailed', False)
+ self.bare = self.options.get('bare', False)
- default_name = self.scenario_cfg.get('host',
- self.scenario_cfg.get('target'))
- self.server_name = self.options.get('server_name', default_name)
- if self.server_name:
- LOG.debug('Server name is %s', self.server_name)
-
- self.nova_client = op_utils.get_nova_client()
+ self.shade_client = openstack_utils.get_shade_client()
def run(self, result):
"""execute the test"""
- if self.server_id:
- server = self.nova_client.servers.get(self.server_id)
- else:
- server = op_utils.get_server_by_name(self.server_name)
-
- keys = self.scenario_cfg.get('output', '').split()
+ server = openstack_utils.get_server(
+ self.shade_client, name_or_id=self.server_name_or_id,
+ filters=self.filters, detailed=self.detailed, bare=self.bare)
- if server:
- LOG.info("Get server successful!")
- values = [0, self._change_obj_to_dict(server)]
- else:
- LOG.info("Get server failed!")
- values = [1]
+ if not server:
+ result.update({'get_server': 0})
+ LOG.error('Get Server failed!')
+ raise exceptions.ScenarioGetServerError
+ result.update({'get_server': 1})
+ LOG.info('Get Server successful!')
+ keys = self.scenario_cfg.get('output', '').split()
+ values = [server]
return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py
index ce8a7f497..9a7b975a2 100644
--- a/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py
+++ b/yardstick/benchmark/scenarios/networking/pktgen_dpdk.py
@@ -70,39 +70,42 @@ class PktgenDPDKLatency(base.Scenario):
def run(self, result):
"""execute the benchmark"""
+ options = self.scenario_cfg['options']
+ eth1 = options.get("eth1", "ens4")
+ eth2 = options.get("eth2", "ens5")
if not self.setup_done:
self.setup()
if not self.testpmd_args:
- self.testpmd_args = utils.get_port_mac(self.client, 'eth2')
+ self.testpmd_args = utils.get_port_mac(self.client, eth2)
if not self.pktgen_args:
- server_rev_mac = utils.get_port_mac(self.server, 'eth1')
- server_send_mac = utils.get_port_mac(self.server, 'eth2')
- client_src_ip = utils.get_port_ip(self.client, 'eth1')
- client_dst_ip = utils.get_port_ip(self.client, 'eth2')
+ server_rev_mac = utils.get_port_mac(self.server, eth1)
+ server_send_mac = utils.get_port_mac(self.server, eth2)
+ client_src_ip = utils.get_port_ip(self.client, eth1)
+ client_dst_ip = utils.get_port_ip(self.client, eth2)
self.pktgen_args = [client_src_ip, client_dst_ip,
server_rev_mac, server_send_mac]
- options = self.scenario_cfg['options']
packetsize = options.get("packetsize", 64)
rate = options.get("rate", 100)
- cmd = "screen sudo -E bash ~/testpmd_fwd.sh %s " % (self.testpmd_args)
+ cmd = "screen sudo -E bash ~/testpmd_fwd.sh %s %s %s" % \
+ (self.testpmd_args, eth1, eth2)
LOG.debug("Executing command: %s", cmd)
self.server.send_command(cmd)
time.sleep(1)
- cmd = "screen sudo -E bash ~/pktgen_dpdk.sh %s %s %s %s %s %s" % \
+ cmd = "screen sudo -E bash ~/pktgen_dpdk.sh %s %s %s %s %s %s %s %s" % \
(self.pktgen_args[0], self.pktgen_args[1], self.pktgen_args[2],
- self.pktgen_args[3], rate, packetsize)
+ self.pktgen_args[3], rate, packetsize, eth1, eth2)
LOG.debug("Executing command: %s", cmd)
self.client.send_command(cmd)
# wait for finishing test
- time.sleep(1)
+ time.sleep(60)
cmd = r"""\
cat ~/result.log -vT \
diff --git a/yardstick/benchmark/scenarios/networking/pktgen_dpdk_latency_benchmark.bash b/yardstick/benchmark/scenarios/networking/pktgen_dpdk_latency_benchmark.bash
index b872aa3df..dcd5a9bfb 100644
--- a/yardstick/benchmark/scenarios/networking/pktgen_dpdk_latency_benchmark.bash
+++ b/yardstick/benchmark/scenarios/networking/pktgen_dpdk_latency_benchmark.bash
@@ -7,7 +7,7 @@
# which accompanies this distribution, and is available at
# http://www.apache.org/licenses/LICENSE-2.0
##############################################################################
-!/bin/sh
+#!/bin/sh
set -e
@@ -18,6 +18,11 @@ FWD_REV_MAC=$3 # MAC address of forwarding receiver in VM B
FWD_SEND_MAC=$4 # MAC address of forwarding sender in VM B
RATE=$5 # packet rate in percentage
PKT_SIZE=$6 # packet size
+ETH1=$7
+ETH2=$8
+
+DPDK_VERSION="dpdk-17.02"
+PKTGEN_VERSION="pktgen-3.2.12"
load_modules()
@@ -31,13 +36,13 @@ load_modules()
if lsmod | grep "igb_uio" &> /dev/null ; then
echo "igb_uio module is loaded"
else
- insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
+ insmod /opt/tempT/$DPDK_VERSION/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
fi
if lsmod | grep "rte_kni" &> /dev/null ; then
echo "rte_kni module is loaded"
else
- insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
+ insmod /opt/tempT/$DPDK_VERSION/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
fi
}
@@ -48,8 +53,10 @@ change_permissions()
}
add_interface_to_dpdk(){
+ ip link set $ETH1 down
+ ip link set $ETH2 down
interfaces=$(lspci |grep Eth |tail -n +2 |awk '{print $1}')
- /dpdk/tools/dpdk-devbind.py --bind=igb_uio $interfaces
+ /opt/tempT/$DPDK_VERSION/usertools/dpdk-devbind.py --bind=igb_uio $interfaces
}
@@ -106,20 +113,14 @@ spawn ./app/app/x86_64-native-linuxapp-gcc/pktgen -c 0x07 -n 4 -b $blacklist --
expect "Pktgen>"
send "\n"
expect "Pktgen>"
-send "screen on\n"
+send "on\n"
expect "Pktgen>"
set count 10
while { $count } {
send "page latency\n"
- expect {
- timeout { send "\n" }
- -regexp {..*} {
- set result "${result}$expect_out(0,string)"
- set timeout 1
- exp_continue
- }
- "Pktgen>"
- }
+ expect -re "(..*)"
+ set result "${result}$expect_out(0,string)"
+ set timeout 1
set count [expr $count-1]
}
send "stop 0\n"
@@ -136,7 +137,7 @@ EOF
run_pktgen()
{
blacklist=$(lspci |grep Eth |awk '{print $1}'|head -1)
- cd /pktgen-dpdk
+ cd /opt/tempT/$PKTGEN_VERSION
touch /home/ubuntu/result.log
result_log="/home/ubuntu/result.log"
sudo expect /home/ubuntu/pktgen.exp $blacklist $result_log
@@ -153,4 +154,3 @@ main()
}
main
-
diff --git a/yardstick/benchmark/scenarios/networking/testpmd_fwd.bash b/yardstick/benchmark/scenarios/networking/testpmd_fwd.bash
index 247a8a833..30b63a734 100644
--- a/yardstick/benchmark/scenarios/networking/testpmd_fwd.bash
+++ b/yardstick/benchmark/scenarios/networking/testpmd_fwd.bash
@@ -13,6 +13,10 @@ set -e
# Commandline arguments
DST_MAC=$1 # MAC address of the peer port
+ETH1=$2
+ETH2=$3
+
+DPDK_VERSION="dpdk-17.02"
load_modules()
{
@@ -25,13 +29,13 @@ load_modules()
if lsmod | grep "igb_uio" &> /dev/null ; then
echo "igb_uio module is loaded"
else
- insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
+ insmod /opt/tempT/$DPDK_VERSION/x86_64-native-linuxapp-gcc/kmod/igb_uio.ko
fi
if lsmod | grep "rte_kni" &> /dev/null ; then
echo "rte_kni module is loaded"
else
- insmod /dpdk/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
+ insmod /opt/tempT/$DPDK_VERSION/x86_64-native-linuxapp-gcc/kmod/rte_kni.ko
fi
}
@@ -42,15 +46,17 @@ change_permissions()
}
add_interface_to_dpdk(){
+ ip link set $ETH1 down
+ ip link set $ETH2 down
interfaces=$(lspci |grep Eth |tail -n +2 |awk '{print $1}')
- /dpdk/tools/dpdk-devbind.py --bind=igb_uio $interfaces
+ /opt/tempT/$DPDK_VERSION/usertools//dpdk-devbind.py --bind=igb_uio $interfaces
}
run_testpmd()
{
blacklist=$(lspci |grep Eth |awk '{print $1}'|head -1)
- cd /dpdk
- sudo ./destdir/bin/testpmd -c 0x07 -n 4 -b $blacklist -- -a --eth-peer=1,$DST_MAC --forward-mode=mac
+ cd /opt/tempT/$DPDK_VERSION/x86_64-native-linuxapp-gcc/app
+ sudo ./testpmd -c 0x07 -n 4 -b $blacklist -- -a --eth-peer=1,$DST_MAC --forward-mode=mac
}
main()
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py
index 0e4785294..be2fa3f3b 100644
--- a/yardstick/benchmark/scenarios/networking/vnf_generic.py
+++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py
@@ -14,6 +14,7 @@
import copy
import logging
+import time
import ipaddress
from itertools import chain
@@ -484,3 +485,11 @@ class NetworkServiceTestCase(scenario_base.Scenario):
# https://bugs.python.org/issue9400
LOG.exception("")
raise RuntimeError("Error in teardown")
+
+ def pre_run_wait_time(self, time_seconds):
+ """Time waited before executing the run method"""
+ time.sleep(time_seconds)
+
+ def post_run_wait_time(self, time_seconds):
+ """Time waited after executing the run method"""
+ pass