aboutsummaryrefslogtreecommitdiffstats
path: root/yardstick/benchmark/scenarios
diff options
context:
space:
mode:
Diffstat (limited to 'yardstick/benchmark/scenarios')
-rw-r--r--yardstick/benchmark/scenarios/storage/fio.py39
-rw-r--r--yardstick/benchmark/scenarios/storage/fio_benchmark.bash43
2 files changed, 29 insertions, 53 deletions
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