diff options
Diffstat (limited to 'yardstick')
17 files changed, 386 insertions, 11 deletions
diff --git a/yardstick/benchmark/contexts/model.py b/yardstick/benchmark/contexts/model.py index 2cf31f6ea..d31f4afc0 100644 --- a/yardstick/benchmark/contexts/model.py +++ b/yardstick/benchmark/contexts/model.py @@ -201,12 +201,12 @@ class Server(Object): port_name, network.router.stack_if_name, self.secgroup_name) - self.floating_ip_assoc["stack_name"] = \ - server_name + "-fip-assoc" - template.add_floating_ip_association( - self.floating_ip_assoc["stack_name"], - self.floating_ip["stack_name"], - port_name) + self.floating_ip_assoc["stack_name"] = \ + server_name + "-fip-assoc" + template.add_floating_ip_association( + self.floating_ip_assoc["stack_name"], + self.floating_ip["stack_name"], + port_name) template.add_server(server_name, self.image, self.flavor, ports=port_name_list, 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/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 diff --git a/yardstick/cmd/commands/task.py b/yardstick/cmd/commands/task.py index 18b72e726..b38e084ac 100644 --- a/yardstick/cmd/commands/task.py +++ b/yardstick/cmd/commands/task.py @@ -206,7 +206,7 @@ class TaskParser(object): test_cases_dir += os.sep cur_pod = os.environ.get('NODE_NAME', None) - cur_installer = os.environ.get('INSTALL_TYPE', None) + cur_installer = os.environ.get('INSTALLER_TYPE', None) valid_task_files = [] valid_task_args = [] @@ -275,10 +275,16 @@ class TaskParser(object): for cfg_attrs in context_cfgs: context_type = cfg_attrs.get("type", "Heat") if "Heat" == context_type and "networks" in cfg_attrs: + # bugfix: if there are more than one network, + # only add "external_network" on first one. + # the name of netwrok should follow this rule: + # test, test2, test3 ... + # sort network with the length of network's name + sorted_networks = sorted(cfg_attrs["networks"].keys()) # config external_network based on env var - for _, attrs in cfg_attrs["networks"].items(): - attrs["external_network"] = os.environ.get( - 'EXTERNAL_NETWORK', 'net04_ext') + cfg_attrs["networks"][sorted_networks[0]]["external_network"] \ + = os.environ.get("EXTERNAL_NETWORK", "net04_ext") + context = Context.get(context_type) context.init(cfg_attrs) diff --git a/yardstick/resources/script/install/storperf.bash b/yardstick/resources/scripts/install/storperf.bash index 9bbec7206..9bbec7206 100644 --- a/yardstick/resources/script/install/storperf.bash +++ b/yardstick/resources/scripts/install/storperf.bash diff --git a/yardstick/resources/script/remove/storperf.bash b/yardstick/resources/scripts/remove/storperf.bash index a8eb51c89..a8eb51c89 100644 --- a/yardstick/resources/script/remove/storperf.bash +++ b/yardstick/resources/scripts/remove/storperf.bash |