perftest-tsdb-compare-1d.sh 3.3 KB
Newer Older
S
Shuduo Sang 已提交
1 2
#!/bin/bash

S
Shuduo Sang 已提交
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
WORK_DIR=/mnt/root
TSDB_CMP_DIR=timeseriesdatabase-comparisons/build/tsdbcompare

walLevel=`grep "^walLevel" /etc/taos/taos.cfg | awk '{print $2}'`
if [[ "$walLevel" -eq "2" ]]; then
	walPostfix="wal2"
elif [[ "$walLevel" -eq "1" ]]; then
	walPostfix="wal1"
else
	echo -e "${RED}wrong walLevel $walLevel found! ${NC}"
	exit 1
fi

logDir=`grep "^logDir" /etc/taos/taos.cfg | awk '{print $2}'`
dataDir=`grep "^dataDir" /etc/taos/taos.cfg | awk '{print $2}'`

S
Shuduo Sang 已提交
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
# Coloured Echoes                                                                                                       #
function red_echo      { echo -e "\033[31m$@\033[0m";   }                                                               #
function green_echo    { echo -e "\033[32m$@\033[0m";   }                                                               #
function yellow_echo   { echo -e "\033[33m$@\033[0m";   }                                                               #
function white_echo    { echo -e "\033[1;37m$@\033[0m"; }                                                               #
# Coloured Printfs                                                                                                      #
function red_printf    { printf "\033[31m$@\033[0m";    }                                                               #
function green_printf  { printf "\033[32m$@\033[0m";    }                                                               #
function yellow_printf { printf "\033[33m$@\033[0m";    }                                                               #
function white_printf  { printf "\033[1;37m$@\033[0m";  }                                                               #
# Debugging Outputs                                                                                                     #
function white_brackets { local args="$@"; white_printf "["; printf "${args}"; white_printf "]"; }                      #
function echoInfo   { local args="$@"; white_brackets $(green_printf "INFO") && echo " ${args}"; }                      #
function echoWarn   { local args="$@";  echo "$(white_brackets "$(yellow_printf "WARN")" && echo " ${args}";)" 1>&2; }  #
function echoError  { local args="$@"; echo "$(white_brackets "$(red_printf    "ERROR")" && echo " ${args}";)" 1>&2; }  #

function restartTaosd {
S
Shuduo Sang 已提交
36
        echo "Stop taosd"
S
Shuduo Sang 已提交
37
	systemctl stop taosd
S
Shuduo Sang 已提交
38 39 40 41 42 43 44 45 46 47
	PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
	while [ -n "$PID" ]
	do
		pkill -TERM -x taosd
		sleep 1
		PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
	done

	rm -rf $logDir/*
	rm -rf $dataDir/*
S
Shuduo Sang 已提交
48
	
S
Shuduo Sang 已提交
49
        echo "Start taosd"
S
Shuduo Sang 已提交
50 51 52 53 54 55 56 57
	taosd 2>&1 > /dev/null &
	sleep 10
}

function runPerfTest1d {
	echoInfo "Restart Taosd"
	restartTaosd

S
Shuduo Sang 已提交
58 59
	cd $WORK_DIR/$TSDB_CMP_DIR
	./runTDengine.sh -d 1 -w -q 2>&1 | tee $WORK_DIR/perftest-1d-$walPostfix-$today.log
S
Shuduo Sang 已提交
60 61 62
}

function generatePerfPlot1d {
S
Shuduo Sang 已提交
63
	cd $WORK_DIR
S
Shuduo Sang 已提交
64

S
Shuduo Sang 已提交
65
	csvLines=`cat perftest-1d-$walPostfix-report.csv | wc -l`
S
Shuduo Sang 已提交
66 67

	if [ "$csvLines" -gt "10" ]; then
S
Shuduo Sang 已提交
68
		sed -i '1d' perftest-1d-$walPostfix-report.csv
S
Shuduo Sang 已提交
69 70
	fi

S
Shuduo Sang 已提交
71
	gnuplot -e "filename='perftest-1d-$walPostfix-report'" -p perftest-csv2png.gnuplot
S
Shuduo Sang 已提交
72 73 74
}

today=`date +"%Y%m%d"`
S
Shuduo Sang 已提交
75
cd $WORK_DIR
S
Shuduo Sang 已提交
76 77

echoInfo "run Performance Test with 1 day data"
S
Shuduo Sang 已提交
78
runPerfTest1d
S
Shuduo Sang 已提交
79
echoInfo "Generate plot of 1 day data"
S
Shuduo Sang 已提交
80 81 82 83 84
generatePerfPlot1d

tar czf $WORK_DIR/taos-log-1d-$today.tar.gz $logDir/*

echoInfo "End of TSDB-Compare 1-day-data Test" | tee -a $WORK_DIR/cron.log