diff options
Diffstat (limited to 'yardstick/benchmark/scenarios')
15 files changed, 572 insertions, 1 deletions
diff --git a/yardstick/benchmark/scenarios/availability/attacker_conf.yaml b/yardstick/benchmark/scenarios/availability/attacker_conf.yaml index e5d1b9f0b..d37d66964 100644 --- a/yardstick/benchmark/scenarios/availability/attacker_conf.yaml +++ b/yardstick/benchmark/scenarios/availability/attacker_conf.yaml @@ -15,3 +15,15 @@ bare-metal-down: stop-service: inject_script: ha_tools/stop_service.bash recovery_script: ha_tools/start_service.bash + +close-interface: + inject_script: ha_tools/network/close_interface.bash + recovery_script: ha_tools/network/open_interface.bash + +stress-cpu: + inject_script: ha_tools/node/stress_cpu.bash + recovery_script: ha_tools/node/release_cpu.bash + +block-io: + inject_script: ha_tools/disk/block_io.bash + recovery_script: ha_tools/disk/recovery_disk_io.bash
\ No newline at end of file diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/disk/block_io.bash b/yardstick/benchmark/scenarios/availability/ha_tools/disk/block_io.bash new file mode 100644 index 000000000..2ccf7eeab --- /dev/null +++ b/yardstick/benchmark/scenarios/availability/ha_tools/disk/block_io.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 +############################################################################## + +# make a disk IO jam + +sudo dd if=/dev/zero of=/test.dbf bs=8k count=30000000 & diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/disk/recovery_disk_io.bash b/yardstick/benchmark/scenarios/availability/ha_tools/disk/recovery_disk_io.bash new file mode 100644 index 000000000..dbe8519ba --- /dev/null +++ b/yardstick/benchmark/scenarios/availability/ha_tools/disk/recovery_disk_io.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 +############################################################################## + +# recover a node from disk io block status + +sudo kill `pidof dd` + diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/network/close_interface.bash b/yardstick/benchmark/scenarios/availability/ha_tools/network/close_interface.bash new file mode 100644 index 000000000..02c8d4736 --- /dev/null +++ b/yardstick/benchmark/scenarios/availability/ha_tools/network/close_interface.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 +############################################################################## + +# close a network interface. +# parameter: $1 - interface-name + +ifconfig $1 down
\ No newline at end of file diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/network/open_interface.bash b/yardstick/benchmark/scenarios/availability/ha_tools/network/open_interface.bash new file mode 100644 index 000000000..953d5d30d --- /dev/null +++ b/yardstick/benchmark/scenarios/availability/ha_tools/network/open_interface.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 +############################################################################## + +# open a network interface. +# parameter: $1 - interfaced-name + +ifconfig $1 up
\ No newline at end of file diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/node/release_cpu.bash b/yardstick/benchmark/scenarios/availability/ha_tools/node/release_cpu.bash new file mode 100644 index 000000000..8e25fae5c --- /dev/null +++ b/yardstick/benchmark/scenarios/availability/ha_tools/node/release_cpu.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 +############################################################################## + +# release CPU stress. + +ps -ef|grep "dd if=/dev/zero of=/dev/null"|awk '{print$2}'|xargs kill -9
\ No newline at end of file diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/node/stress_cpu.bash b/yardstick/benchmark/scenarios/availability/ha_tools/node/stress_cpu.bash new file mode 100644 index 000000000..30aa70748 --- /dev/null +++ b/yardstick/benchmark/scenarios/availability/ha_tools/node/stress_cpu.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 +############################################################################## + +# stress CPU usage to 100%. + +for i in `seq 1 $(cat /proc/cpuinfo |grep "physical id" |wc -l)`; do dd if=/dev/zero of=/dev/null & done
\ No newline at end of file diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/nova/create_flavor.bash b/yardstick/benchmark/scenarios/availability/ha_tools/nova/create_flavor.bash new file mode 100644 index 000000000..5c2d6d70e --- /dev/null +++ b/yardstick/benchmark/scenarios/availability/ha_tools/nova/create_flavor.bash @@ -0,0 +1,19 @@ +#!/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 +############################################################################## + +# create flavor +# parameter: $1-name $2-id $3-ram $4-disk $5-vcpus + +set -e + +source /root/openrc + +nova flavor-create $1 $2 $3 $4 $5 diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/nova/delete_flavor.bash b/yardstick/benchmark/scenarios/availability/ha_tools/nova/delete_flavor.bash new file mode 100644 index 000000000..67d0c902e --- /dev/null +++ b/yardstick/benchmark/scenarios/availability/ha_tools/nova/delete_flavor.bash @@ -0,0 +1,19 @@ +#!/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 +############################################################################## + +# delete a flavor +# parameter: $1 - flavor name/id + +set -e + +source /root/openrc + +nova flavor-delete $1
\ No newline at end of file diff --git a/yardstick/benchmark/scenarios/availability/ha_tools/nova/show_flavors.bash b/yardstick/benchmark/scenarios/availability/ha_tools/nova/show_flavors.bash new file mode 100644 index 000000000..0b1a9f056 --- /dev/null +++ b/yardstick/benchmark/scenarios/availability/ha_tools/nova/show_flavors.bash @@ -0,0 +1,18 @@ +#!/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 +############################################################################## + +# show all of the flavors + +set -e + +source /root/openrc + +nova flavor-list
\ 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 1e6746302..309a03de8 100644 --- a/yardstick/benchmark/scenarios/availability/operation_conf.yaml +++ b/yardstick/benchmark/scenarios/availability/operation_conf.yaml @@ -14,3 +14,7 @@ swift-upload-file: swift-download-file: action_script: ha_tools/swift/download.bash rollback_script: ha_tools/file/remove_file.bash + +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 diff --git a/yardstick/benchmark/scenarios/availability/result_checker_conf.yaml b/yardstick/benchmark/scenarios/availability/result_checker_conf.yaml index 638c39a6e..faa4eb57d 100644 --- a/yardstick/benchmark/scenarios/availability/result_checker_conf.yaml +++ b/yardstick/benchmark/scenarios/availability/result_checker_conf.yaml @@ -8,4 +8,6 @@ process-checker: service-checker: verify_script: ha_tools/check_service.bash nova-instance-checker: - verify_script: ha_tools/nova/show_instances.bash
\ No newline at end of file + 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 diff --git a/yardstick/benchmark/scenarios/storage/storagecapacity.bash b/yardstick/benchmark/scenarios/storage/storagecapacity.bash new file mode 100644 index 000000000..6ed4b2811 --- /dev/null +++ b/yardstick/benchmark/scenarios/storage/storagecapacity.bash @@ -0,0 +1,69 @@ +#!/bin/bash + +############################################################################## +# Copyright (c) 2016 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 +############################################################################## + +# Measure storage capacity and scale of a host + +set -e +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 +} + +# write the disk size to stdout in json format +output_disk_size() +{ + DEVICENUM=`awk 'END{print NR}' $OUTPUT_FILE` + DISKSIZE=`awk 'BEGIN{cnt=0;} {cnt=cnt+$2} END{print cnt}' $OUTPUT_FILE` + echo -e "{\ + \"Number of devices\":\"$DEVICENUM\", \ + \"Total disk size\":\"$DISKSIZE bytes\" \ + }" +} + +# run block_size test +run_block_size() +{ + echo -n "" > $OUTPUT_FILE + blkdevices=`fdisk -l | grep '^Disk.*bytes$' | awk -F [:,\ ] '{print $2}'` + blkdevices=($blkdevices) + for bd in "${blkdevices[@]}";do + blk_size=`blockdev --getbsz $bd` + echo '"'$bd'" '$blk_size >> $OUTPUT_FILE + done +} + +# write the block size to stdout in json format +output_block_size() +{ + BLK_SIZE_STR=`awk 'BEGIN{r="{";} {r=r""$1":"$2","} END{print r}' $OUTPUT_FILE` + BLK_SIZE_STR=${BLK_SIZE_STR%,}"}" + echo $BLK_SIZE_STR +} + +main() +{ + test_type=$1 + case $test_type in + "disk_size" ) + run_disk_size + output_disk_size + ;; + "block_size" ) + run_block_size + output_block_size + ;; + esac +} + +main $1 diff --git a/yardstick/benchmark/scenarios/storage/storagecapacity.py b/yardstick/benchmark/scenarios/storage/storagecapacity.py new file mode 100644 index 000000000..49e3a0339 --- /dev/null +++ b/yardstick/benchmark/scenarios/storage/storagecapacity.py @@ -0,0 +1,133 @@ +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd and other. +# +# 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 +############################################################################## +import pkg_resources +import logging +import json + +import yardstick.ssh as ssh +from yardstick.benchmark.scenarios import base + +LOG = logging.getLogger(__name__) + + +class StorageCapacity(base.Scenario): + """Measure storage capacity and scale. + + Parameters: + test_type - specified whether to measure. + valid test type are disk_size, block_size, disk_utilization + type: string + unit: na + default: "disk_size" + interval - specified how ofter to stat disk utilization + type: int + unit: seconds + default: 1 + count - specified how many times to stat disk utilization + type: int + unit: na + default: 15 + + This scenario reads hardware specification, + disk size, block size and disk utilization. + """ + __scenario_type__ = "StorageCapacity" + TARGET_SCRIPT = "storagecapacity.bash" + + def __init__(self, scenario_cfg, context_cfg): + self.scenario_cfg = scenario_cfg + self.context_cfg = context_cfg + self.setup_done = False + + def setup(self): + """scenario setup""" + self.target_script = pkg_resources.resource_filename( + "yardstick.benchmark.scenarios.storage", + StorageCapacity.TARGET_SCRIPT) + host = self.context_cfg['host'] + if host is None: + raise RuntimeError('No right node.Please check the configuration') + host_user = host.get('user', 'ubuntu') + host_ip = host.get('ip', None) + host_pwd = host.get('password', 'root') + LOG.debug("user:%s, host:%s", host_user, host_ip) + + self.client = ssh.SSH(host_user, host_ip, password=host_pwd) + self.client.wait(timeout=600) + + # copy script to host + self.client.run("cat > ~/storagecapacity.sh", + stdin=open(self.target_script, 'rb')) + + self.setup_done = True + + def _get_disk_utilization(self): + """Get disk utilization using iostat.""" + options = self.scenario_cfg["options"] + interval = options.get('interval', 1) + count = options.get('count', 15) + + cmd = "sudo iostat -dx %d %d | awk 'NF==14 && \ + $1 !~ /Device/ {print $1,$14}'" % (interval, count) + + LOG.debug("Executing command: %s", cmd) + status, stdout, stderr = self.client.execute(cmd) + if status: + raise RuntimeError(stderr) + + device_name_arr = [] + min_util_arr = [] + max_util_arr = [] + avg_util_arr = [] + for row in stdout.split('\n'): + kv = row.split(' ') + if len(kv) != 2: + continue + name = kv[0] + util = float(kv[1]) + if name not in device_name_arr: + device_name_arr.append(name) + min_util_arr.append(util) + max_util_arr.append(util) + avg_util_arr.append(util) + else: + i = device_name_arr.index(name) + min_util_arr[i] = min_util_arr[i] \ + if min_util_arr[i] < util else util + max_util_arr[i] = max_util_arr[i] \ + if max_util_arr[i] > util else util + avg_util_arr[i] += util + r = {} + for i in range(len(device_name_arr)): + r[device_name_arr[i]] = {"min_util": min_util_arr[i], + "max_util": max_util_arr[i], + "avg_util": avg_util_arr[i]/count} + return r + + def run(self, result): + """execute the benchmark""" + + if not self.setup_done: + self.setup() + + options = self.scenario_cfg["options"] + test_type = options.get('test_type', 'disk_size') + + if test_type == "disk_utilization": + r = self._get_disk_utilization() + result.update(r) + else: + cmd = "sudo bash storagecapacity.sh " + test_type + + LOG.debug("Executing command: %s", cmd) + status, stdout, stderr = self.client.execute(cmd) + if status: + raise RuntimeError(stderr) + + result.update(json.loads(stdout)) diff --git a/yardstick/benchmark/scenarios/storage/storperf.py b/yardstick/benchmark/scenarios/storage/storperf.py new file mode 100644 index 000000000..d39c23aa2 --- /dev/null +++ b/yardstick/benchmark/scenarios/storage/storperf.py @@ -0,0 +1,208 @@ +############################################################################## +# Copyright (c) 2016 Huawei Technologies Co.,Ltd. +# +# 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 +############################################################################## +import logging +import json +import requests +import time + +from yardstick.benchmark.scenarios import base + +LOG = logging.getLogger(__name__) + + +class StorPerf(base.Scenario): + """Execute StorPerf benchmark. + Once the StorPerf container has been started and the ReST API exposed, + you can interact directly with it using the ReST API. StorPerf comes with a + Swagger interface that is accessible through the exposed port at: + http://StorPerf:5000/swagger/index.html + + Command line options: + target = [device or path] (Optional): + The path to either an attached storage device (/dev/vdb, etc) or a + directory path (/opt/storperf) that will be used to execute the performance + test. In the case of a device, the entire device will be used. + If not specified, the current directory will be used. + + workload = [workload module] (Optional): + If not specified, the default is to run all workloads. + The workload types are: + rs: 100% Read, sequential data + ws: 100% Write, sequential data + rr: 100% Read, random access + wr: 100% Write, random access + rw: 70% Read / 30% write, random access + + nossd (Optional): + Do not perform SSD style preconditioning. + + nowarm (Optional): + Do not perform a warmup prior to measurements. + + report = [job_id] (Optional): + Query the status of the supplied job_id and report on metrics. + If a workload is supplied, will report on only that subset. + + """ + __scenario_type__ = "StorPerf" + + def __init__(self, scenario_cfg, context_cfg): + """Scenario construction.""" + self.scenario_cfg = scenario_cfg + self.context_cfg = context_cfg + self.options = self.scenario_cfg["options"] + + self.target = self.options.get("StorPerf_ip", None) + self.query_interval = self.options.get("query_interval", 10) + # Maximum allowed job time + self.timeout = self.options.get('timeout', 3600) + + self.setup_done = False + self.job_completed = False + + def _query_setup_state(self): + """Query the stack status.""" + LOG.info("Querying the stack state...") + setup_query = requests.get('http://%s:5000/api/v1.0/configurations' + % self.target) + + setup_query_content = json.loads(setup_query.content) + if setup_query_content["stack_created"]: + self.setup_done = True + LOG.debug("stack_created: %s" + % setup_query_content["stack_created"]) + + def setup(self): + """Set the configuration.""" + env_args = {} + env_args_payload_list = ["agent_count", "public_network", + "agent_image", "volume_size"] + + for env_argument in env_args_payload_list: + if env_argument in self.options: + env_args[env_argument] = self.options[env_argument] + + LOG.info("Creating a stack on node %s with parameters %s" % + (self.target, env_args)) + setup_res = requests.post('http://%s:5000/api/v1.0/configurations' + % self.target, json=env_args) + + setup_res_content = json.loads(setup_res.content) + + if setup_res.status_code == 400: + raise RuntimeError("Failed to create a stack, error message:", + setup_res_content["message"]) + elif setup_res.status_code == 200: + LOG.info("stack_id: %s" % setup_res_content["stack_id"]) + + while not self.setup_done: + self._query_setup_state() + time.sleep(self.query_interval) + + # TODO: Support Storperf job status. + + # def _query_job_state(self, job_id): + # """Query the status of the supplied job_id and report on metrics""" + # LOG.info("Fetching report for %s..." % job_id) + # report_res = requests.get('http://%s:5000/api/v1.0/jobs?id=%s' % + # (self.target, job_id)) + + # report_res_content = json.loads(report_res.content) + + # if report_res.status_code == 400: + # raise RuntimeError("Failed to fetch report, error message:", + # report_res_content["message"]) + # else: + # job_status = report_res_content["status"] + + # LOG.debug("Job is: %s..." % job_status) + # if job_status == "completed": + # self.job_completed = True + + # TODO: Support using StorPerf ReST API to read Job ETA. + + # if job_status == "completed": + # self.job_completed = True + # ETA = 0 + # elif job_status == "running": + # ETA = report_res_content['time'] + # + # return ETA + + def run(self, result): + """Execute StorPerf benchmark""" + if not self.setup_done: + self.setup() + + job_args = {} + job_args_payload_list = ["block_sizes", "queue_depths", "deadline", + "target", "nossd", "nowarm", "workload"] + + for job_argument in job_args_payload_list: + if job_argument in self.options: + job_args[job_argument] = self.options[job_argument] + + LOG.info("Starting a job with parameters %s" % job_args) + job_res = requests.post('http://%s:5000/api/v1.0/jobs' % self.target, + json=job_args) + + job_res_content = json.loads(job_res.content) + + if job_res.status_code == 400: + raise RuntimeError("Failed to start a job, error message:", + job_res_content["message"]) + elif job_res.status_code == 200: + job_id = job_res_content["job_id"] + LOG.info("Started job id: %s..." % job_id) + + time.sleep(self.timeout) + terminate_res = requests.delete('http://%s:5000/api/v1.0/jobs' % + self.target) + + if terminate_res.status_code == 400: + terminate_res_content = json.loads(terminate_res.content) + raise RuntimeError("Failed to start a job, error message:", + terminate_res_content["message"]) + + # TODO: Support Storperf job status. + + # while not self.job_completed: + # self._query_job_state(job_id) + # time.sleep(self.query_interval) + + # TODO: Support using ETA to polls for completion. + # Read ETA, next poll in 1/2 ETA time slot. + # If ETA is greater than the maximum allowed job time, + # then terminate job immediately. + + # while not self.job_completed: + # esti_time = self._query_state(job_id) + # if esti_time > self.timeout: + # terminate_res = requests.delete('http://%s:5000/api/v1.0 + # /jobs' % self.target) + # else: + # time.sleep(int(est_time)/2) + + result_res = requests.get('http://%s:5000/api/v1.0/jobs?id=%s' % + (self.target, job_id)) + result_res_content = json.loads(result_res.content) + + result.update(result_res_content) + + def teardown(self): + """Deletes the agent configuration and the stack""" + teardown_res = requests.delete('http://%s:5000/api/v1.0/\ + configurations' % self.target) + + if teardown_res.status_code == 400: + teardown_res_content = json.loads(teardown_res.content) + raise RuntimeError("Failed to reset environment, error message:", + teardown_res_content['message']) + + self.setup_done = False |