[TD-13894]<fix>: test-all script for 3.0 (#10623)

This commit is contained in:
Shuduo Sang 2022-03-08 14:37:37 +08:00 committed by GitHub
parent bf0e4b7828
commit c3119245fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 68 additions and 61 deletions

View File

@ -1,5 +1,7 @@
#!/bin/bash #!/bin/bash
# set -x
# Color setting # Color setting
RED='\033[0;31m' RED='\033[0;31m'
GREEN='\033[1;32m' GREEN='\033[1;32m'
@ -12,19 +14,19 @@ tests_dir=`pwd`
IN_TDINTERNAL="community" IN_TDINTERNAL="community"
function stopTaosd { function stopTaosd {
echo "Stop taosd" echo "Stop taosd"
sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail' sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail'
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
while [ -n "$PID" ] while [ -n "$PID" ]
do do
pkill -TERM -x taosd pkill -TERM -x taosd
sleep 1 sleep 1
PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'` PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
done done
} }
function dohavecore(){ function dohavecore(){
corefile=`find $corepath -mmin 1` [ -d $corepath ] && corefile=`find $corepath -mmin 1` || return 1
if [ -n "$corefile" ];then if [ -n "$corefile" ];then
core_file=`echo $corefile|cut -d " " -f2` core_file=`echo $corefile|cut -d " " -f2`
proc=`file $core_file|awk -F "execfn:" '/execfn:/{print $2}'|tr -d \' |awk '{print $1}'|tr -d \,` proc=`file $core_file|awk -F "execfn:" '/execfn:/{print $2}'|tr -d \' |awk '{print $1}'|tr -d \,`
@ -56,20 +58,20 @@ function dohavecore(){
function runSimCaseOneByOne { function runSimCaseOneByOne {
while read -r line; do while read -r line; do
if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then
case=`echo $line | grep sim$ |awk '{print $NF}'` case=`echo $line | grep sim$ |awk '{print $NF}'`
start_time=`date +%s` start_time=`date +%s`
date +%F\ %T | tee -a out.log date +%F\ %T | tee -a out.log
if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
echo -n $case echo -n $case
./test.sh -f $case > /dev/null 2>&1 && \ ./test.sh -f $case > /dev/null 2>&1 \
( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ && ([ -f ../../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log ) \
( grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ || ( grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \
echo -e "${RED} failed${NC}" | tee -a out.log echo -e "${RED} failed${NC}" | tee -a out.log
else else
echo -n $case echo -n $case
./test.sh -f $case > /dev/null 2>&1 && \ ./test.sh -f $case > /dev/null 2>&1 && \
( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ ([ -f ../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
( grep -q 'script.*success.*m$' ../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ ([ -f ../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*success.*m$' ../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \
echo -e "${RED} failed${NC}" | tee -a out.log echo -e "${RED} failed${NC}" | tee -a out.log
fi fi
out_log=`tail -1 out.log ` out_log=`tail -1 out.log `
@ -89,22 +91,22 @@ function runSimCaseOneByOnefq {
for ((i=$start;i<=$end;i++)) ; do for ((i=$start;i<=$end;i++)) ; do
line=`sed -n "$i"p jenkins/basic.txt` line=`sed -n "$i"p jenkins/basic.txt`
if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then
case=`echo $line | grep sim$ |awk '{print $NF}'` case=`echo $line | grep sim$ |awk '{print $NF}'`
start_time=`date +%s` start_time=`date +%s`
date +%F\ %T | tee -a out.log date +%F\ %T | tee -a out.log
if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
echo -n $case echo -n $case
./test.sh -f $case > case.log 2>&1 && \ ./test.sh -f $case > case.log 2>&1 \
( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ && \
( grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ ([ -f ../../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
([ -f ../../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \
( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && cat case.log ) ( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && cat case.log )
else else
pwd
echo -n $case echo -n $case
./test.sh -f $case > ../../sim/case.log 2>&1 && \ ./test.sh -f $case > ../../sim/case.log 2>&1 && \
( grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \ ([ -f ../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*'$case'.*failed.*, err.*lineNum' ../../sim/tsim/log/taoslog0.0 && echo -e "${RED} failed${NC}" | tee -a out.log || echo -e "${GREEN} success${NC}" | tee -a out.log )|| \
( grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \ ([ -f ../../sim/tsim/log/taoslog0.0 ] && grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log ) || \
( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && pwd && cat ../../sim/case.log ) ( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && pwd && cat ../../sim/case.log )
fi fi
@ -134,7 +136,6 @@ function runPyCaseOneByOne {
while read -r line; do while read -r line; do
if [[ $line =~ ^python.* ]]; then if [[ $line =~ ^python.* ]]; then
if [[ $line != *sleep* ]]; then if [[ $line != *sleep* ]]; then
if [[ $line =~ '-r' ]];then if [[ $line =~ '-r' ]];then
case=`echo $line|awk '{print $4}'` case=`echo $line|awk '{print $4}'`
else else
@ -172,7 +173,6 @@ function runPyCaseOneByOnefq() {
line=`sed -n "$i"p fulltest.sh` line=`sed -n "$i"p fulltest.sh`
if [[ $line =~ ^python.* ]]; then if [[ $line =~ ^python.* ]]; then
if [[ $line != *sleep* ]]; then if [[ $line != *sleep* ]]; then
if [[ $line =~ '-r' ]];then if [[ $line =~ '-r' ]];then
case=`echo $line|awk '{print $4}'` case=`echo $line|awk '{print $4}'`
else else
@ -239,7 +239,9 @@ totalExampleFailed=0
if [ "${OS}" == "Linux" ]; then if [ "${OS}" == "Linux" ]; then
corepath=`grep -oP '.*(?=core_)' /proc/sys/kernel/core_pattern||grep -oP '.*(?=core-)' /proc/sys/kernel/core_pattern` corepath=`grep -oP '.*(?=core_)' /proc/sys/kernel/core_pattern||grep -oP '.*(?=core-)' /proc/sys/kernel/core_pattern`
if [ -z "$corepath" ];then if [ -z "$corepath" ];then
echo "/coredump/core_%e_%p_%t" > /proc/sys/kernel/core_pattern || echo "Permission denied" [ -d /coredump ] || mkdir /coredump || echo -e "failed to mdkir /coredump"
[ -d /coredump ] \
&& echo "/coredump/core_%e_%p_%t" > /proc/sys/kernel/core_pattern || echo "Permission denied"
corepath="/coredump/" corepath="/coredump/"
fi fi
fi fi
@ -248,6 +250,7 @@ if [ "$2" != "jdbc" ] && [ "$2" != "python" ] && [ "$2" != "unit" ] && [ "$2" !
echo "### run TSIM test case ###" echo "### run TSIM test case ###"
cd $tests_dir/script cd $tests_dir/script
[ -d ../../sim ] || mkdir ../../sim || echo -e "failed to mkdir ../../sim"
[ -f out.log ] && rm -f out.log [ -f out.log ] && rm -f out.log
if [ "$1" == "cron" ]; then if [ "$1" == "cron" ]; then
echo "### run TSIM regression test ###" echo "### run TSIM regression test ###"
@ -368,16 +371,20 @@ if [ "$2" != "sim" ] && [ "$2" != "jdbc" ] && [ "$2" != "unit" ] && [ "$2" != "
echo "### run Python smoke test ###" echo "### run Python smoke test ###"
runPyCaseOneByOne smoketest.sh runPyCaseOneByOne smoketest.sh
fi fi
totalPySuccess=`grep 'success' pytest-out.log | wc -l`
if [ "$totalPySuccess" -gt "0" ]; then if [ -f pytest-out.log ]; then
echo -e "\n${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" totalPySuccess=`grep 'success' pytest-out.log | wc -l`
fi if [ "$totalPySuccess" -gt "0" ]; then
echo -e "\n${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}"
fi
totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l` totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l`
if [ "$totalPyFailed" -ne "0" ]; then if [ "$totalPyFailed" -ne "0" ]; then
echo -e "\n${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}" echo -e "\n${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}"
# exit $totalPyFailed # exit $totalPyFailed
fi
else
echo -e "pytest-out.log not found!"
fi fi
fi fi