Commit 5470a058 authored by Seth Howell's avatar Seth Howell Committed by Darek Stojaczyk
Browse files

scripts/fio.py: add argparse for command line parameters



This script was getting a bit unwieldy. adding argparse will make it
easier to add more options in the future or to set default values and
validate arguments going forward.

Change-Id: I1ffdbdf2082287ceb8a88cd3eb6ecf9bbd6c9e11
Signed-off-by: default avatarSeth Howell <seth.howell@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455724


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
parent e550cecb
Loading
Loading
Loading
Loading
+18 −23
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ import sys
import signal
import os.path
import time
import argparse

fio_template = """
[global]
@@ -44,31 +45,12 @@ def interrupt_handler(signum, frame):
    sys.exit(0)


def main():

def main(io_size, protocol, queue_depth, test_type, runtime, num_jobs, verify):
    global fio
    if (len(sys.argv) < 7):
        print("usage:")
        print("  " + sys.argv[0] + " <nvmf/iscsi> <io_size> <queue_depth> <test_type> <runtime> <num_jobs>")
        print("advanced usage:")
        print("If you want to run fio with verify, please add verify string after runtime.")
        print("Currently fio.py only support write rw randwrite randrw with verify enabled.")
        sys.exit(1)

    app = str(sys.argv[1])
    io_size = int(sys.argv[2])
    queue_depth = int(sys.argv[3])
    test_type = sys.argv[4]
    runtime = sys.argv[5]
    num_jobs = sys.argv[6]

    verify = False
    if len(sys.argv) > 7:
        verify = True

    if app == "nvmf":
    if protocol == "nvmf":
        devices = get_nvmf_target_devices()
    elif app == "iscsi":
    elif protocol == "iscsi":
        devices = get_iscsi_target_devices()

    configure_devices(devices)
@@ -166,4 +148,17 @@ def configure_devices(devices):


if __name__ == "__main__":
    main()
    parser = argparse.ArgumentParser(description="fio.py")
    parser.add_argument("-i", "--io-size", type=int, help="The desired I/O size in bytes.", required=True)
    parser.add_argument("-p", "--protocol", type=str, help="The protocol we are testing against. One of iscsi or nvmf.", required=True)
    parser.add_argument("-d", "--queue-depth", type=int, help="The desired queue depth for each job.", required=True)
    parser.add_argument("-t", "--test-type", type=str, help="The fio I/O pattern to run. e.g. read, randwrite, randrw.", required=True)
    parser.add_argument("-r", "--runtime", type=int, help="Time in seconds to run the workload.", required=True)
    parser.add_argument("-n", "--num-jobs", type=int, help="The number of fio jobs to run in your workload. default 1.", default=1)
    parser.add_argument("-v", "--verify", action="store_true", help="Supply this argument to verify the I/O.", default=False)
    args = parser.parse_args()

    if args.protocol.lower() != "nvmf" and args.protocol.lower() != "iscsi":
        parser.error("Protocol must be one of the following: nvmf, iscsi.")

    main(args.io_size, args.protocol, args.queue_depth, args.test_type, args.runtime, args.num_jobs, args.verify)
+2 −2
Original line number Diff line number Diff line
@@ -14,8 +14,8 @@ function node_login_fio_logout() {
		iscsiadm -m node -p $TARGET_IP:$ISCSI_PORT -o update -n node.conn[0].iscsi.$arg
	done
	iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
	$fio_py iscsi 512 1 write 2 1
	$fio_py iscsi 512 1 read 2 1
	$fio_py -p iscsi -i 512 -d 1 -t write -r 2
	$fio_py -p iscsi -i 512 -d 1 -t read -r 2
	iscsiadm -m node --logout -p $TARGET_IP:$ISCSI_PORT
	sleep 1
}
+6 −6
Original line number Diff line number Diff line
@@ -40,7 +40,7 @@ function running_config() {
	timing_exit start_iscsi_tgt2

	sleep 1
	$fio_py iscsi 4096 1 randrw 5 1
	$fio_py -p iscsi -i 4096 -d 1 -t randrw -r 5
}

if [ -z "$TARGET_IP" ]; then
@@ -95,12 +95,12 @@ iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT

trap "iscsicleanup; killprocess $pid; iscsitestfini $1 $2; delete_tmp_files; exit 1" SIGINT SIGTERM EXIT

$fio_py iscsi 4096 1 randrw 1 1 verify
$fio_py iscsi 131072 32 randrw 1 1 verify
$fio_py iscsi 524288 128 randrw 1 1 verify
$fio_py -p iscsi -i 4096 -d 1 -t randrw -r 1 -v
$fio_py -p iscsi -i 131072 -d 32 -t randrw -r 1 -v
$fio_py -p iscsi -i 524288 -d 128 -t randrw -r 1 -v

if [ $RUN_NIGHTLY -eq 1 ]; then
	$fio_py iscsi 4096 1 write 300 1 verify
	$fio_py -p iscsi -i 4096 -d 1 -t write -r 300 -v

	# Run the running_config test which will generate a config file from the
	#  running iSCSI target, then kill and restart the iSCSI target using the
@@ -110,7 +110,7 @@ if [ $RUN_NIGHTLY -eq 1 ]; then
fi

# Start hotplug test case.
$fio_py iscsi 1048576 128 rw 10 1 &
$fio_py -p iscsi -i 1048576 -d 128 -t rw -r 10 &
fio_pid=$!

sleep 3
+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ sleep 1
iscsiadm -m node --login -p $MIGRATION_ADDRESS:$ISCSI_PORT

# fio tests for multi-process
$fio_py iscsi 4096 32 randrw 10 1 &
$fio_py -p iscsi -i 4096 -d 32 -t randrw -r 10 &
fiopid=$!
sleep 5

+1 −1
Original line number Diff line number Diff line
@@ -74,7 +74,7 @@ iscsiadm -m node --login -p $TARGET_IP:$ISCSI_PORT
timing_exit discovery

timing_enter fio
$fio_py iscsi 131072 8 randwrite 10 1 verify
$fio_py -p iscsi -i 131072 -d 8 -t randwrite -r 10 -v
timing_exit fio

rm -f ./local-job0-0-verify.state
Loading