#!/bin/bash
SCRIPT_PATH=`pwd`
TEST_PATH=$1
cd $TEST_PATH


${SCRIPT_PATH}/fio -ioengine=psync -bs=32k -fdatasync=1 -thread -rw=randread -size=10G -filename=fio_randread_test.txt -name='fio randread test' -iodepth=4 -runtime=60 -numjobs=4 -group_reporting --output-format=json --output=fio_randread_result.json > /dev/null
echo "randread iops (>40000):"
python ${SCRIPT_PATH}/parse_fio_output.py --target="fio_randread_result.json" --read-iops

${SCRIPT_PATH}/fio -ioengine=psync -bs=32k -fdatasync=1 -thread -rw=randrw -percentage_random=100,0 -size=10G -filename=fio_randread_write_test.txt -name='fio mixed randread and sequential write test' -iodepth=4 -runtime=60 -numjobs=4 -group_reporting --output-format=json --output=fio_randread_write_test.json > /dev/null
echo "randread and write riops (>10000):"
python ${SCRIPT_PATH}/parse_fio_output.py --target='fio_randread_write_test.json' --read-iops
echo "randread and write wiops (>10000):"
python ${SCRIPT_PATH}/parse_fio_output.py --target='fio_randread_write_test.json' --write-iops

${SCRIPT_PATH}/fio -ioengine=psync -bs=32k -fdatasync=1 -thread -rw=randrw -percentage_random=100,0 -size=10G -filename=fio_randread_write_latency_test.txt -name='fio mixed randread and sequential write test' -iodepth=1 -runtime=60 -numjobs=1 -group_reporting --output-format=json --output=fio_randread_write_latency_test.json > /dev/null
echo "randread and write rlat (<250000ns):"
python ${SCRIPT_PATH}/parse_fio_output.py --target='fio_randread_write_latency_test.json' --read-lat
echo "randread and write wlat (<30000ns):"
python ${SCRIPT_PATH}/parse_fio_output.py --target='fio_randread_write_latency_test.json' --write-lat

${SCRIPT_PATH}/fio -direct=0 -fdatasync=1 -iodepth=4 -thread=4 -rw=write -ioengine=libaio -bs=4k -filename=./fio_fsync_test.txt -size=20G -runtime=120 -group_reporting -name='fio_fsync_test' --output-format=json --output=fio_fsync_test.json > /dev/null
echo "fio_fsync write iops (>10000):"
python ${SCRIPT_PATH}/parse_fio_output.py --target='fio_fsync_test.json' --write-iops


