From 17777bcad74a460f754ca6b324e95ca814e6b65d Mon Sep 17 00:00:00 2001 From: Karol Latecki Date: Fri, 22 Jun 2018 09:37:12 +0200 Subject: [PATCH] test/vhost: allow FIO to output JSON Add option in test/vhost/common.sh to run FIO with --output-format=json Change-Id: I3115cf35d48a15a539d91e21f8f128970f150467 Signed-off-by: Karol Latecki Reviewed-on: https://review.gerrithub.io/416525 Tested-by: SPDK Automated Test System Reviewed-by: Ben Walker Reviewed-by: Seth Howell Reviewed-by: John Kariuki Reviewed-by: Pawel Wodkowski Reviewed-by: Tomasz Zawadzki Reviewed-by: Daniel Verkamp --- test/vhost/common/common.sh | 3 ++- test/vhost/common/run_fio.py | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/test/vhost/common/common.sh b/test/vhost/common/common.sh index 9e928fcfd0..210de36bf1 100644 --- a/test/vhost/common/common.sh +++ b/test/vhost/common/common.sh @@ -999,6 +999,7 @@ function run_fio() mkdir -p $out ;; --local) run_server_mode=false ;; + --json) json="--json" ;; *) error "Invalid argument '$arg'" return 1 @@ -1044,7 +1045,7 @@ function run_fio() python $SPDK_BUILD_DIR/test/vhost/common/run_fio.py --job-file=/root/$job_fname \ $([[ ! -z "$fio_bin" ]] && echo "--fio-bin=$fio_bin") \ - --out=$out ${fio_disks%,} + --out=$out $json ${fio_disks%,} } # Shutdown or kill any running VM and SPDK APP. diff --git a/test/vhost/common/run_fio.py b/test/vhost/common/run_fio.py index 4010df4768..2bf897edb3 100755 --- a/test/vhost/common/run_fio.py +++ b/test/vhost/common/run_fio.py @@ -23,6 +23,7 @@ def show_help(): -f, --fio-bin Location of FIO binary on local host (Default "fio") -o, --out Directory used to save generated job files and files with test results + -J, --json Use JSON format for output -p, --perf-vmex Enable aggregating statistic for VMEXITS for VMs """) @@ -43,12 +44,14 @@ def save_file(path, mode, contents): fh.close() -def run_fio(vms, fio_cfg_fname, out_path, perf_vmex=False): +def run_fio(vms, fio_cfg_fname, out_path, perf_vmex=False, json=False): global fio_bin job_name = os.path.splitext(os.path.basename(fio_cfg_fname))[0] # Build command for FIO fio_cmd = " ".join([fio_bin, "--eta=never"]) + if json: + fio_cmd = " ".join([fio_bin, "--output-format=json"]) for vm in vms: # vm[0] = IP address, vm[1] = Port number fio_cmd = " ".join([fio_cmd, @@ -114,11 +117,12 @@ def main(): fio_cfg = None out_dir = None perf_vmex = False + json = False try: - opts, args = getopt.getopt(sys.argv[1:], "hj:f:o:p", + opts, args = getopt.getopt(sys.argv[1:], "hJj:f:o:p", ["help", "job-file=", "fio-bin=", - "out=", "perf-vmex"]) + "out=", "perf-vmex", "json"]) except getopt.GetoptError: show_help() sys.exit(1) @@ -139,6 +143,8 @@ def main(): out_dir = a elif o in ("-f", "--fio-bin"): fio_bin = a + elif o in ("-J", "--json"): + json = True if fio_cfg is None: print("ERROR! No FIO job provided!") @@ -155,7 +161,7 @@ def main(): vms.append((ip, port, filenames)) print("Running job file: {0}".format(fio_cfg)) - run_fio(vms, fio_cfg, out_dir, perf_vmex) + run_fio(vms, fio_cfg, out_dir, perf_vmex, json) if __name__ == "__main__":