[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'
@ -24,7 +26,7 @@ function stopTaosd {
} }
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 \,`
@ -61,15 +63,15 @@ function runSimCaseOneByOne {
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 `
@ -95,16 +97,16 @@ function runSimCaseOneByOnefq {
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,8 +371,9 @@ 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 [ -f pytest-out.log ]; then
totalPySuccess=`grep 'success' pytest-out.log | wc -l`
if [ "$totalPySuccess" -gt "0" ]; then if [ "$totalPySuccess" -gt "0" ]; then
echo -e "\n${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" echo -e "\n${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}"
fi fi
@ -379,6 +383,9 @@ if [ "$2" != "sim" ] && [ "$2" != "jdbc" ] && [ "$2" != "unit" ] && [ "$2" != "
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 fi
else
echo -e "pytest-out.log not found!"
fi
fi fi