sbc-performance-test-kit/bin/disk-test.sh

66 lines
3.8 KiB
Bash
Raw Normal View History

2021-01-10 23:40:11 +00:00
#!/bin/bash
if [[ $# -lt 3 ]] ; then
echo "\\o/"
echo "Not enough arguments supplied" >&2
echo "You need to pass a log file name to store the test results, the disk space to use and the number of files to use " >&2
echo " |" >&2
echo "syntax: " >&2
echo " $(basename $0) <log file name> <test disk space> <test file num>" >&2
echo "example: " >&2
echo " $(basename $0) test.log 64G 512 " >&2
echo "/!\\" >&2
exit 1
fi
LOGFILE=$1
TEST_DISK_SPACE=$2
TEST_FILE_NUM=$3
#FILE_IO_MODE=async
FILE_IO_MODE=sync
THREADS=8
2021-01-12 12:16:59 +00:00
BLOCK_SIZE_1=4096
BLOCK_SIZE_2=1048576
BLOCK_SIZE_1_TXT="4 kiB"
BLOCK_SIZE_2_TXT="1 MiB"
2021-01-10 23:40:11 +00:00
echo ' '
echo "#### Disk test ####" | tee -a $LOGFILE
BLOCK_DEVICES=$(lsblk | grep -v loop | grep disk | cut -f1 -d ' ')
for d in $BLOCK_DEVICES
do
echo "# block device /dev/$d => hdparm -tT #" | tee -a $LOGFILE
sudo hdparm -tT /dev/$d 2>&1 | tee -a $LOGFILE
sudo hdparm -tT /dev/$d 2>&1 | tee -a $LOGFILE
sudo hdparm -tT /dev/$d 2>&1 | tee -a $LOGFILE
done
/usr/local/bin/sysbench fileio prepare --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
2021-01-12 16:16:40 +00:00
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches" 2>&1 | tee -a $LOGFILE
2021-01-12 12:16:59 +00:00
echo "# sysbench $BLOCK_SIZE_1_TXT random read/write test #" | tee -a $LOGFILE
/usr/local/bin/sysbench fileio run --threads=$THREADS --file-test-mode=rndrw --file-block-size=$BLOCK_SIZE_1 --file-io-mode=$FILE_IO_MODE --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE --file-rw-ratio=2 2>&1 | tee -a $LOGFILE
2021-01-10 23:40:11 +00:00
/usr/local/bin/sysbench fileio prepare --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
2021-01-12 16:16:40 +00:00
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches" 2>&1 | tee -a $LOGFILE
2021-01-12 12:16:59 +00:00
echo "# sysbench $BLOCK_SIZE_2_TXT random read/write test #" | tee -a $LOGFILE
/usr/local/bin/sysbench fileio run --threads=$THREADS --file-test-mode=rndrw --file-block-size=$BLOCK_SIZE_2 --file-io-mode=$FILE_IO_MODE --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE --file-rw-ratio=2 2>&1 | tee -a $LOGFILE
/usr/local/bin/sysbench fileio prepare --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
2021-01-12 16:16:40 +00:00
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches" 2>&1 | tee -a $LOGFILE
2021-01-12 12:16:59 +00:00
echo "# sysbench $BLOCK_SIZE_1_TXT sequential read test #" | tee -a $LOGFILE
/usr/local/bin/sysbench fileio run --threads=$THREADS --file-test-mode=seqrd --file-block-size=$BLOCK_SIZE_1 --file-io-mode=$FILE_IO_MODE --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
/usr/local/bin/sysbench fileio prepare --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
2021-01-12 16:16:40 +00:00
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches" 2>&1 | tee -a $LOGFILE
2021-01-12 12:16:59 +00:00
echo "# sysbench $BLOCK_SIZE_2_TXT sequential read test #" | tee -a $LOGFILE
/usr/local/bin/sysbench fileio run --threads=$THREADS --file-test-mode=seqrd --file-block-size=$BLOCK_SIZE_2 --file-io-mode=$FILE_IO_MODE --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
2021-01-12 16:16:40 +00:00
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches" 2>&1 | tee -a $LOGFILE
2021-01-12 12:16:59 +00:00
echo "# sysbench $BLOCK_SIZE_1_TXT sequential write test #" | tee -a $LOGFILE
2021-01-12 16:37:36 +00:00
/usr/local/bin/sysbench fileio run --threads=$THREADS --file-test-mode=seqwr --file-block-size=$BLOCK_SIZE_1 --file-io-mode=$FILE_IO_MODE --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
2021-01-12 16:16:40 +00:00
sudo sh -c "echo 1 > /proc/sys/vm/drop_caches" 2>&1 | tee -a $LOGFILE
2021-01-12 12:16:59 +00:00
echo "# sysbench $BLOCK_SIZE_2_TXT sequential write test #" | tee -a $LOGFILE
2021-01-12 16:37:36 +00:00
/usr/local/bin/sysbench fileio run --threads=$THREADS --file-test-mode=seqwr --file-block-size=$BLOCK_SIZE_2 --file-io-mode=$FILE_IO_MODE --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE
2021-01-12 12:16:59 +00:00
2021-01-10 23:40:11 +00:00
/usr/local/bin/sysbench fileio cleanup --file-num=$TEST_FILE_NUM --file-total-size=$TEST_DISK_SPACE 2>&1 | tee -a $LOGFILE