test-all.sh 17.6 KB
Newer Older
sangshuduo's avatar
sangshuduo 已提交
1 2
#!/bin/bash

3 4 5 6 7 8
# Color setting
RED='\033[0;31m'
GREEN='\033[1;32m'
GREEN_DARK='\033[0;32m'
GREEN_UNDERLINE='\033[4;32m'
NC='\033[0m'
L
liuyq-617 已提交
9

10 11 12
tests_dir=`pwd`
IN_TDINTERNAL="community"

P
Ping Xiao 已提交
13
function stopTaosd {
14
  echo "Stop taosd"
L
update  
liuyq-617 已提交
15
  sudo systemctl stop taosd || echo 'no sudo or systemctl or stop fail'
P
Ping Xiao 已提交
16
  PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
17 18
  while [ -n "$PID" ]
  do
P
Ping Xiao 已提交
19 20
    pkill -TERM -x taosd
    sleep 1
21 22
    PID=`ps -ef|grep -w taosd | grep -v grep | awk '{print $2}'`
  done
P
Ping Xiao 已提交
23 24
}

L
liuyq-617 已提交
25 26 27
function dohavecore(){
  corefile=`find $corepath -mmin 1`  
  if [ -n "$corefile" ];then
L
liuyq-617 已提交
28 29
    core_file=`echo $corefile|cut -d " " -f2`
    proc=`file $core_file|awk -F "execfn:"  '/execfn:/{print $2}'|tr -d \' |awk '{print $1}'|tr -d \,`
30
    echo 'taosd or taos has generated core'
L
fix  
liuyq-617 已提交
31
    rm case.log
L
liuyq-617 已提交
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
    if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]] && [[ $1 == 1 ]]; then
      cd ../../../
      tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz debug/build/bin/taosd debug/build/bin/tsim debug/build/lib/libtaos*so*
      if [[ $2 == 1 ]];then
        cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S"`
      else
        cd community
        cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" `
      fi
    else 
      cd ../../
      if [[ $1 == 1 ]];then 
        tar -zcPf $corepath'taos_'`date "+%Y_%m_%d_%H_%M_%S"`.tar.gz debug/build/bin/taosd debug/build/bin/tsim debug/build/lib/libtaos*so*
        cp -r sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" `
      fi
    fi
48
    if [[ $1 == 1 ]];then
49
      echo '\n'|gdb $proc $core_file -ex "bt 10" -ex quit
50 51
      exit 8
    fi
L
liuyq-617 已提交
52
  fi
53
}
L
liuyq-617 已提交
54

