aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/scenarios')
-rw-r--r--yardstick/benchmark/scenarios/availability/attacker_conf.yaml4
-rw-r--r--yardstick/benchmark/scenarios/availability/ha_tools/node/reboot_node.bash14
-rw-r--r--yardstick/benchmark/scenarios/availability/ha_tools/nova/get_server_floatingip.bash23
-rw-r--r--yardstick/benchmark/scenarios/availability/ha_tools/nova/list_servers.bash22
-rw-r--r--yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_resource_status.bash14
-rw-r--r--yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_resource_status_host.bash15
-rw-r--r--yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_vip_host.bash15
-rw-r--r--yardstick/benchmark/scenarios/availability/operation_conf.yaml11
-rw-r--r--yardstick/benchmark/scenarios/availability/result_checker_conf.yaml4
-rw-r--r--yardstick/benchmark/scenarios/availability/scenario_general.py5
-rwxr-xr-xyardstick/benchmark/scenarios/availability/serviceha.py5
-rw-r--r--yardstick/benchmark/scenarios/availability/util.py2
-rw-r--r--yardstick/benchmark/scenarios/compute/computecapacity.bash13
-rw-r--r--yardstick/benchmark/scenarios/compute/qemu_migrate.py17
-rw-r--r--yardstick/benchmark/scenarios/lib/attach_volume.py53
-rw-r--r--yardstick/benchmark/scenarios/lib/create_floating_ip.py60
-rw-r--r--yardstick/benchmark/scenarios/lib/create_keypair.py71
-rw-r--r--yardstick/benchmark/scenarios/lib/create_network.py64
-rw-r--r--yardstick/benchmark/scenarios/lib/create_port.py66
-rw-r--r--yardstick/benchmark/scenarios/lib/create_router.py66
-rw-r--r--yardstick/benchmark/scenarios/lib/create_sec_group.py65
-rw-r--r--yardstick/benchmark/scenarios/lib/create_server.py2
-rw-r--r--yardstick/benchmark/scenarios/lib/create_subnet.py66
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_floating_ip.py54
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_keypair.py56
-rw-r--r--yardstick/benchmark/scenarios/lib/delete_volume.py55
-rw-r--r--yardstick/benchmark/scenarios/lib/detach_volume.py54
-rw-r--r--yardstick/benchmark/scenarios/networking/pktgen.py13
-rw-r--r--yardstick/benchmark/scenarios/networking/vnf_generic.py134
-rw-r--r--yardstick/benchmark/scenarios/storage/fio.py116
-rw-r--r--yardstick/benchmark/scenarios/storage/storagecapacity.bash4
31 files changed, 1066 insertions, 97 deletions
diff --git a/yardstick/benchmark/scenarios/availability/attacker_conf.yaml b/yardstick/benchmark/scenarios/availability/attacker_conf.yaml
index aa144ab50..ee7ea7d83 100644
--- a/yardstick/benchmark/scenarios/availability/attacker_conf.yaml
+++ b/yardstick/benchmark/scenarios/availability/attacker_conf.yaml
@@ -40,3 +40,7 @@ stress-cpu:
block-io:
inject_script: ha_tools/disk/block_io.bash
recovery_script: ha_tools/disk/recovery_disk_io.bash
+
+kill-corosync:
+ inject_script: ha_tools/fault_process_kill.bash
+ recovery_script: ha_tools/node/reboot_node.bash \ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/node/reboot_node.bash b/yardstick/benchmark/scenarios/availability/ha_tools/node/reboot_node.bash
new file mode 100644
index 000000000..1ee8c9c2f
--- /dev/null
+++ b/yardstick/benchmark/scenarios/availability/ha_tools/node/reboot_node.bash
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# reboot node
+
+reboot \ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/nova/get_server_floatingip.bash b/yardstick/benchmark/scenarios/availability/ha_tools/nova/get_server_floatingip.bash
new file mode 100644
index 000000000..78dd27628
--- /dev/null
+++ b/yardstick/benchmark/scenarios/availability/ha_tools/nova/get_server_floatingip.bash
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# get floating ip of a serer
+# parameter: $1 - server name
+
+set -e
+
+if [ $OS_INSECURE ] && [ "$(echo $OS_INSECURE | tr '[:upper:]' '[:lower:]')" = "true" ]; then
+ SECURE="--insecure"
+else
+ SECURE=""
+fi
+
+openstack ${SECURE} server list -f value | grep $1 | awk '{print $5}' \ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/nova/list_servers.bash b/yardstick/benchmark/scenarios/availability/ha_tools/nova/list_servers.bash
new file mode 100644
index 000000000..0f67c021e
--- /dev/null
+++ b/yardstick/benchmark/scenarios/availability/ha_tools/nova/list_servers.bash
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# list servers
+
+set -e
+
+if [ $OS_INSECURE ] && [ "$(echo $OS_INSECURE | tr '[:upper:]' '[:lower:]')" = "true" ]; then
+ SECURE="--insecure"
+else
+ SECURE=""
+fi
+
+openstack ${SECURE} server list \ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_resource_status.bash b/yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_resource_status.bash
new file mode 100644
index 000000000..68707cf4f
--- /dev/null
+++ b/yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_resource_status.bash
@@ -0,0 +1,14 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# get pacemaker resource status
+
+pcs resource show \ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_resource_status_host.bash b/yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_resource_status_host.bash
new file mode 100644
index 000000000..7a02ccf29
--- /dev/null
+++ b/yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_resource_status_host.bash
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# get pacemaker resource status of hosts
+# parameter: $1 - resource name $2 status
+
+pcs resource show | grep $1 -A 3 | grep $2 \ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_vip_host.bash b/yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_vip_host.bash
new file mode 100644
index 000000000..f4870fdae
--- /dev/null
+++ b/yardstick/benchmark/scenarios/availability/ha_tools/pacemaker/get_vip_host.bash
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+##############################################################################
+# (c) OPNFV, Yin Kanglin and others.
+# 14_ykl@tongji.edu.cn
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+# get vip host in pacemaker
+# parameter: $1 - virtual ip name
+
+pcs resource show| grep -w $1 | awk '{print $4}' \ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/operation_conf.yaml b/yardstick/benchmark/scenarios/availability/operation_conf.yaml
index 1c39385a9..dc5169196 100644
--- a/yardstick/benchmark/scenarios/availability/operation_conf.yaml
+++ b/yardstick/benchmark/scenarios/availability/operation_conf.yaml
@@ -25,4 +25,13 @@ swift-download-file:
nova-create-flavor:
action_script: ha_tools/nova/create_flavor.bash
- rollback_script: ha_tools/nova/delete_flavor.bash \ No newline at end of file
+ rollback_script: ha_tools/nova/delete_flavor.bash
+
+get-floatingip:
+ action_script: ha_tools/nova/get_server_floatingip.bash
+ rollback_script: ha_tools/nova/list_servers.bash
+
+get-vip-host:
+ action_script: ha_tools/pacemaker/get_vip_host.bash
+ rollback_script: ha_tools/pacemaker/get_resource_status.bash
+
diff --git a/yardstick/benchmark/scenarios/availability/result_checker_conf.yaml b/yardstick/benchmark/scenarios/availability/result_checker_conf.yaml
index 0494a71a7..451cc0f11 100644
--- a/yardstick/benchmark/scenarios/availability/result_checker_conf.yaml
+++ b/yardstick/benchmark/scenarios/availability/result_checker_conf.yaml
@@ -18,4 +18,6 @@ service-checker:
nova-instance-checker:
verify_script: ha_tools/nova/show_instances.bash
nova-flavor-checker:
- verify_script: ha_tools/nova/show_flavors.bash \ No newline at end of file
+ verify_script: ha_tools/nova/show_flavors.bash
+pacemaker-resource-checker:
+ verify_script: ha_tools/pacemaker/get_resource_status_host.bash \ No newline at end of file
diff --git a/yardstick/benchmark/scenarios/availability/scenario_general.py b/yardstick/benchmark/scenarios/availability/scenario_general.py
index 17ad79f29..c7ed1d6ec 100644
--- a/yardstick/benchmark/scenarios/availability/scenario_general.py
+++ b/yardstick/benchmark/scenarios/availability/scenario_general.py
@@ -26,6 +26,7 @@ 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)
@@ -63,6 +64,7 @@ class ScenarioGeneral(base.Scenario):
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")
@@ -74,9 +76,12 @@ envrioment, the HA test case NOT pass")
"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")
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 2f0012ecf..d0f5e9e4d 100755
--- a/yardstick/benchmark/scenarios/availability/serviceha.py
+++ b/yardstick/benchmark/scenarios/availability/serviceha.py
@@ -29,6 +29,7 @@ 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,6 +74,7 @@ class ServiceHA(base.Scenario):
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
@@ -81,6 +83,7 @@ the HA test case NOT pass")
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
@@ -90,6 +93,8 @@ 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/availability/util.py b/yardstick/benchmark/scenarios/availability/util.py
index 6fef622bd..d288fcbc1 100644
--- a/yardstick/benchmark/scenarios/availability/util.py
+++ b/yardstick/benchmark/scenarios/availability/util.py
@@ -51,6 +51,8 @@ def build_shell_command(param_config, remote=True, intermediate_variables=None):
def read_stdout_item(stdout, key):
+ if key == "all":
+ return stdout
for item in stdout.splitlines():
if key in item:
attributes = item.split("|")
diff --git a/yardstick/benchmark/scenarios/compute/computecapacity.bash b/yardstick/benchmark/scenarios/compute/computecapacity.bash
index 68741a94f..d49638fe3 100644
--- a/yardstick/benchmark/scenarios/compute/computecapacity.bash
+++ b/yardstick/benchmark/scenarios/compute/computecapacity.bash
@@ -27,12 +27,11 @@ run_capacity()
# Number of logical cores
THREAD=$(grep 'processor' /proc/cpuinfo | sort -u | wc -l)
# Total memory size
- MEMORY=$(grep 'MemTotal' /proc/meminfo | sort -u)
- ME=$(echo $MEMORY | awk '/ /{printf "%s %s", $2, $3}')
+ MEMORY=$(grep 'MemTotal' /proc/meminfo | sort -u | awk '{print $2}')
+
# Cache size per CPU
- CACHE=$(grep 'cache size' /proc/cpuinfo | sort -u)
- CA=$(echo $CACHE | awk '/ /{printf "%s", $4}')
- CACHES=$[$CA * $CPU]
+ CACHE=$(grep 'cache size' /proc/cpuinfo | sort -u | awk '{print $4}')
+ CACHES=$[$CACHE * $CPU]
HT_Value=$[$HT_Para * $CORES]
if [ $HT_Value -eq $THREAD ]; then
HT_OPEN=1
@@ -48,8 +47,8 @@ output_json()
\"Cpu_number\":\"$CPU\", \
\"Core_number\":\"$CORES\", \
\"Thread_number\":\"$THREAD\", \
- \"Memory_size\": \"$ME\", \
- \"Cache_size\": \"$CACHES KB\", \
+ \"Memory_size\": \"$MEMORY\", \
+ \"Cache_size\": \"$CACHES\", \
\"HT_Open\": \"$HT_OPEN\" \
}"
}
diff --git a/yardstick/benchmark/scenarios/compute/qemu_migrate.py b/yardstick/benchmark/scenarios/compute/qemu_migrate.py
index cee87a545..6c0446bb7 100644
--- a/yardstick/benchmark/scenarios/compute/qemu_migrate.py
+++ b/yardstick/benchmark/scenarios/compute/qemu_migrate.py
@@ -41,10 +41,18 @@ class QemuMigrate(base.Scenario):
def _put_files(self, client):
setup_options = self.scenario_cfg["setup_options"]
+ rpm_dir = setup_options["rpm_dir"]
script_dir = setup_options["script_dir"]
+ image_dir = setup_options["image_dir"]
+ LOG.debug("Send RPMs from %s to workspace %s",
+ rpm_dir, self.WORKSPACE)
+ client.put(rpm_dir, self.WORKSPACE, recursive=True)
LOG.debug("Send scripts from %s to workspace %s",
script_dir, self.WORKSPACE)
client.put(script_dir, self.WORKSPACE, recursive=True)
+ LOG.debug("Send guest image from %s to workspace %s",
+ image_dir, self.WORKSPACE)
+ client.put(image_dir, self.WORKSPACE, recursive=True)
def _run_setup_cmd(self, client, cmd):
LOG.debug("Run cmd: %s", cmd)
@@ -143,10 +151,17 @@ def _test(): # pragma: no cover
"qmp_sock_dst": "/tmp/qmp-sock-dst",
"max_down_time": 0.10
}
+ sla = {
+ "max_totaltime": 10,
+ "max_downtime": 0.10,
+ "max_setuptime": 0.50,
+ }
args = {
- "options": options
+ "options": options,
+ "sla": sla
}
result = {}
+
migrate = QemuMigrate(args, ctx)
migrate.run(result)
print(result)
diff --git a/yardstick/benchmark/scenarios/lib/attach_volume.py b/yardstick/benchmark/scenarios/lib/attach_volume.py
new file mode 100644
index 000000000..88124964b
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/attach_volume.py
@@ -0,0 +1,53 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class AttachVolume(base.Scenario):
+ """Attach a volmeu 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.server_id = self.options.get("server_id", "TestServer")
+ self.volume_id = self.options.get("volume_id", None)
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.attach_server_volume(self.server_id,
+ self.volume_id)
+
+ if status:
+ LOG.info("Attach volume to server successful!")
+ else:
+ LOG.info("Attach volume to server failed!")
diff --git a/yardstick/benchmark/scenarios/lib/create_floating_ip.py b/yardstick/benchmark/scenarios/lib/create_floating_ip.py
new file mode 100644
index 000000000..328566d48
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_floating_ip.py
@@ -0,0 +1,60 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+import os
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class CreateFloatingIp(base.Scenario):
+ """Create an OpenStack floating ip"""
+
+ __scenario_type__ = "CreateFloatingIp"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.ext_net_id = os.getenv("EXTERNAL_NETWORK", "external")
+
+ self.neutron_client = op_utils.get_neutron_client()
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ net_id = op_utils.get_network_id(self.neutron_client, self.ext_net_id)
+ floating_info = op_utils.create_floating_ip(self.neutron_client,
+ extnet_id=net_id)
+ if floating_info:
+ LOG.info("Creating floating ip successful!")
+ else:
+ LOG.error("Creating floating ip failed!")
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ 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
new file mode 100644
index 000000000..2185bfa5d
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_keypair.py
@@ -0,0 +1,71 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import 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
+
+LOG = logging.getLogger(__name__)
+
+
+class CreateKeypair(base.Scenario):
+ """Create an OpenStack keypair"""
+
+ __scenario_type__ = "CreateKeypair"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ 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.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ 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)
+ print("Writing %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")
+
+ if keypair:
+ result.update({"keypair_create": 1})
+ LOG.info("Create keypair successful!")
+ else:
+ 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)
diff --git a/yardstick/benchmark/scenarios/lib/create_network.py b/yardstick/benchmark/scenarios/lib/create_network.py
new file mode 100644
index 000000000..cffff132a
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_network.py
@@ -0,0 +1,64 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class CreateNetwork(base.Scenario):
+ """Create an OpenStack network"""
+
+ __scenario_type__ = "CreateNetwork"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.openstack = self.options.get("openstack_paras", None)
+
+ self.neutron_client = op_utils.get_neutron_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ openstack_paras = {'network': self.openstack}
+ network_id = op_utils.create_neutron_net(self.neutron_client,
+ openstack_paras)
+ if network_id:
+ result.update({"network_create": 1})
+ LOG.info("Create network successful!")
+ else:
+ result.update({"network_create": 0})
+ LOG.error("Create network failed!")
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [network_id]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_port.py b/yardstick/benchmark/scenarios/lib/create_port.py
new file mode 100644
index 000000000..6a3a23a10
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_port.py
@@ -0,0 +1,66 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class CreatePort(base.Scenario):
+ """Create an OpenStack flavor"""
+
+ __scenario_type__ = "CreatePort"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.openstack = self.options.get("openstack_paras", None)
+
+ self.neutron_client = op_utils.get_neutron_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ openstack_paras = {'port': self.openstack}
+ port = self.neutron_client.create_port(openstack_paras)
+
+ if port:
+ result.update({"Port_Create": 1})
+ LOG.info("Create Port successful!")
+ else:
+ result.update({"Port_Create": 0})
+ LOG.error("Create Port failed!")
+
+ check_result = port['port']['id']
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [check_result]
+ return self._push_to_outputs(keys, values)
diff --git a/yardstick/benchmark/scenarios/lib/create_router.py b/yardstick/benchmark/scenarios/lib/create_router.py
new file mode 100644
index 000000000..9aa57ebb2
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_router.py
@@ -0,0 +1,66 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class CreateRouter(base.Scenario):
+ """Create an OpenStack router"""
+
+ __scenario_type__ = "CreateRouter"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.openstack = self.options.get("openstack_paras", None)
+
+ self.neutron_client = op_utils.get_neutron_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ openstack_paras = {'router': self.openstack}
+ router_id = op_utils.create_neutron_router(self.neutron_client,
+ openstack_paras)
+ if router_id:
+ result.update({"network_create": 1})
+ LOG.info("Create router successful!")
+ else:
+ result.update({"network_create": 0})
+ LOG.error("Create router failed!")
+
+ check_result = router_id
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [check_result]
+ 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
new file mode 100644
index 000000000..3d1aec9e8
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_sec_group.py
@@ -0,0 +1,65 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class CreateSecgroup(base.Scenario):
+ """Create an OpenStack security group"""
+
+ __scenario_type__ = "CreateSecgroup"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ 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.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ 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:
+ result.update({"sg_create": 0})
+ LOG.error("Create security group failed!")
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ 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 45c0bfde9..273b0045a 100644
--- a/yardstick/benchmark/scenarios/lib/create_server.py
+++ b/yardstick/benchmark/scenarios/lib/create_server.py
@@ -59,8 +59,10 @@ class CreateServer(base.Scenario):
vm = op_utils.create_instance_and_wait_for_active(self.openstack)
if vm:
+ result.update({"instance_create": 1})
LOG.info("Create server successful!")
else:
+ result.update({"instance_create": 0})
LOG.error("Create server failed!")
try:
diff --git a/yardstick/benchmark/scenarios/lib/create_subnet.py b/yardstick/benchmark/scenarios/lib/create_subnet.py
new file mode 100644
index 000000000..c34af8a9e
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/create_subnet.py
@@ -0,0 +1,66 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class CreateSubnet(base.Scenario):
+ """Create an OpenStack flavor"""
+
+ __scenario_type__ = "CreateSubnet"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.openstack = self.options.get("openstack_paras", None)
+
+ self.neutron_client = op_utils.get_neutron_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ openstack_paras = {'subnets': [self.openstack]}
+ subnet_id = op_utils.create_neutron_subnet(self.neutron_client,
+ openstack_paras)
+ if subnet_id:
+ result.update({"subnet_create": 1})
+ LOG.info("Create subnet successful!")
+ else:
+ result.update({"subnet_create": 0})
+ LOG.error("Create subnet failed!")
+
+ check_result = subnet_id
+
+ try:
+ keys = self.scenario_cfg.get('output', '').split()
+ except KeyError:
+ pass
+ else:
+ values = [check_result]
+ 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
new file mode 100644
index 000000000..4314952fb
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_floating_ip.py
@@ -0,0 +1,54 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeleteFloatingIp(base.Scenario):
+ """Delete an OpenStack floating ip """
+
+ __scenario_type__ = "DeleteFloatingIp"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.floating_ip_id = self.options.get("floating_ip_id", None)
+
+ self.nova_client = op_utils.get_nova_client()
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ 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:
+ result.update({"delete_floating_ip": 0})
+ LOG.error("Delete floating ip failed!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_keypair.py b/yardstick/benchmark/scenarios/lib/delete_keypair.py
new file mode 100644
index 000000000..135139959
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_keypair.py
@@ -0,0 +1,56 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeleteKeypair(base.Scenario):
+ """Delete an OpenStack keypair"""
+
+ __scenario_type__ = "DeleteKeypair"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.key_name = self.options.get("key_name", "yardstick_key")
+
+ self.nova_client = op_utils.get_nova_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.delete_keypair(self.nova_client,
+ self.key_name)
+
+ if status:
+ result.update({"delete_keypair": 1})
+ LOG.info("Delete keypair successful!")
+ else:
+ result.update({"delete_keypair": 0})
+ LOG.info("Delete keypair failed!")
diff --git a/yardstick/benchmark/scenarios/lib/delete_volume.py b/yardstick/benchmark/scenarios/lib/delete_volume.py
new file mode 100644
index 000000000..ea2b85812
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/delete_volume.py
@@ -0,0 +1,55 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DeleteVolume(base.Scenario):
+ """Delete an OpenStack volume"""
+
+ __scenario_type__ = "DeleteVolume"
+
+ def __init__(self, scenario_cfg, context_cfg):
+ self.scenario_cfg = scenario_cfg
+ self.context_cfg = context_cfg
+ self.options = self.scenario_cfg['options']
+
+ self.volume_id = self.options.get("volume_id", None)
+
+ self.cinder_client = op_utils.get_cinder_client()
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.delete_volume(self.cinder_client, self.volume_id)
+
+ if status:
+ result.update({"delete_volume": 1})
+ LOG.info("Delete volume successful!")
+ else:
+ result.update({"delete_volume": 0})
+ LOG.info("Delete volume failed!")
diff --git a/yardstick/benchmark/scenarios/lib/detach_volume.py b/yardstick/benchmark/scenarios/lib/detach_volume.py
new file mode 100644
index 000000000..0b02a3a81
--- /dev/null
+++ b/yardstick/benchmark/scenarios/lib/detach_volume.py
@@ -0,0 +1,54 @@
+##############################################################################
+# Copyright (c) 2017 Huawei Technologies Co.,Ltd and others.
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Apache License, Version 2.0
+# which accompanies this distribution, and is available at
+# http://www.apache.org/licenses/LICENSE-2.0
+##############################################################################
+
+from __future__ import print_function
+from __future__ import absolute_import
+
+import logging
+
+from yardstick.benchmark.scenarios import base
+import yardstick.common.openstack_utils as op_utils
+
+LOG = logging.getLogger(__name__)
+
+
+class DetachVolume(base.Scenario):
+ """Detach a volume from an instance"""
+
+ __scenario_type__ = "DetachVolume"
+
+ 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", "TestServer")
+ self.volume_id = self.options.get("volume_id", None)
+
+ self.setup_done = False
+
+ def setup(self):
+ """scenario setup"""
+
+ self.setup_done = True
+
+ def run(self, result):
+ """execute the test"""
+
+ if not self.setup_done:
+ self.setup()
+
+ status = op_utils.detach_volume(self.server_id, self.volume_id)
+
+ if status:
+ result.update({"detach_volume": 1})
+ LOG.info("Detach volume from server successful!")
+ else:
+ result.update({"detach_volume": 0})
+ LOG.info("Detach volume from server failed!")
diff --git a/yardstick/benchmark/scenarios/networking/pktgen.py b/yardstick/benchmark/scenarios/networking/pktgen.py
index 1e0a5fcbb..a9e7aa6a3 100644
--- a/yardstick/benchmark/scenarios/networking/pktgen.py
+++ b/yardstick/benchmark/scenarios/networking/pktgen.py
@@ -11,6 +11,7 @@ from __future__ import print_function
import os
import logging
+import math
import pkg_resources
from oslo_serialization import jsonutils
@@ -357,15 +358,15 @@ class Pktgen(base.Scenario):
result.update(jsonutils.loads(stdout))
- result['packets_received'] = self._iptables_get_result()
+ received = result['packets_received'] = self._iptables_get_result()
+ sent = result['packets_sent']
result['packetsize'] = packetsize
+ # compatible with python3 /
+ ppm = math.ceil(1000000.0 * (sent - received) / sent)
+
+ result['ppm'] = ppm
if "sla" in self.scenario_cfg:
- sent = result['packets_sent']
- received = result['packets_received']
- ppm = 1000000 * (sent - received) / sent
- # if ppm is 1, then 11 out of 10 million is no pass
- ppm += (sent - received) % sent > 0
LOG.debug("Lost packets %d - Lost ppm %d", (sent - received), ppm)
sla_max_ppm = int(self.scenario_cfg["sla"]["max_ppm"])
assert ppm <= sla_max_ppm, "ppm %d > sla_max_ppm %d; " \
diff --git a/yardstick/benchmark/scenarios/networking/vnf_generic.py b/yardstick/benchmark/scenarios/networking/vnf_generic.py
index 599835d56..4510bcfba 100644
--- a/yardstick/benchmark/scenarios/networking/vnf_generic.py
+++ b/yardstick/benchmark/scenarios/networking/vnf_generic.py
@@ -14,13 +14,17 @@
""" NSPerf specific scenario definition """
from __future__ import absolute_import
-import logging
+import logging
import errno
-import os
+import ipaddress
+import os
+import sys
import re
from itertools import chain
+
+import six
from operator import itemgetter
from collections import defaultdict
@@ -31,8 +35,10 @@ from yardstick.network_services.collector.subscriber import Collector
from yardstick.network_services.vnf_generic import vnfdgen
from yardstick.network_services.vnf_generic.vnf.base import GenericVNF
from yardstick.network_services.traffic_profile.base import TrafficProfile
+from yardstick.network_services.utils import get_nsb_option
from yardstick import ssh
+
LOG = logging.getLogger(__name__)
@@ -126,19 +132,50 @@ class NetworkServiceTestCase(base.Scenario):
self.collector = None
self.traffic_profile = None
+ def _get_ip_flow_range(self, ip_start_range):
+
+ node_name, range_or_interface = next(iter(ip_start_range.items()), (None, '0.0.0.0'))
+ if node_name is not None:
+ node = self.context_cfg["nodes"].get(node_name, {})
+ try:
+ # the ip_range is the interface name
+ interface = node.get("interfaces", {})[range_or_interface]
+ except KeyError:
+ ip = "0.0.0.0"
+ mask = "255.255.255.0"
+ else:
+ ip = interface["local_ip"]
+ # we can't default these values, they must both exist to be valid
+ mask = interface["netmask"]
+
+ ipaddr = ipaddress.ip_network(six.text_type('{}/{}'.format(ip, mask)), strict=False)
+ hosts = list(ipaddr.hosts())
+ ip_addr_range = "{}-{}".format(hosts[0], hosts[-1])
+ else:
+ # we are manually specifying the range
+ ip_addr_range = range_or_interface
+ return ip_addr_range
+
def _get_traffic_flow(self):
+ flow = {}
try:
- with open(self.scenario_cfg["traffic_options"]["flow"]) as fflow:
- flow = yaml_load(fflow)
- except (KeyError, IOError, OSError):
+ fflow = self.scenario_cfg["options"]["flow"]
+ for index, src in enumerate(fflow.get("src_ip", [])):
+ flow["src_ip{}".format(index)] = self._get_ip_flow_range(src)
+
+ for index, dst in enumerate(fflow.get("dst_ip", [])):
+ flow["dst_ip{}".format(index)] = self._get_ip_flow_range(dst)
+
+ for index, publicip in enumerate(fflow.get("publicip", [])):
+ flow["public_ip{}".format(index)] = publicip
+ except KeyError:
flow = {}
- return flow
+ return {"flow": flow}
def _get_traffic_imix(self):
try:
- with open(self.scenario_cfg["traffic_options"]["imix"]) as fimix:
- imix = yaml_load(fimix)
- except (KeyError, IOError, OSError):
+ imix = {"imix": self.scenario_cfg['options']['framesize']}
+ except KeyError:
imix = {}
return imix
@@ -265,8 +302,25 @@ class NetworkServiceTestCase(base.Scenario):
for dpdk_port_num, netdev in enumerate(s):
netdev['dpdk_port_num'] = dpdk_port_num
+ def _probe_netdevs(self, node, node_dict):
+ cmd = "PATH=$PATH:/sbin:/usr/sbin ip addr show"
+ netdevs = {}
+ with SshManager(node_dict) as conn:
+ if conn:
+ exit_status = conn.execute(cmd)[0]
+ if exit_status != 0:
+ raise IncorrectSetup("Node's %s lacks ip tool." % node)
+ exit_status, stdout, _ = conn.execute(
+ self.FIND_NETDEVICE_STRING)
+ if exit_status != 0:
+ raise IncorrectSetup(
+ "Cannot find netdev info in sysfs" % node)
+ netdevs = node_dict['netdevs'] = self.parse_netdev_info(stdout)
+ return netdevs
+
@classmethod
- def _probe_missing_values(cls, netdevs, network, missing):
+ def _probe_missing_values(cls, netdevs, network):
+
mac_lower = network['local_mac'].lower()
for netdev in netdevs.values():
if netdev['address'].lower() != mac_lower:
@@ -288,36 +342,30 @@ class NetworkServiceTestCase(base.Scenario):
"""
for node, node_dict in self.context_cfg["nodes"].items():
- cmd = "PATH=$PATH:/sbin:/usr/sbin ip addr show"
- with SshManager(node_dict) as conn:
- exit_status = conn.execute(cmd)[0]
- if exit_status != 0:
- raise IncorrectSetup("Node's %s lacks ip tool." % node)
- exit_status, stdout, _ = conn.execute(
- self.FIND_NETDEVICE_STRING)
- if exit_status != 0:
- raise IncorrectSetup(
- "Cannot find netdev info in sysfs" % node)
- netdevs = node_dict['netdevs'] = self.parse_netdev_info(
- stdout)
-
- for network in node_dict["interfaces"].values():
- missing = self.TOPOLOGY_REQUIRED_KEYS.difference(network)
- if not missing:
- continue
-
- try:
- self._probe_missing_values(netdevs, network,
- missing)
- except KeyError:
- pass
- else:
- missing = self.TOPOLOGY_REQUIRED_KEYS.difference(
- network)
- if missing:
- raise IncorrectConfig(
- "Require interface fields '%s' not found, topology file "
- "corrupted" % ', '.join(missing))
+ for network in node_dict["interfaces"].values():
+ missing = self.TOPOLOGY_REQUIRED_KEYS.difference(network)
+ if not missing:
+ continue
+
+ # only ssh probe if there are missing values
+ # ssh probe won't work on Ixia, so we had better define all our values
+ try:
+ netdevs = self._probe_netdevs(node, node_dict)
+ except (SSHError, SSHTimeout):
+ raise IncorrectConfig(
+ "Unable to probe missing interface fields '%s', on node %s "
+ "SSH Error" % (', '.join(missing), node))
+ try:
+ self._probe_missing_values(netdevs, network)
+ except KeyError:
+ pass
+ else:
+ missing = self.TOPOLOGY_REQUIRED_KEYS.difference(
+ network)
+ if missing:
+ raise IncorrectConfig(
+ "Require interface fields '%s' not found, topology file "
+ "corrupted" % ', '.join(missing))
# 3. Use topology file to find connections & resolve dest address
self._resolve_topology()
@@ -393,6 +441,9 @@ printf "%s/driver:" $1 ; basename $(readlink -s $1/device/driver); } \
:param context_cfg:
:return:
"""
+ trex_lib_path = get_nsb_option('trex_client_lib')
+ sys.path[:] = list(chain([trex_lib_path], (x for x in sys.path if x != trex_lib_path)))
+
if scenario_cfg is None:
scenario_cfg = self.scenario_cfg
@@ -440,7 +491,6 @@ printf "%s/driver:" $1 ; basename $(readlink -s $1/device/driver); } \
for vnf in chain(traffic_runners, non_traffic_runners):
LOG.info("Instantiating %s", vnf.name)
vnf.instantiate(self.scenario_cfg, self.context_cfg)
- for vnf in chain(traffic_runners, non_traffic_runners):
LOG.info("Waiting for %s to instantiate", vnf.name)
vnf.wait_for_instantiate()
except RuntimeError:
@@ -473,7 +523,7 @@ printf "%s/driver:" $1 ; basename $(readlink -s $1/device/driver); } \
for vnf in self.vnfs:
# Result example:
# {"VNF1: { "tput" : [1000, 999] }, "VNF2": { "latency": 100 }}
- LOG.debug("vnf")
+ LOG.debug("collect KPI for %s", vnf.name)
result.update(self.collector.get_kpi(vnf))
def teardown(self):
diff --git a/yardstick/benchmark/scenarios/storage/fio.py b/yardstick/benchmark/scenarios/storage/fio.py
index b99e34270..98fe26973 100644
--- a/yardstick/benchmark/scenarios/storage/fio.py
+++ b/yardstick/benchmark/scenarios/storage/fio.py
@@ -28,6 +28,14 @@ class Fio(base.Scenario):
type: string
unit: na
default: /home/ubuntu/data.raw
+ job_file - fio job configuration file
+ type: string
+ unit: na
+ default: None
+ directory - mount directoey for test volume
+ type: string
+ unit: na
+ default: None
bs - block size used for the io units
type: int
unit: bytes
@@ -71,20 +79,42 @@ class Fio(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.setup_done = False
def setup(self):
"""scenario setup"""
- self.target_script = pkg_resources.resource_filename(
- "yardstick.benchmark.scenarios.storage",
- Fio.TARGET_SCRIPT)
host = self.context_cfg["host"]
self.client = ssh.SSH.from_node(host, defaults={"user": "root"})
self.client.wait(timeout=600)
- # copy script to host
- self.client._put_file_shell(self.target_script, '~/fio.sh')
+ self.job_file = self.options.get("job_file", None)
+
+ if self.job_file:
+ self.job_file_script = pkg_resources.resource_filename(
+ "yardstick.resources", 'files/' + self.job_file)
+
+ # copy script to host
+ self.client._put_file_shell(self.job_file_script, '~/job_file.ini')
+
+ else:
+ self.target_script = pkg_resources.resource_filename(
+ "yardstick.benchmark.scenarios.storage", Fio.TARGET_SCRIPT)
+
+ # copy script to host
+ self.client._put_file_shell(self.target_script, '~/fio.sh')
+
+ mount_dir = self.options.get("directory", None)
+
+ if mount_dir:
+ LOG.debug("Formating volume...")
+ self.client.execute("sudo mkfs.ext4 /dev/vdb")
+ cmd = "sudo mkdir %s" % mount_dir
+ self.client.execute(cmd)
+ LOG.debug("Mounting volume at: %s", mount_dir)
+ cmd = "sudo mount /dev/vdb %s" % mount_dir
+ self.client.execute(cmd)
self.setup_done = True
@@ -92,57 +122,69 @@ class Fio(base.Scenario):
"""execute the benchmark"""
default_args = "-ioengine=libaio -group_reporting -time_based -time_based " \
"--output-format=json"
+ timeout = 3600
if not self.setup_done:
self.setup()
- options = self.scenario_cfg["options"]
- filename = options.get("filename", "/home/ubuntu/data.raw")
- bs = options.get("bs", "4k")
- iodepth = options.get("iodepth", "1")
- rw = options.get("rw", "write")
- ramp_time = options.get("ramp_time", 20)
- size = options.get("size", "1g")
- direct = options.get("direct", "1")
- numjobs = options.get("numjobs", "1")
- rwmixwrite = options.get("rwmixwrite", 50)
- name = "yardstick-fio"
- # if run by a duration runner
- duration_time = self.scenario_cfg["runner"].get("duration", None) \
- if "runner" in self.scenario_cfg else None
- # if run by an arithmetic runner
- arithmetic_time = options.get("duration", None)
- if duration_time:
- runtime = duration_time
- elif arithmetic_time:
- runtime = arithmetic_time
+ if self.job_file:
+ cmd = "sudo fio job_file.ini --output-format=json"
else:
- runtime = 30
+ filename = self.options.get("filename", "/home/ubuntu/data.raw")
+ bs = self.options.get("bs", "4k")
+ iodepth = self.options.get("iodepth", "1")
+ rw = self.options.get("rw", "write")
+ ramp_time = self.options.get("ramp_time", 20)
+ size = self.options.get("size", "1g")
+ direct = self.options.get("direct", "1")
+ numjobs = self.options.get("numjobs", "1")
+ rwmixwrite = self.options.get("rwmixwrite", 50)
+ name = "yardstick-fio"
+ # if run by a duration runner
+ duration_time = self.scenario_cfg["runner"].get("duration", None) \
+ if "runner" in self.scenario_cfg else None
+ # if run by an arithmetic runner
+ arithmetic_time = self.options.get("duration", None)
+ if duration_time:
+ runtime = duration_time
+ elif arithmetic_time:
+ runtime = arithmetic_time
+ else:
+ runtime = 30
+ # Set timeout, so that the cmd execution does not exit incorrectly
+ # when the test run time is last long
+ timeout = int(ramp_time) + int(runtime) + 600
+
+ cmd_args = "-filename=%s -direct=%s -bs=%s -iodepth=%s -rw=%s -rwmixwrite=%s " \
+ "-size=%s -ramp_time=%s -numjobs=%s -runtime=%s -name=%s %s" \
+ % (filename, direct, bs, iodepth, rw, rwmixwrite, size, ramp_time, numjobs,
+ runtime, name, default_args)
+ cmd = "sudo bash fio.sh %s %s" % (filename, cmd_args)
- cmd_args = "-filename=%s -direct=%s -bs=%s -iodepth=%s -rw=%s -rwmixwrite=%s " \
- "-size=%s -ramp_time=%s -numjobs=%s -runtime=%s -name=%s %s" \
- % (filename, direct, bs, iodepth, rw, rwmixwrite, size, ramp_time, numjobs,
- runtime, name, default_args)
- cmd = "sudo bash fio.sh %s %s" % (filename, cmd_args)
LOG.debug("Executing command: %s", cmd)
- # Set timeout, so that the cmd execution does not exit incorrectly
- # when the test run time is last long
- timeout = int(ramp_time) + int(runtime) + 600
status, stdout, stderr = self.client.execute(cmd, timeout=timeout)
if status:
raise RuntimeError(stderr)
raw_data = jsonutils.loads(stdout)
- # The bandwidth unit is KB/s, and latency unit is us
- if rw in ["read", "randread", "rw", "randrw"]:
+ if self.job_file:
result["read_bw"] = raw_data["jobs"][0]["read"]["bw"]
result["read_iops"] = raw_data["jobs"][0]["read"]["iops"]
result["read_lat"] = raw_data["jobs"][0]["read"]["lat"]["mean"]
- if rw in ["write", "randwrite", "rw", "randrw"]:
result["write_bw"] = raw_data["jobs"][0]["write"]["bw"]
result["write_iops"] = raw_data["jobs"][0]["write"]["iops"]
result["write_lat"] = raw_data["jobs"][0]["write"]["lat"]["mean"]
+ else:
+ # The bandwidth unit is KB/s, and latency unit is us
+ if rw in ["read", "randread", "rw", "randrw"]:
+ result["read_bw"] = raw_data["jobs"][0]["read"]["bw"]
+ result["read_iops"] = raw_data["jobs"][0]["read"]["iops"]
+ result["read_lat"] = raw_data["jobs"][0]["read"]["lat"]["mean"]
+ if rw in ["write", "randwrite", "rw", "randrw"]:
+ result["write_bw"] = raw_data["jobs"][0]["write"]["bw"]
+ result["write_iops"] = raw_data["jobs"][0]["write"]["iops"]
+ result["write_lat"] = raw_data["jobs"][0]["write"]["lat"]["mean"]
if "sla" in self.scenario_cfg:
sla_error = ""
diff --git a/yardstick/benchmark/scenarios/storage/storagecapacity.bash b/yardstick/benchmark/scenarios/storage/storagecapacity.bash
index f963782d8..96db6e1be 100644
--- a/yardstick/benchmark/scenarios/storage/storagecapacity.bash
+++ b/yardstick/benchmark/scenarios/storage/storagecapacity.bash
@@ -17,7 +17,7 @@ OUTPUT_FILE=/tmp/storagecapacity-out.log
# run disk_size test
run_disk_size()
{
- fdisk -l | grep '^Disk.*bytes$' | awk -F [:,\ ] '{print $2,$7}' > $OUTPUT_FILE
+ fdisk -l | grep '^Disk.*bytes' | awk -F [:,\ ] '{print $2,$7}' > $OUTPUT_FILE
}
# write the disk size to stdout in json format
@@ -35,7 +35,7 @@ output_disk_size()
run_block_size()
{
echo -n "" > $OUTPUT_FILE
- blkdevices=`fdisk -l | grep '^Disk.*bytes$' | awk -F [:,\ ] '{print $2}'`
+ blkdevices=`fdisk -l | grep '^Disk.*bytes' | awk -F [:,\ ] '{print $2}'`
blkdevices=($blkdevices)
for bd in "${blkdevices[@]}";do
blk_size=`blockdev --getbsz $bd`