diff options
author | Chase Qi <chase.qi@linaro.org> | 2016-11-14 17:59:28 +0800 |
---|---|---|
committer | Chase Qi <chase.qi@linaro.org> | 2016-11-15 00:11:45 +0800 |
commit | 74d3b71a095915b5bfc13c626a4e2fc7bfd2757e (patch) | |
tree | 382c74bd05f7a378159af13d67d521edffc2225d | |
parent | 65d6f0ef02ffcfcce25625718fdff398460746b1 (diff) |
automated: fix fio test
* Added more params for more control from test plan
* Added readwrite and randrw test
* Stop testing fio against partition, which destroy filesystem. Mount
partition and enter mount point, run fio from there
* Show test progress and clean output
Change-Id: If63a5ca1a0485b88456a4a0f7f3ba82bcba751e0
Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rwxr-xr-x | automated/linux/fio-test/fio-test.sh | 170 | ||||
-rw-r--r-- | automated/linux/fio-test/fio-test.yaml | 20 |
2 files changed, 76 insertions, 114 deletions
diff --git a/automated/linux/fio-test/fio-test.sh b/automated/linux/fio-test/fio-test.sh index bf06755..90e7b4a 100755 --- a/automated/linux/fio-test/fio-test.sh +++ b/automated/linux/fio-test/fio-test.sh @@ -1,41 +1,27 @@ -#!/bin/bash -# -# FIO test cases for Linux -# -# Copyright (C) 2016, Linaro Limited. -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License -# as published by the Free Software Foundation; either version 2 -# of the License, or (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -# -# Author: Naresh Kamboju <naresh.kamboju@linaro.org> -# +#!/bin/sh -e +# shellcheck disable=SC1091 . ../../lib/sh-test-lib OUTPUT="$(pwd)/output" RESULT_FILE="${OUTPUT}/result.txt" -FIO_SKIP_LIST="fio_read fio_randread fio_write fio_randwrite fio_512k_write fio_512k_read" +export RESULT_FILE +PARTITION="" +IOENGINE="sync" +BLOCK_SIZE="4k" usage() { - echo "Usage: $0 [-p <partition>] [-s <true>]" 1>&2 + echo "Usage: $0 [-p <partition>] [-b <block_size>] [-i <sync|psync|libaio>] + [-s <true|false>]" 1>&2 exit 1 } -while getopts "p:s:" o; do +while getopts "p:b:i:s:" o; do case "$o" in # The current working directory will be used by default. - # Use '-p' specify partition that used for dd test. + # Use '-p' specify partition that used for fio test. p) PARTITION="${OPTARG}" ;; + b) BLOCK_SIZE="${OPTARG}" ;; + i) IOENGINE="${OPTARG}" ;; s) SKIP_INSTALL="${OPTARG}" ;; *) usage ;; esac @@ -52,106 +38,76 @@ fio_build_install() { install() { dist_name + # shellcheck disable=SC2154 case "${dist}" in Debian|Ubuntu) pkgs="fio" install_deps "${pkgs}" "${SKIP_INSTALL}" ;; Fedora|CentOS) - pkgs="gcc tar wget" + pkgs="libaio-devel gcc tar wget" install_deps "${pkgs}" "${SKIP_INSTALL}" fio_build_install ;; # When build do not have package manager # Assume development tools pre-installed - *) fio_build_install ;; + *) + fio_build_install + ;; esac } -parse_output() { - test="$1" - file="$2" - IOPS=$(grep "iops=" "${file}" | cut -d= -f4 | cut -d, -f1) - add_metric "${test}" "pass" "${IOPS}" "iops" -} - -fio_device_existence() { - # check for block device - [ -b "${PARTITION}" ] - exit_on_fail "fio_device" "fio ${FIO_SKIP_LIST}" -} - -fio_existence() { - eval "which fio" - exit_on_fail "fio" "${FIO_SKIP_LIST}" -} - -fio_read() { - file="${OUTPUT}/fio_read.txt" - fio -filename="${PARTITION}" -rw=read -direct=1 -iodepth 1 -thread \ - -ioengine=psync -bs=4k -numjobs=1 -runtime=10 -group_reporting \ - -name=fio_read 2>&1 | tee -a "${file}" - parse_output "fio_read" "${file}" - -} - -fio_randread() { - file="${OUTPUT}/fio_randread.txt" - fio -filename="${PARTITION}" -rw=randread -direct=1 -iodepth 1 -thread \ - -ioengine=psync -bs=4k -numjobs=1 -runtime=10 -group_reporting \ - -name=fio_randread 2>&1 | tee -a "${file}" - parse_output "fio_randread" "${file}" -} - -fio_write() { - file="${OUTPUT}/fio_write.txt" - fio -filename="${PARTITION}" -rw=write -direct=1 -iodepth 1 -thread \ - -ioengine=psync -bs=4k -numjobs=1 -runtime=10 -group_reporting \ - -name=fio_write 2>&1 | tee -a "${file}" - parse_output "fio_write" "${file}" -} - -fio_randwrite() { - file="${OUTPUT}/fio_randwrite.txt" - fio -filename="${PARTITION}" -rw=randwrite -direct=1 -iodepth 1 -thread \ - -ioengine=psync -bs=4k -numjobs=1 -runtime=10 -group_reporting \ - -name=fio_randwrite 2>&1 | tee -a "${file}" - parse_output "fio_randwrite" "${file}" -} - -fio_512k_write() { - file="${OUTPUT}/fio_512k_write.txt" - fio -filename="${PARTITION}" -rw=write -direct=1 -iodepth 1 -thread \ - -ioengine=psync -bs=512k -numjobs=1 -runtime=10 -group_reporting \ - -name=fio_512k_write 2>&1 | tee -a "${file}" - parse_output "fio_512k_write" "${file}" -} - -fio_512k_read() { - file="${OUTPUT}/fio_512k_read.txt" - fio -filename="${PARTITION}" -rw=read -direct=1 -iodepth 1 -thread \ - -ioengine=psync -bs=512k -numjobs=1 -runtime=10 -group_reporting \ - -name=fio_512k_read 2>&1 | tee -a "${file}" - parse_output "fio_512k_read" "${file}" +fio_test() { + # shellcheck disable=SC2039 + local rw="$1" + file="${OUTPUT}/fio-${BLOCK_SIZE}-${rw}.txt" + + # Run fio test. + echo + info_msg "Running fio ${BLOCK_SIZE} ${rw} test ..." + fio -name="${rw}" -rw="${rw}" -bs="${BLOCK_SIZE}" -size=1G -runtime=300 \ + -numjobs=1 -ioengine="${IOENGINE}" -direct=1 -group_reporting \ + -output="${file}" + echo + + # Parse output. + cat "${file}" + measurement=$(grep -m 1 "iops=" "${file}" | cut -d= -f4 | cut -d, -f1) + add_metric "fio-${rw}" "pass" "${measurement}" "iops" + + # Delete files created by fio to avoid out of space. + rm -rf ./"${rw}"* } -# Test run. +# Config test. ! check_root && error_msg "This script must be run as root" [ -d "${OUTPUT}" ] && mv "${OUTPUT}" "${OUTPUT}_$(date +%Y%m%d%H%M%S)" mkdir -p "${OUTPUT}" +# Enter test directory. +if [ -n "${PARTITION}" ]; then + if [ -b "${PARTITION}" ]; then + if df | grep "${PARTITION}"; then + mount_point=$(df | grep "${PARTITION}" | awk '{print $NF}') + else + mount_point="/media/fio" + mkdir -p "${mount_point}" + umount "${mount_point}" > /dev/null 2>&1 || true + mount "${PARTITION}" "${mount_point}" && \ + info_msg "${PARTITION} mounted to ${mount_point}" + df | grep "${PARTITION}" + fi + cd "${mount_point}" + else + error_msg "Block device ${PARTITION} NOT found" + fi +fi + +# Install and run fio test. +install info_msg "About to run fio test..." info_msg "Output directory: ${OUTPUT}" - -# Install dependency packages -install - -# Run all test -fio_device_existence -fio_existence -fio_read -fio_randread -fio_write -fio_randwrite -fio_512k_write -fio_512k_read +info_msg "fio test directory: $(pwd)" +for rw in "read" randread write randwrite rw randrw; do + fio_test "${rw}" +done diff --git a/automated/linux/fio-test/fio-test.yaml b/automated/linux/fio-test/fio-test.yaml index e355495..337fec0 100644 --- a/automated/linux/fio-test/fio-test.yaml +++ b/automated/linux/fio-test/fio-test.yaml @@ -1,10 +1,11 @@ metadata: name: fio-test format: "Lava-Test-Shell Test Definition 1.0" - description: "FIO or Flexible IO is a versatile IO workload generator Test on Linux. - The target block device partition required to run this test to be set as '/dev/sdbX'" + description: "FIO or Flexible IO is a versatile IO workload generator test + on Linux." maintainer: - naresh.kamboju@linaro.org + - chase.qi@linaro.org os: - debian - ubuntu @@ -13,8 +14,10 @@ metadata: devices: - mustang - overdrive - - d02 + - d05 - d03 + - moonshot + - thunderX - hi6220-hikey - apq8016-sbc scope: @@ -23,14 +26,17 @@ metadata: - lava-test-shell params: + # Specify block device partition that used for fio test. Example: /dev/sdb1 + # Use disk-partitioning.yaml to create and format partition, as needed. # The currenty working directory will be used by default. - # Use '-p' specify block device partition that used for fio test. - # Example: /dev/sdb1 - BLK_DEV_PARTITION: "" + PARTITION: "" + # Available IO engines: sync, psync, libaio + IOENGINE: "sync" + BLOCK_SIZE: "4k" SKIP_INSTALL: "False" run: steps: - cd ./automated/linux/fio-test/ - - ./fio-test.sh -p "${BLK_DEV_PARTITION}" -s "${SKIP_INSTALL}" + - ./fio-test.sh -p "${PARTITION}" -i "${IOENGINE}" -b "${BLOCK_SIZE}" -s "${SKIP_INSTALL}" - ../../utils/send-to-lava.sh ./output/result.txt |