55 56
function runSimCaseOneByOne {
  while read -r line; do
P
Ping Xiao 已提交
57
    if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then
58
			case=`echo $line | grep sim$ |awk '{print $NF}'`    
P
Ping Xiao 已提交
59
      start_time=`date +%s`      
P
Ping Xiao 已提交
60
      date +%F\ %T | tee -a out.log
L
liuyq-617 已提交
61 62 63
      if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
        echo -n $case
        ./test.sh -f $case > /dev/null 2>&1 && \
L
liuyq-617 已提交
64
        ( 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 )|| \
L
liuyq-617 已提交
65 66 67 68 69
        ( 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
      else
        echo -n $case
        ./test.sh -f $case > /dev/null 2>&1 && \
L
liuyq-617 已提交
70
        ( 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 )|| \
L
liuyq-617 已提交
71 72 73
        ( 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
      fi
L
liuyq-617 已提交
74
      out_log=`tail -1 out.log  `
L
liuyq-617 已提交
75 76 77
      # if [[ $out_log =~ 'failed' ]];then
      #   exit 8
      # fi
S
Shuduo Sang 已提交
78 79
      end_time=`date +%s`
      echo execution time of $case was `expr $end_time - $start_time`s. | tee -a out.log
80 81 82
    fi
  done < $1
}
83

L
liuyq-617 已提交
84
function runSimCaseOneByOnefq {
L
liuyq-617 已提交
85 86 87 88 89

  start=`sed -n "/$1-start/=" jenkins/basic.txt`
  end=`sed -n "/$1-end/=" jenkins/basic.txt`  
  for ((i=$start;i<=$end;i++)) ; do
    line=`sed -n "$i"p jenkins/basic.txt`
L
liuyq-617 已提交
90 91 92
    if [[ $line =~ ^./test.sh* ]] || [[ $line =~ ^run* ]]; then
			case=`echo $line | grep sim$ |awk '{print $NF}'`

93
      start_time=`date +%s`    
P
Ping Xiao 已提交
94
      date +%F\ %T | tee -a out.log
95
      if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
L
liuyq-617 已提交
96
        echo -n $case
L
fix  
liuyq-617 已提交
97
        ./test.sh -f $case > case.log 2>&1 && \
L
liuyq-617 已提交
98
        ( 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 )|| \
L
liuyq-617 已提交
99
        ( grep -q 'script.*success.*m$' ../../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log )  || \
L
fix  
liuyq-617 已提交
100
        ( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' && cat case.log )
101
      else
L
liuyq-617 已提交
102
        echo -n $case
103
        ./test.sh -f $case > ../../sim/case.log 2>&1 && \
L
liuyq-617 已提交
104
        ( 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 )|| \
L
liuyq-617 已提交
105
        ( grep -q 'script.*success.*m$' ../../sim/tsim/log/taoslog0.0 && echo -e "${GREEN} success${NC}" | tee -a out.log )  || \
L
fix  
liuyq-617 已提交
106
        ( echo -e "${RED} failed${NC}" | tee -a out.log && echo '=====================log=====================' &&  cat case.log )
107 108
      fi
      
L
liuyq-617 已提交
109 110
      out_log=`tail -1 out.log  `
      if [[ $out_log =~ 'failed' ]];then
L
fix  
liuyq-617 已提交
111
        rm case.log
112
        if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
L
liuyq-617 已提交
113
          cp -r ../../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S"`
114
        else 
L
liuyq-617 已提交
115
          cp -r ../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" `
116
        fi
L
liuyq-617 已提交
117
        dohavecore $2 1
L
fix  
liuyq-617 已提交
118 119 120
        if [[ $2 == 1 ]];then
          exit 8
        fi
L
liuyq-617 已提交
121 122 123
      fi
      end_time=`date +%s`
      echo execution time of $case was `expr $end_time - $start_time`s. | tee -a out.log
L
liuyq-617 已提交
124
      dohavecore $2 1
L
liuyq-617 已提交
125
    fi
L
liuyq-617 已提交
126
  done 
127 128
  rm -rf ../../../sim/case.log
  rm -rf ../../sim/case.log
L
liuyq-617 已提交
129
}
130 131 132 133

function runPyCaseOneByOne {
  while read -r line; do
    if [[ $line =~ ^python.* ]]; then
134
      if [[ $line != *sleep* ]]; then
L
liuyq-617 已提交
135 136 137 138 139 140
        
        if [[ $line =~ '-r' ]];then
          case=`echo $line|awk '{print $4}'`
        else
          case=`echo $line|awk '{print $NF}'`
        fi
S
Shuduo Sang 已提交
141
        start_time=`date +%s`
P
Ping Xiao 已提交
142
        date +%F\ %T | tee -a pytest-out.log
L
liuyq-617 已提交
143
        echo -n $case
144
        $line > /dev/null 2>&1 && \
L
liuyq-617 已提交
145 146
          echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \
          echo -e "${RED} failed${NC}" | tee -a pytest-out.log
S
Shuduo Sang 已提交
147
        end_time=`date +%s`
L
liuyq-617 已提交
148
        out_log=`tail -1 pytest-out.log  `
L
liuyq-617 已提交
149 150 151
        # if [[ $out_log =~ 'failed' ]];then
        #   exit 8
        # fi
S
Shuduo Sang 已提交
152
        echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log
153 154 155
      else
        $line > /dev/null 2>&1
      fi
156 157 158
    fi
  done < $1
}
159

L
liuyq-617 已提交
160
function runPyCaseOneByOnefq() {
L
liuyq-617 已提交
161 162 163 164 165 166 167
  if [[ $3 =~ system ]] ; then
    cd $tests_dir/system-test
  elif [[ $3 =~ develop ]] ; then
    cd $tests_dir/develop-test
  else
    cd $tests_dir/pytest
  fi
L
liuyq-617 已提交
168 169 170 171 172 173 174 175 176
  if [[ $1 =~ full ]] ; then
    start=1
    end=`sed -n '$=' fulltest.sh`
  else
    start=`sed -n "/$1-start/=" fulltest.sh`
    end=`sed -n "/$1-end/=" fulltest.sh`
  fi
  for ((i=$start;i<=$end;i++)) ; do
    line=`sed -n "$i"p fulltest.sh`
L
liuyq-617 已提交
177 178 179 180 181 182 183 184 185
    if [[ $line =~ ^python.* ]]; then
      if [[ $line != *sleep* ]]; then
        
        if [[ $line =~ '-r' ]];then
          case=`echo $line|awk '{print $4}'`
        else
          case=`echo $line|awk '{print $NF}'`
        fi
        start_time=`date +%s`
P
Ping Xiao 已提交
186
        date +%F\ %T | tee -a pytest-out.log
L
liuyq-617 已提交
187
        echo -n $case
L
liuyq-617 已提交
188 189 190
        if [[ $1 =~ full ]] ; then
          line=$line" -s"
        fi
L
fix  
liuyq-617 已提交
191
        $line > case.log 2>&1 && \
L
liuyq-617 已提交
192
          echo -e "${GREEN} success${NC}" | tee -a pytest-out.log || \
193
          echo -e "${RED} failed${NC}" | tee -a pytest-out.log 
L
liuyq-617 已提交
194 195 196
        end_time=`date +%s`
        out_log=`tail -1 pytest-out.log  `
        if [[ $out_log =~ 'failed' ]];then
L
liuyq-617 已提交
197
          cp -r ../../sim ~/sim_`date "+%Y_%m_%d_%H:%M:%S" `
L
fix  
liuyq-617 已提交
198
          echo '=====================log===================== '
L
fix  
liuyq-617 已提交
199 200
          cat case.log
          rm -rf case.log
L
liuyq-617 已提交
201
          dohavecore $2 2
L
fix  
liuyq-617 已提交
202 203 204
          if [[ $2 == 1 ]];then
            exit 8
          fi
L
liuyq-617 已提交
205 206 207 208 209
        fi
        echo execution time of $case was `expr $end_time - $start_time`s. | tee -a pytest-out.log
      else
        $line > /dev/null 2>&1
      fi
L
liuyq-617 已提交
210
      dohavecore $2 2
L
liuyq-617 已提交
211
    fi
L
liuyq-617 已提交
212
  done 
213
  rm -rf ../../sim/case.log
L
liuyq-617 已提交
214
}
215

216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236
######################
# main entry
######################

unameOut="$(uname -s)"
case "${unameOut}" in
    Linux*)     OS=Linux;;
    Darwin*)    OS=Darwin;;
    CYGWIN*)    OS=Windows;;
    *)          OS=Unknown;;
