diff options
author | houjingwen <houjingwen@huawei.com> | 2015-07-03 07:58:25 +0000 |
---|---|---|
committer | houjingwen <houjingwen@huawei.com> | 2015-07-06 02:40:51 +0000 |
commit | 6b667910909b332e78105ccdf17e39e4b286ed39 (patch) | |
tree | b58a13ad4f8b65dda0e289012c89a7410bd30271 /yardstick/benchmark/scenarios/storage/fio_benchmark.bash | |
parent | bca83ab90d5f6ffb0afe5f2e756e3fd37f85c2a7 (diff) |
Add support for measuring storage performance use fio
A simple test case is added that will test writes to ephemeral storage.
See samples/fio.yaml
The Fio test type can also be used to test block storage, just modify
the "filename" argument.
JIRA: YARDSTICK-34
Change-Id: I1758d2999f8a5fdd44726e1dfc3e9769ea39dad6
Signed-off-by: houjingwen <houjingwen@huawei.com>
Diffstat (limited to 'yardstick/benchmark/scenarios/storage/fio_benchmark.bash')
-rw-r--r-- | yardstick/benchmark/scenarios/storage/fio_benchmark.bash | 81 |
1 files changed, 81 insertions, 0 deletions
diff --git a/yardstick/benchmark/scenarios/storage/fio_benchmark.bash b/yardstick/benchmark/scenarios/storage/fio_benchmark.bash new file mode 100644 index 000000000..0fa319dd4 --- /dev/null +++ b/yardstick/benchmark/scenarios/storage/fio_benchmark.bash @@ -0,0 +1,81 @@ +#!/bin/sh + +############################################################################## +# Copyright (c) 2015 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 +############################################################################## + +set -e + +# Commandline arguments +FIO_FILENAME=$1 +shift +OPTIONS="$@" +OUTPUT_FILE="yardstick-fio.log" + +# setup data file for fio +setup() +{ + if [ ! -f $FIO_FILENAME ]; then + dd if=/dev/zero of=$FIO_FILENAME bs=1M count=1024 oflag=direct > /dev/null 2>&1 + fi +} + +# run fio test +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\" \ + }" +} + +# main entry +main() +{ + # setup the test + setup + + # run the test + run_test >/dev/null + + # output result + output_json +} + +main + |