hw-test/scripts/test-fio

133 lines
3.3 KiB
Bash
Executable file

#!/bin/bash
if [[ -z $OUTPUT_DIR ]] ; then
source scan-dmidecode
fi
source test-variables
SUMMARY=0
#if [[ "$1" == "summary" ]] ; then
# SUMMARY=plain
#elif [[ "$1" == "csv" ]] ; then
# SUMMARY=csv
#else
# if [[ -f $OUTPUT_DIR/disk.lst ]] ; then
# mv -vf $OUTPUT_DIR/disk.lst $OUTPUT_DIR/disk.$MY_DATETIME
# fi
#fi
scan-hdd # Always rescan
#if [[ "$1" == "force" ]] ; then
rm -f $OUTPUT_DIR/disk/*.fio.result
#fi
MAXWAIT=9
JOBS=0
if [[ $SUMMARY == 0 ]] ; then
echo -n "BEGIN: " >> $OUTPUT_DIR/fio.log
date >> $OUTPUT_DIR/fio.log
for DISK in `cat $OUTPUT_DIR/disk.lst \
| sed 's/#.*$//' \
| cut -d ':' -f 1`
do
SERIAL=`cat $OUTPUT_DIR/disk.lst \
| grep $DISK \
| cut -d ':' -f 2`
if [[ -f $OUTPUT_DIR/disk/$SERIAL.fio.result ]] ; then
cat $OUTPUT_DIR/disk/$SERIAL.fio.result \
| sed 's/Process [0-9]\+/Test already done/'
cat $OUTPUT_DIR/disk/$SERIAL.fio.result \
| sed 's/Process [0-9]\+/Result found/' \
>> $OUTPUT_DIR/fio.log
continue
fi
JOBS=$(( JOBS + 1 ))
echo -n "Process $JOBS: Testing disk $DISK with fio ..."
echo -n "Process $JOBS : Disk $DISK : " \
>> $OUTPUT_DIR/fio.log
COUNT=0
TEST_PID=
wrapper-fio $DISK $SERIAL $JOBS &
sleep 1
RET=`jobs %+ | awk '/Exit [0-9]+/ {print $3}'`
if [[ -n $RET ]] ; then
echo -n "Exit $RET "
COUNT=$RET
fi
while (( $COUNT < $MAXWAIT )) ; do
COUNT=$(( COUNT + 1 ))
sleep 1
if [[ -f /run/$SERIAL.fio.pid ]] ; then
TEST_PID=`cat /run/$SERIAL.fio.pid`
echo " PID $TEST_PID"
echo " PID $TEST_PID" >> $OUTPUT_DIR/fio.log
break
fi
echo -n '.'
done
if [[ -z $TEST_PID ]] ; then
echo "${RED}Process not running.${OFF}"
echo "${RED}Process not running.${OFF}" \
>> $OUTPUT_DIR/fio.log
fi
done
fi
JOBS_WAITING=$JOBS
JOBS_OLD=0
COUNT=0
NOTICE_INTERVAL=60
while (( $JOBS_WAITING > 0 )) ; do
sleep 1
JOBS_WAITING=`jobs -r | wc -l`
JOBS_FINISHED=$(( JOBS - JOBS_WAITING ))
if (( $COUNT % $NOTICE_INTERVAL == 0 )) ; then
if [[ $JOBS_WAITING != $JOBS_OLD ]] ; then
echo "$JOBS_FINISHED jobs finished, $JOBS_WAITING jobs still running..."
JOBS_OLD=$JOBS_WAITING
fi
fi
COUNT=$(( COUNT + 1 ))
echo $JOBS_WAITING > /run/fio.waiting
done
rm -f /run/fio.waiting
echo -n "END: " >> $OUTPUT_DIR/fio.log
date >> $OUTPUT_DIR/fio.log
echo >> $OUTPUT_DIR/fio.log
#snapshot
mkdir -p $SNAPSHOT_D
cp -af $OUTPUT_DIR/* $SNAPSHOT_D/
if [[ $SUMMARY != 0 ]] ; then
if [[ $SUMMARY == plain ]] ; then
echo "=====> FIO SUMMARY <====="
fi
echo "SERVER|DISK|SERIAL|RESULT|COMMENT" > $OUTPUT_DIR/fio.csv
for DISK in `cat $OUTPUT_DIR/disk.lst \
| sed 's/#.*$//' \
| cut -d ':' -f 1`
do
SERIAL=`cat $OUTPUT_DIR/disk.lst \
| grep $DISK \
| cut -d ':' -f 2`
#echo "looking for $OUTPUT_DIR/disk/$SERIAL.fio.csv"
if [[ $SUMMARY == plain ]] ; then
if [[ -f $OUTPUT_DIR/disk/$SERIAL.fio.result ]] ; then
cat $OUTPUT_DIR/disk/$SERIAL.fio.result
fi
fi
if [[ -f $OUTPUT_DIR/disk/$SERIAL.fio.csv ]] ; then
cat $OUTPUT_DIR/disk/$SERIAL.fio.csv \
>> $OUTPUT_DIR/fio.csv
fi
done
fi
if [[ $SUMMARY == csv ]] ; then
echo "=====> BADBLOCKS CSV SUMMARY <====="
cat $OUTPUT_DIR/fio.csv \
| sed "s/^\([^|]\+\)/${BLD}\1${OFF}/ ; s/OK/$RES_OK/ ; s/FAIL/$RES_FAIL/ ; s/RESULT/$RES_ULT/ "
# | sed 's/empty/W87152YGWGM/g' # Serial number for debugging
fi