esac

case "${OS}" in
    Linux*)     TAOSLIB=libtaos.so;;
    Darwin*)    TAOSLIB=libtaos.dylib;;
    Windows*)    TAOSLIB=taos.dll;;
    Unknown)          TAOSLIB="UNKNOWN:${unameOut}";;
esac

echo TAOSLIB is ${TAOSLIB}

237 238
totalFailed=0
totalPyFailed=0
239
totalJDBCFailed=0
P
Ping Xiao 已提交
240
totalUnitFailed=0
241
totalExampleFailed=0
J
jiacy-jcy 已提交
242
totalApiFailed=0
sangshuduo's avatar
sangshuduo 已提交
243

244 245
if [ "${OS}" == "Linux" ]; then
    corepath=`grep -oP '.*(?=core_)' /proc/sys/kernel/core_pattern||grep -oP '.*(?=core-)' /proc/sys/kernel/core_pattern`
L
liuyq-617 已提交
246 247 248 249
    if [ -z "$corepath" ];then
      echo "/coredump/core_%e_%p_%t" > /proc/sys/kernel/core_pattern || echo "Permission denied"
      corepath="/coredump/"
    fi
250 251
fi

252
if [ "$2" != "jdbc" ] && [ "$2" != "python" ] && [ "$2" != "unit" ]  && [ "$2" != "example" ]; then
253
  echo "### run TSIM test case ###"
