@@ -51,6 +51,7 @@ runtime=""
5151ramptime=" "
5252iodepth=" "
5353ioengine=" "
54+ pre_iteration_script=" "
5455job_mode=" concurrent" # serial or concurrent
5556file_size=" "
5657direct=" " # don't cache IO's by default
@@ -121,6 +122,9 @@ function fio_usage() {
121122 printf " \t\tnumber of jobs to run, if not given then fio default of numjobs=1 will be used\n"
122123 printf -- " \t--job-file=<path>\n"
123124 printf " \t\tprovide the path of a fio job config file, (default is $job_file )\n"
125+ printf -- " \t--pre-iteration-script=str\n"
126+ printf -- " \t\tuse executable script/program to prepare the system for test iteration\n"
127+ printf -- " \t\texample: --pre-iteration-script=\$ HOME/drop-cache.sh\n"
124128 printf -- " \t--samples=<int>\n"
125129 printf " \t\tnumber of samples to use per test iteration (default is $nr_samples )\n"
126130 printf -- " \t--max-stddev=<int>\n"
@@ -133,7 +137,7 @@ function fio_usage() {
133137}
134138
135139function fio_process_options() {
136- opts=$( getopt -q -o jic:t:b:s:d:r: --longoptions " help,max-stddev:,max-failures:,samples:,direct:,sync:,install,clients:,client-file:,iodepth:,ioengine:,config:,jobs-per-dev:,job-mode:,rate-iops:,ramptime:,runtime:,test-types:,block-sizes:,file-size:,targets:,tool-group:,postprocess-only:,run-dir:,directory:,numjobs:,job-file:" -n " getopt.sh" -- " $@ " ) ;
140+ opts=$( getopt -q -o jic:t:b:s:d:r: --longoptions " help,max-stddev:,max-failures:,samples:,direct:,sync:,install,clients:,client-file:,iodepth:,ioengine:,config:,jobs-per-dev:,job-mode:,rate-iops:,ramptime:,runtime:,test-types:,block-sizes:,file-size:,targets:,tool-group:,postprocess-only:,run-dir:,directory:,numjobs:,job-file:,pre-iteration-script:, " -n " getopt.sh" -- " $@ " ) ;
137141 if [ $? -ne 0 ]; then
138142 printf " \t${benchmark} : you specified an invalid option\n\n"
139143 fio_usage
@@ -330,6 +334,18 @@ function fio_process_options() {
330334 if [ -n " $1 " ]; then
331335 job_file=" $1 "
332336 shift ;
337+
338+ fi
339+ ;;
340+ --pre-iteration-script)
341+ shift ;
342+ if [ -n " $1 " ]; then
343+ pre_iteration_script=" $1 "
344+ if [ ! -x $pre_iteration_script ]; then
345+ printf " ERROR: $pre_iteration_script must be executable\n"
346+ exit 1
347+ fi
348+ shift ;
333349 fi
334350 ;;
335351 --)
@@ -513,6 +529,16 @@ function fio_run_job() {
513529 else
514530 mkdir -p $benchmark_results_dir /clients/localhost
515531 fi
532+
533+ # certain test preparation steps such as cache dropping
534+ # can be a bit hard on the system, give it a few
535+ # seconds before actually starting test
536+ # by putting this before pbench-start-tools,
537+
538+ if [ -n " $pre_iteration_script " ] ; then
539+ printf " running pre-iteration-script command: $pre_iteration_script \n"
540+ eval " $pre_iteration_script "
541+ fi
516542 pbench-start-tools --group=$tool_group --iteration=$iteration --dir=$benchmark_results_dir
517543 local client_opts=" "
518544
0 commit comments