perftest-taosdemo.sh 4.1 KB
Newer Older
S
Shuduo Sang 已提交
1 2
#!/bin/bash

S
Shuduo Sang 已提交
3
WORK_DIR=/mnt/root
4
TDENGINE_DIR=/root/TDengine
S
Shuduo Sang 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18

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}'`

19 20 21
[ -z "$logDir" ] && logDir="/var/log/taos"
[ -z "$dataDir" ] && dataDir="/var/lib/taos"

S
Shuduo Sang 已提交
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
# 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; }
S
Shuduo Sang 已提交
37 38

function restartTaosd {
S
Shuduo Sang 已提交
39
        echo "Stop taosd"
S
Shuduo Sang 已提交
40
	systemctl stop taosd
S
Shuduo Sang 已提交
41 42 43 44 45 46 47 48 49 50
	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 已提交
51
	
S
Shuduo Sang 已提交
52
        echo "Start taosd"
S
Shuduo Sang 已提交
53 54 55 56 57 58 59 60
	taosd 2>&1 > /dev/null &
	sleep 10
}

function runCreateTableOnly {
	echoInfo "Restart Taosd"
	restartTaosd

S
Shuduo Sang 已提交
61
	/usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo -n 0 2>&1 | tee taosdemo-$walPostfix-$today.log"
S
Shuduo Sang 已提交
62 63 64 65 66 67 68
	demoCreateTableOnly=`grep "Total:" totaltime.out|awk '{print $2}'`
}

function runDeleteTableOnly {
	echoInfo "Restart Taosd"
	restartTaosd

S
Shuduo Sang 已提交
69
	/usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo -t 0 -D 1 2>&1 | tee taosdemo-$walPostfix-$today.log"
S
Shuduo Sang 已提交
70
	demoDeleteTableOnly=`grep "Total:" totaltime.out|awk '{print $2}'`
S
Shuduo Sang 已提交
71 72 73 74 75 76
}

function runCreateTableThenInsert {
	echoInfo "Restart Taosd"
	restartTaosd

S
Shuduo Sang 已提交
77
	/usr/bin/time -f "Total: %e" -o totaltime.out bash -c "yes | taosdemo 2>&1 | tee -a taosdemo-$walPostfix-$today.log"
78 79 80 81 82 83 84 85 86 87 88
	demoTableAndInsert=`grep "Total:" totaltime.out|awk '{print $2}'`	
	demoRPS=`grep "records\/second" taosdemo-$walPostfix-$today.log | tail -n1 | awk '{print $13}'`	
}

function queryPerformance {
	echoInfo "Restart Taosd"
	restartTaosd
	
	cd $TDENGINE_DIR/tests/pytest
	python3 query/queryPerformance.py
}
S
Shuduo Sang 已提交
89 90

function generateTaosdemoPlot {
S
Shuduo Sang 已提交
91 92 93
	echo "${today} $walPostfix, demoCreateTableOnly: ${demoCreateTableOnly}, demoDeleteTableOnly: ${demoDeleteTableOnly}, demoTableAndInsert: ${demoTableAndInsert}" | tee -a taosdemo-$today.log
	echo "${today}, ${demoCreateTableOnly}, ${demoDeleteTableOnly}, ${demoTableAndInsert}">> taosdemo-$walPostfix-report.csv
	echo "${today}, ${demoRPS}" >> taosdemo-rps-$walPostfix-report.csv
S
Shuduo Sang 已提交
94
	
S
Shuduo Sang 已提交
95
	csvLines=`cat taosdemo-$walPostfix-report.csv | wc -l`
S
Shuduo Sang 已提交
96 97

	if [ "$csvLines" -gt "10" ]; then
S
Shuduo Sang 已提交
98
		sed -i '1d' taosdemo-$walPostfix-report.csv
S
Shuduo Sang 已提交
99 100
	fi

S
Shuduo Sang 已提交
101
	csvLines=`cat taosdemo-rps-$walPostfix-report.csv | wc -l`
S
Shuduo Sang 已提交
102 103

	if [ "$csvLines" -gt "10" ]; then
S
Shuduo Sang 已提交
104
		sed -i '1d' taosdemo-rps-$walPostfix-report.csv
S
Shuduo Sang 已提交
105 106
	fi

S
Shuduo Sang 已提交
107 108
	gnuplot -e "filename='taosdemo-$walPostfix-report'" -p taosdemo-csv2png.gnuplot
	gnuplot -e "filename='taosdemo-rps-$walPostfix-report'" -p taosdemo-rps-csv2png.gnuplot
S
Shuduo Sang 已提交
109 110 111 112
}

today=`date +"%Y%m%d"`

S
Shuduo Sang 已提交
113
cd $WORK_DIR
S
Shuduo Sang 已提交
114
echoInfo "Test Create Table Only "
S
Shuduo Sang 已提交
115
runCreateTableOnly
116
echoInfo "Test Delete Table Only"
S
Shuduo Sang 已提交
117
runDeleteTableOnly
S
Shuduo Sang 已提交
118
echoInfo "Test Create Table then Insert data"
S
Shuduo Sang 已提交
119
runCreateTableThenInsert
120 121
echoInfo "Query Performance for 10 Billion Records"
queryPerformance
S
Shuduo Sang 已提交
122
echoInfo "Generate plot for taosdemo"
S
Shuduo Sang 已提交
123 124
generateTaosdemoPlot

125

S
Shuduo Sang 已提交
126 127 128
tar czf $WORK_DIR/taos-log-taosdemo-$today.tar.gz $logDir/*

echoInfo "End of TaosDemo Test" | tee -a $WORK_DIR/cron.log