From 735af0fc05d73cbc7bd97b52a230d966cbfec6c3 Mon Sep 17 00:00:00 2001 From: houjingwen Date: Wed, 16 Sep 2015 11:19:15 +0000 Subject: Fix bug in fio scenario 1) when duration>3600s in fio.yaml, ssh time out 2) sometimes the latency value in test result is null 3) update plot.py, fit for code update in fio.py 4) small bug in file.py (result output dump) Add --output-format=json in default args, so fio command can return json format data. JIRA: YARDSTICK-143 Change-Id: Ie02977b8c9f11986a1eed66896b84d18db3d2211 Signed-off-by: houjingwen --- yardstick/benchmark/scenarios/storage/fio.py | 39 +++++++++++++------- .../benchmark/scenarios/storage/fio_benchmark.bash | 43 ++-------------------- yardstick/dispatcher/file.py | 3 +- yardstick/plot/plotter.py | 16 ++++---- 4 files changed, 39 insertions(+), 62 deletions(-) (limited to 'yardstick') diff --git a/yardstick/benchmark/scenarios/storage/fio.py b/yardstick/benchmark/scenarios/storage/fio.py index d3695165f..42f159164 100644 --- a/yardstick/benchmark/scenarios/storage/fio.py +++ b/yardstick/benchmark/scenarios/storage/fio.py @@ -17,7 +17,7 @@ LOG = logging.getLogger(__name__) class Fio(base.Scenario): - """Execute fio benchmark on host + """Execute fio benchmark in a host Parameters filename - file name for fio workload @@ -73,8 +73,9 @@ class Fio(base.Scenario): def run(self, args): """execute the benchmark""" - default_args = "-ioengine=libaio -direct=1 " \ - "-group_reporting -numjobs=1 -time_based" + default_args = "-ioengine=libaio -direct=1 -group_reporting " \ + "-numjobs=1 -time_based --output-format=json" + result = {} if not self.setup_done: self.setup() @@ -97,21 +98,32 @@ class Fio(base.Scenario): else: runtime = 30 - args = "-filename=%s -bs=%s -iodepth=%s -rw=%s -ramp_time=%s " \ - "-runtime=%s -name=%s" \ - % (filename, bs, iodepth, rw, ramp_time, runtime, name) - cmd = "sudo bash fio.sh %s %s %s" \ - % (filename, args, default_args) + cmd_args = "-filename=%s -bs=%s -iodepth=%s -rw=%s -ramp_time=%s " \ + "-runtime=%s -name=%s %s" \ + % (filename, bs, iodepth, rw, ramp_time, runtime, name, + default_args) + cmd = "sudo bash fio.sh %s %s" % (filename, cmd_args) LOG.debug("Executing command: %s", cmd) - status, stdout, stderr = self.client.execute(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) - data = json.loads(stdout) + raw_data = json.loads(stdout) + + # The bandwidth unit is KB/s, and latency unit is us + 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"] + 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"] # TODO: add sla check - return data + return result def _test(): @@ -133,8 +145,9 @@ def _test(): "filename": "/home/ec2-user/data.raw", "bs": "4k", "iodepth": "1", - "rw": "write", - "ramp_time": 10, + "rw": "rw", + "ramp_time": 1, + "duration": 10 } args = {"options": options} diff --git a/yardstick/benchmark/scenarios/storage/fio_benchmark.bash b/yardstick/benchmark/scenarios/storage/fio_benchmark.bash index 0fa319dd4..2ef7f4949 100644 --- a/yardstick/benchmark/scenarios/storage/fio_benchmark.bash +++ b/yardstick/benchmark/scenarios/storage/fio_benchmark.bash @@ -15,7 +15,6 @@ set -e FIO_FILENAME=$1 shift OPTIONS="$@" -OUTPUT_FILE="yardstick-fio.log" # setup data file for fio setup() @@ -25,43 +24,10 @@ setup() fi } -# run fio test +# run fio test and write json format result to stdout run_test() { - fio $OPTIONS --output=$OUTPUT_FILE -} - -# write the result to stdout in json format -output_json() -{ - read_bw=$(grep "READ.*aggrb" $OUTPUT_FILE | awk -F [=\ ,] '{printf $9}') - write_bw=$(grep "WRITE.*aggrb" $OUTPUT_FILE | awk -F [=\ ,] '{printf $8}') - eval $(grep -e '\ lat.*stdev' -e "read.*iops" -e "write.*iops" -e "trim.*iops" $OUTPUT_FILE | sed 'N;s/\n/ /g' | grep read | awk -F [=\ ,\(\)] '{printf("read_iops=%s; read_lat_unit=%s; read_lat=%s", $12, $24, $33)}') - eval $(grep -e '\ lat.*stdev' -e "read.*iops" -e "write.*iops" -e "trim.*iops" $OUTPUT_FILE | sed 'N;s/\n/ /g' | grep write | awk -F [=\ ,\(\)] '{printf("write_iops=%s; write_lat_unit=%s; write_lat=%s", $11, $23, $32)}') - - read_bw=${read_bw:-N/A} - write_bw=${write_bw:-N/A} - read_iops=${read_iops:-N/A} - write_iops=${write_iops:-N/A} - if [ "x$read_lat" = "x" ]; then - read_lat="N/A" - else - read_lat=$read_lat$read_lat_unit - fi - if [ "x$write_lat" = "x" ]; then - write_lat="N/A" - else - write_lat=$write_lat$write_lat_unit - fi - - echo -e "{ \ - \"read_bw\":\"$read_bw\", \ - \"write_bw\":\"$write_bw\", \ - \"read_iops\":\"$read_iops\", \ - \"write_iops\":\"$write_iops\", \ - \"read_lat\":\"$read_lat\", \ - \"write_lat\":\"$write_lat\" \ - }" + fio $OPTIONS } # main entry @@ -71,10 +37,7 @@ main() setup # run the test - run_test >/dev/null - - # output result - output_json + run_test } main diff --git a/yardstick/dispatcher/file.py b/yardstick/dispatcher/file.py index 7c644f82f..dc39f152e 100644 --- a/yardstick/dispatcher/file.py +++ b/yardstick/dispatcher/file.py @@ -8,6 +8,7 @@ ############################################################################## import logging +import json from yardstick.dispatcher.base import Base as DispatchBase @@ -50,4 +51,4 @@ class FileDispatcher(DispatchBase): def record_result_data(self, data): if self.log: - self.log.info(data) + self.log.info(json.dumps(data)) diff --git a/yardstick/plot/plotter.py b/yardstick/plot/plotter.py index f3fb75d3e..0455386b5 100644 --- a/yardstick/plot/plotter.py +++ b/yardstick/plot/plotter.py @@ -213,16 +213,16 @@ class Plotter(object): is_rw_type = rw_types[i] == "rw" or rw_types[i] == "randrw" if is_r_type or is_rw_type: - # Remove trailing 'usec' and convert to float + # Convert to float data['read_lat'] = \ - [r['benchmark']['data']['read_lat'][:-4] for r in records] + [r['benchmark']['data']['read_lat'] for r in records] data['read_lat'] = \ [float(i) for i in data['read_lat']] - # Remove trailing 'KB/s' and convert to float + # Convert to int data['read_bw'] = \ - [r['benchmark']['data']['read_bw'][:-4] for r in records] + [r['benchmark']['data']['read_bw'] for r in records] data['read_bw'] = \ - [float(i) for i in data['read_bw']] + [int(i) for i in data['read_bw']] # Convert to int data['read_iops'] = \ [r['benchmark']['data']['read_iops'] for r in records] @@ -231,14 +231,14 @@ class Plotter(object): if is_w_type or is_rw_type: data['write_lat'] = \ - [r['benchmark']['data']['write_lat'][:-4] for r in records] + [r['benchmark']['data']['write_lat'] for r in records] data['write_lat'] = \ [float(i) for i in data['write_lat']] data['write_bw'] = \ - [r['benchmark']['data']['write_bw'][:-4] for r in records] + [r['benchmark']['data']['write_bw'] for r in records] data['write_bw'] = \ - [float(i) for i in data['write_bw']] + [int(i) for i in data['write_bw']] data['write_iops'] = \ [r['benchmark']['data']['write_iops'] for r in records] -- cgit 1.2.3-korg