S
Shuduo Sang 已提交
254
  cd $tests_dir/script
255

256 257 258 259 260 261
  [ -f out.log ] && rm -f out.log
  if [ "$1" == "cron" ]; then
    echo "### run TSIM regression test ###"
    runSimCaseOneByOne regressionSuite.sim
  elif [ "$1" == "full" ]; then
    echo "### run TSIM full test ###"
P
Ping Xiao 已提交
262
    runSimCaseOneByOne jenkins/basic.txt
L
liuyq-617 已提交
263 264
  elif [ "$1" == "b1" ]; then
    echo "### run TSIM b1 test ###"
L
liuyq-617 已提交
265 266 267
    runSimCaseOneByOnefq b1 0
    runSimCaseOneByOnefq b4 0
    runSimCaseOneByOnefq b7 0
L
liuyq-617 已提交
268 269
  elif [ "$1" == "b2" ]; then
    echo "### run TSIM b2 test ###"
L
liuyq-617 已提交
270
    runSimCaseOneByOnefq b2 0
L
balance  
liuyq-617 已提交
271
    runSimCaseOneByOnefq b5 0
L
liuyq-617 已提交
272 273
  elif [ "$1" == "b3" ]; then
    echo "### run TSIM b3 test ###"
L
liuyq-617 已提交
274
    runSimCaseOneByOnefq b3 0
L
balance  
liuyq-617 已提交
275
    runSimCaseOneByOnefq b6 0
L
liuyq-617 已提交
276 277
  elif [ "$1" == "b1fq" ]; then
    echo "### run TSIM b1 test ###"
L
liuyq-617 已提交
278
    runSimCaseOneByOnefq b1 1
L
liuyq-617 已提交
279 280
  elif [ "$1" == "b2fq" ]; then
    echo "### run TSIM b2 test ###"
L
liuyq-617 已提交
281
    runSimCaseOneByOnefq b2 1
L
liuyq-617 已提交
282 283
  elif [ "$1" == "b3fq" ]; then
    echo "### run TSIM b3 test ###"
L
liuyq-617 已提交
284
    runSimCaseOneByOnefq b3 1
L
liuyq-617 已提交
285 286
  elif [ "$1" == "b4fq" ]; then
    echo "### run TSIM b4 test ###"
L
liuyq-617 已提交
287
    runSimCaseOneByOnefq b4 1
L
liuyq-617 已提交
288 289
  elif [ "$1" == "b5fq" ]; then
    echo "### run TSIM b5 test ###"
L
liuyq-617 已提交
290
    runSimCaseOneByOnefq b5 1
L
liuyq-617 已提交
291 292
  elif [ "$1" == "b6fq" ]; then
    echo "### run TSIM b6 test ###"
L
liuyq-617 已提交
293
    runSimCaseOneByOnefq b6 1
L
liuyq-617 已提交
294 295
  elif [ "$1" == "b7fq" ]; then
    echo "### run TSIM b7 test ###"
L
liuyq-617 已提交
296
    runSimCaseOneByOnefq b7 1
S
Shuduo Sang 已提交
297
  elif [ "$1" == "smoke" ] || [ -z "$1" ]; then
298 299 300
    echo "### run TSIM smoke test ###"
    runSimCaseOneByOne basicSuite.sim
  fi
301

302 303
  totalSuccess=`grep 'success' out.log | wc -l`
  totalBasic=`grep success out.log | grep Suite | wc -l`
304

305 306 307
  if [ "$totalSuccess" -gt "0" ]; then
    totalSuccess=`expr $totalSuccess - $totalBasic`
  fi
sangshuduo's avatar
sangshuduo 已提交
308

S
Shuduo Sang 已提交
309
  echo -e "\n${GREEN} ### Total $totalSuccess TSIM case(s) succeed! ### ${NC}"
310

311 312
  totalFailed=`grep 'failed\|fault' out.log | wc -l`
# echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}"
313

