From 4b859262823e048ed36988d6734b2d372130e27d Mon Sep 17 00:00:00 2001
From: Fulvio Galeazzi <fulvio.galeazzi@garr.it>
Date: Mon, 15 Nov 2021 13:51:22 +0100
Subject: [PATCH] 2021-11-15:  FG;  Better management for disk-based tests via
 environment variables.

---
 doFioLoop.sh | 85 ++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 69 insertions(+), 16 deletions(-)

diff --git a/doFioLoop.sh b/doFioLoop.sh
index 1cb9387..2d52d83 100755
--- a/doFioLoop.sh
+++ b/doFioLoop.sh
@@ -1,40 +1,93 @@
-# export PARTITION=/srv/node/test/fio/
-export IOENGINE=rbd
-export theTime=15
+export runTimeDefault=120
 export thePause=10
-for partition in /mnt/rbdTestSsd /mnt/rbdTestBackup /mnt/rbdTestCinder /mnt/rbdTestCinderFast /mnt/rbdTestVolFG /mnt/rbdTestGlance  ; do
+export theSmlPause=3
+export subDir=$1
+
+display_usage() { 
+    echo "Usage: "
+    echo "    export LISTDEVICES='list of devices to check' "
+    echo "    export IOENGINE=libaio|rbd 
+    echo "    export runTime=NNN # this is optional"
+    echo "    $0 <log_dir>"
+} 
+
+###
+
+# check whether user had supplied -h or --help . If yes display usage 
+if [[ ( $# == "--help") ||  $# == "-h" ]] 
+then 
+    display_usage
+    exit 0
+fi 
+if [ ! -d $PWD/$subDir ]; then
+    echo "SubDirectory $subDir does not exist."
+    display_usage
+    exit 1
+elif [ -z $subDir ]; then
+    echo "No log_dir specified."
+    display_usage
+    exit 2
+fi
+if [ -z "$LISTDEVICES" ]; then
+    echo "Missing list of devices to be checked?"
+    display_usage
+    exit 3
+fi
+if [ -z "$IOENGINE" ]; then
+    echo "Missing IOENGINE variable"
+    display_usage
+    exit 2
+fi
+echo "List of devices to check:"
+read -r -a listDevs <<<  $LISTDEVICES
+for i in "${listDevs[@]}" ; do
+    echo "  Part: $i"
+done
+if [ -z "$runTime" ]; then
+    export runTime=$runTimeDefault
+    echo "No runTime specified, assuming default"
+fi
+echo "RunTime set to $runTime"
+echo "Log will be written to: $subDir"
+echo "Sleep a little bit..." ; sleep $theSmlPause
+
+for partition in "${listDevs[@]}" ; do
 export PARTITION=${partition}
+export sanitizedPart=`echo $PARTITION | sed -e 's/\///g' -e 's/\s*//g'`    
 echo " "
-echo " Partition is: $PARTITION"
+echo " Partition is: $PARTITION  sanitized to $sanitizedPart"
 echo " "
-baseDirName=`basename $PARTITION`
-for iodepth in 1 ; do 
-# for iodepth in 1 2 4 8 ; do 
+for iodepth in 1 8 2 4 ; do 
     export IODEPTH=${iodepth}
     echo " "
     echo " IODEPTH now $IODEPTH"
     echo " "
-    for numjobs in 1 2 16 4 ; do
-#    for numjobs in 1 16 4 32 ; do
+    for numjobs in 1 16 2 4 ; do
 	export NUMJOBS=${numjobs}
 	echo "   "
 	echo "   NUMJOBS now $NUMJOBS"
 	echo "   "
-	for blocksize in 4k 4M 64k 1M ; do
-#	for blocksize in 4k 4M 128k ; do
+	for blocksize in 4k 4M 128k ; do
 	    export BLOCKSIZE=${blocksize}
 	    export SIZE=4G
 	    echo "     "
 	    echo "     BLOCKSIZE now $BLOCKSIZE"
 	    echo "     "
-	    for i in 3 4 5 ; do
+	    for i in 1 2 3 4 5 ; do
 		echo "FIO test ${i}: Io=${IODEPTH} Num=${NUMJOBS} bs=${BLOCKSIZE} size=${SIZE}"
 		sync ; sleep 2
-		echo "Executing: fio --time_based --runtime=${theTime} --output=${baseDirName}_i-${IODEPTH}_n-${NUMJOBS}_b-${BLOCKSIZE}_s-${SIZE}_j-${i}.log mix_fio_group_job${i}.txt"
-		fio --time_based --runtime=${theTime} --output=${baseDirName}_i-${IODEPTH}_n-${NUMJOBS}_b-${BLOCKSIZE}_s-${SIZE}_j-${i}.log mix_fio_group_job${i}.txt
-		sync ; echo "done ${baseDirName}_i-${IODEPTH}_n-${NUMJOBS}_b-${BLOCKSIZE}_s-${SIZE}_j-${i}.log" ; sleep $thePause
+		export fileSuff=${IOENGINE}_${sanitizedPart}_i-${IODEPTH}_n-${NUMJOBS}_b-${BLOCKSIZE}_s-${SIZE}_j-${i}
+		if [ ! -e ${subDir}/fio_${fileSuff}.log ]; then
+		    echo "Executing: fio --time_based --runtime=${runTime} --output=${subDir}/fio_.log mix_fio_group_job${i}.txt"
+		    fio --time_based --runtime=${runTime} --output=${subDir}/fio_${fileSuff}.log mix_fio_group_job${i}.txt
+		    sync ; echo "done ${subDir}/fio_${fileSuff}.log" ; sleep $thePause
+		else
+		    echo "SKIPPED, sleep $theSmlPause at `date`" ; sleep $theSmlPause
+		fi
 	    done
 	done
     done
 done
 done
+
+
-- 
GitLab