314
  if [ "$totalFailed" -ne "0" ]; then
S
Shuduo Sang 已提交
315
    echo -e "\n${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}"
sangshuduo's avatar
sangshuduo 已提交
316

317 318
#  exit $totalFailed
  fi
sangshuduo's avatar
sangshuduo 已提交
319 320
fi

321
if [ "$2" != "sim" ] && [ "$2" != "jdbc" ] && [ "$2" != "unit" ]  && [ "$2" != "example" ]; then
322
  echo "### run Python test case ###"
323

S
Shuduo Sang 已提交
324
  cd $tests_dir
325

S
Shuduo Sang 已提交
326
  if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
327 328 329 330 331 332
    cd ../..
  else
    cd ../
  fi

  TOP_DIR=`pwd`
333
  TAOSLIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1`
334
  if [[ "$TAOSLIB_DIR" == *"$IN_TDINTERNAL"* ]]; then
335
    LIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1|cut -d '/' -f 2,3,4,5`
336
  else
337
    LIB_DIR=`find . -name "${TAOSLIB}"|grep -w lib|head -n1|cut -d '/' -f 2,3,4`
338 339 340 341
  fi

  export LD_LIBRARY_PATH=$TOP_DIR/$LIB_DIR:$LD_LIBRARY_PATH

S
Shuduo Sang 已提交
342
  cd $tests_dir/pytest
343 344 345 346 347 348 349 350

  [ -f pytest-out.log ] && rm -f pytest-out.log

  if [ "$1" == "cron" ]; then
    echo "### run Python regression test ###"
    runPyCaseOneByOne regressiontest.sh
  elif [ "$1" == "full" ]; then
    echo "### run Python full test ###"
351 352 353 354 355 356 357 358 359 360 361 362
    cd $tests_dir/develop-test
    for name in *.sh
    do
      runPyCaseOneByOne $name
    done
    cd $tests_dir/system-test
    for name in *.sh
    do
      runPyCaseOneByOne $name
    done
    cd $tests_dir/pytest
    runPyCaseOneByOne fulltest.sh    
L
liuyq-617 已提交
363
  elif [ "$1" == "pytest" ]; then
L
liuyq-617 已提交
364 365
    echo "### run Python full test ###"
    runPyCaseOneByOne fulltest.sh
L
liuyq-617 已提交
366 367
  elif [ "$1" == "pytestfq" ]; then
    echo "### run Python full test ###"
L
liuyq-617 已提交
368
    runPyCaseOneByOnefq full 0
369 370
  elif [ "$1" == "p1" ]; then
    echo "### run Python_1 test ###"
L
liuyq-617 已提交
371
    runPyCaseOneByOnefq p1 1
372 373
  elif [ "$1" == "p2" ]; then
    echo "### run Python_2 test ###"
L
liuyq-617 已提交
374
    runPyCaseOneByOnefq p2 1
L
liuyq-617 已提交
375 376
  elif [ "$1" == "p3" ]; then
    echo "### run Python_3 test ###"
L
liuyq-617 已提交
377
    runPyCaseOneByOnefq p3 1 
L
liuyq-617 已提交
378 379
  elif [ "$1" == "p4" ]; then
    echo "### run Python_4 test ###"
L
liuyq-617 已提交
380
    runPyCaseOneByOnefq p4 1
L
liuyq-617 已提交
381 382 383 384 385 386
  elif [ "$1" == "system-test" ]; then
    echo "### run system-test test ###"
    runPyCaseOneByOnefq full 1 system
  elif [ "$1" == "develop-test" ]; then
    echo "### run develop-test test ###"
    runPyCaseOneByOnefq full 1 develop
L
liuyq-617 已提交
387 388
  elif [ "$1" == "b2" ] || [ "$1" == "b3" ]; then
    exit $(($totalFailed + $totalPyFailed))
S
Shuduo Sang 已提交
389
  elif [ "$1" == "smoke" ] || [ -z "$1" ]; then
390 391 392
    echo "### run Python smoke test ###"
    runPyCaseOneByOne smoketest.sh
  fi
393
  totalPySuccess=`grep 'success' pytest-out.log | wc -l`
394 395

  if [ "$totalPySuccess" -gt "0" ]; then
S
Shuduo Sang 已提交
396
    echo -e "\n${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}"
397 398 399 400
  fi

  totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l`
  if [ "$totalPyFailed" -ne "0" ]; then
S
Shuduo Sang 已提交
401
    echo -e "\n${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}"
402
#  exit $totalPyFailed
403
  fi
sangshuduo's avatar
sangshuduo 已提交
404 405
fi

406

407
if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "unit" ]  && [ "$2" != "example" ] && [ "$1" == "full" ]; then
408
  echo "### run JDBC test cases ###"
409

P
Ping Xiao 已提交
410
  cd $tests_dir
411 412 413 414 415 416 417

  if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
    cd ../../
  else
    cd ../
  fi

P
Ping Xiao 已提交
418
  pwd
419
  cd debug/
P
change  
Ping Xiao 已提交
420
  
P
Ping Xiao 已提交
421
  stopTaosd
422
  rm -rf /var/lib/taos/*
423 424
  nohup build/bin/taosd -c /etc/taos/ > /dev/null 2>&1 &
  sleep 30
P
change  
Ping Xiao 已提交
425
  
426
  cd $tests_dir/../src/connector/jdbc  
P
Ping Xiao 已提交
427
  
P
change  
Ping Xiao 已提交
428
  mvn test > jdbc-out.log 2>&1
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450
  tail -n 20 jdbc-out.log

  cases=`grep 'Tests run' jdbc-out.log | awk 'END{print $3}'`
  totalJDBCCases=`echo ${cases/%,}`
  failed=`grep 'Tests run' jdbc-out.log | awk 'END{print $5}'`
  JDBCFailed=`echo ${failed/%,}`
  error=`grep 'Tests run' jdbc-out.log | awk 'END{print $7}'`
  JDBCError=`echo ${error/%,}`
  
  totalJDBCFailed=`expr $JDBCFailed + $JDBCError`
  totalJDBCSuccess=`expr $totalJDBCCases - $totalJDBCFailed`

  if [ "$totalJDBCSuccess" -gt "0" ]; then
    echo -e "\n${GREEN} ### Total $totalJDBCSuccess JDBC case(s) succeed! ### ${NC}"
  fi
  
  if [ "$totalJDBCFailed" -ne "0" ]; then
    echo -e "\n${RED} ### Total $totalJDBCFailed JDBC case(s) failed! ### ${NC}"
  fi
  dohavecore 1
fi

451
if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ]  && [ "$2" != "example" ]  && [ "$1" == "full" ]; then
452 453 454 455 456 457 458 459 460 461 462 463 464
  echo "### run Unit tests ###"  

  stopTaosd
  cd $tests_dir

  if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
    cd ../../
  else
    cd ../
  fi

  pwd
  cd debug/build/bin
465
  rm -rf /var/lib/taos/*
466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
  nohup ./taosd -c /etc/taos/ > /dev/null 2>&1 &
  sleep 30
  
  pwd
  ./queryTest > unittest-out.log 2>&1
  tail -n 20 unittest-out.log

  totalUnitTests=`grep "Running" unittest-out.log | awk '{print $3}'`  
  totalUnitSuccess=`grep 'PASSED' unittest-out.log | awk '{print $4}'`
  totalUnitFailed=`expr $totalUnitTests - $totalUnitSuccess`

  if [ "$totalUnitSuccess" -gt "0" ]; then
    echo -e "\n${GREEN} ### Total $totalUnitSuccess Unit test succeed! ### ${NC}"
  fi
  
  if [ "$totalUnitFailed" -ne "0" ]; then
    echo -e "\n${RED} ### Total $totalUnitFailed Unit test failed! ### ${NC}"
  fi
  dohavecore 1
fi

487 488
if [ "$2" != "sim" ] && [ "$2" != "python" ] && [ "$2" != "jdbc" ] && [ "$2" != "unit" ] && [ "$1" == "full" ]; then
  echo "### run Example tests ###"  
489

490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
  stopTaosd
  cd $tests_dir

  if [[ "$tests_dir" == *"$IN_TDINTERNAL"* ]]; then
    cd ../../
  else
    cd ../
  fi

  pwd
  cd debug/build/bin
  rm -rf /var/lib/taos/*
  nohup ./taosd -c /etc/taos/ > /dev/null 2>&1 &
  echo "sleeping for 30 seconds"
  #sleep 30
  
  cd $tests_dir
  echo "current dir: "
  pwd
  cd examples/c
  echo "building applications"
  make > /dev/null
  totalExamplePass=0

  echo "Running tests"
P
Ping Xiao 已提交
515 516 517 518 519 520 521 522
  ./apitest > /dev/null 2>&1
  if [ $? != "0" ]; then
    echo "apitest failed"
    totalExampleFailed=`expr $totalExampleFailed + 1`    
  else
    echo "apitest pass"
    totalExamplePass=`expr $totalExamplePass + 1`
  fi 
523

Z
zhaoyanggh 已提交
524
  ./prepare > /dev/null 2>&1
525 526 527 528 529 530 531 532 533 534
  if [ $? != "0" ]; then
    echo "prepare failed"
    totalExampleFailed=`expr $totalExampleFailed + 1`    
  else
    echo "prepare pass"
    totalExamplePass=`expr $totalExamplePass + 1`
  fi

  ./subscribe -test > /dev/null 2>&1
  if [ $? != "0" ]; then
P
Ping Xiao 已提交
535
    echo "subscribe failed"
536 537
    totalExampleFailed=`expr $totalExampleFailed + 1`    
  else
P
Ping Xiao 已提交
538
    echo "subscribe pass"
539 540 541 542 543
    totalExamplePass=`expr $totalExamplePass + 1`
  fi

  yes |./asyncdemo 127.0.0.1 test 1000 10 > /dev/null 2>&1
  if [ $? != "0" ]; then
P
Ping Xiao 已提交
544
    echo "asyncdemo failed"
545 546
    totalExampleFailed=`expr $totalExampleFailed + 1`    
  else
P
Ping Xiao 已提交
547
    echo "asyncdemo pass"
548 549
    totalExamplePass=`expr $totalExamplePass + 1`
  fi
550 551 552 553 554 555 556 557 558

  ./demo 127.0.0.1 > /dev/null 2>&1
  if [ $? != "0" ]; then
    echo "demo failed"
    totalExampleFailed=`expr $totalExampleFailed + 1`    
  else
    echo "demo pass"
    totalExamplePass=`expr $totalExamplePass + 1`
  fi
J
jiacy-jcy 已提交
559 560 561 562
  echo "### run setconfig tests ###"

  stopTaosd

J
jiacy-jcy 已提交
563 564
  cd $tests_dir
  echo "current dir: "
J
Jason-Jia 已提交
565
  
J
jiacy-jcy 已提交
566
  pwd
J
Jason-Jia 已提交
567
  
J
jiacy-jcy 已提交
568
  cd script/api
J
Jason-Jia 已提交
569
  echo "building setcfgtest"
J
jiacy-jcy 已提交
570 571 572 573 574 575 576 577 578 579 580
  make > /dev/null
  ./clientcfgtest
  if [ $? != "0" ]; then
    echo "clientcfgtest failed"
    totalExampleFailed=`expr $totalExampleFailed + 1`    
  else
    echo "clientcfgtest pass"
    totalExamplePass=`expr $totalExamplePass + 1`
  fi


581 582 583 584 585 586 587 588
  if [ "$totalExamplePass" -gt "0" ]; then
    echo -e "\n${GREEN} ### Total $totalExamplePass examples succeed! ### ${NC}"
  fi
  
  if [ "$totalExampleFailed" -ne "0" ]; then
    echo -e "\n${RED} ### Total $totalExampleFailed examples failed! ### ${NC}"
  fi

589 590 591
  if [ "${OS}" == "Linux" ]; then
    dohavecore 1
  fi
J
jiacy-jcy 已提交
592 593 594 595 596

  



597 598 599
fi


J
jiacy-jcy 已提交
600

601
exit $(($totalFailed + $totalPyFailed + $totalJDBCFailed + $totalUnitFailed + $totalExampleFailed))