From 9ea0e2f7700654e5a55efaec5eaa74fb3857060a Mon Sep 17 00:00:00 2001 From: Shuduo Sang Date: Sun, 31 May 2020 12:58:09 +0800 Subject: [PATCH] fix test scripts according to jeff's suggestion. --- .travis.yml | 10 +++++----- tests/pytest/fulltest.sh | 2 ++ tests/pytest/smoketest.sh | 2 ++ tests/pytest/util/dnodes.py | 20 ++++++++++---------- tests/script/sh/cfg.sh | 15 ++++++++++++--- tests/script/sh/clear.sh | 14 +++++++++++--- tests/script/sh/deploy.sh | 15 ++++++++++++--- tests/script/sh/exec.sh | 19 ++++++++++++++----- tests/script/sh/exec_tarbitrator.sh | 17 +++++++++++++---- tests/script/sh/exec_up.sh | 17 +++++++++++++---- tests/script/test.sh | 20 +++++++++++++------- tests/test-all.sh | 16 ++++++++-------- 12 files changed, 115 insertions(+), 52 deletions(-) diff --git a/.travis.yml b/.travis.yml index 877e717eaf..af41d45ac0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -51,7 +51,7 @@ matrix: ./test-all.sh $TRAVIS_EVENT_TYPE || travis_terminate $? cd ${TRAVIS_BUILD_DIR}/tests/pytest - ./valgrind-test.sh 2>&1 > mem-error-out.txt + ./valgrind-test.sh 2>&1 > mem-error-out.log sleep 1 # Color setting @@ -61,9 +61,9 @@ matrix: GREEN_UNDERLINE='\033[4;32m' NC='\033[0m' - grep 'start to execute\|ERROR SUMMARY' mem-error-out.txt|grep -v 'grep'|uniq|tee uniq-mem-error-out.txt + grep 'start to execute\|ERROR SUMMARY' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-mem-error-out.log - for memError in `grep 'ERROR SUMMARY' uniq-mem-error-out.txt | awk '{print $4}'` + for memError in `grep 'ERROR SUMMARY' uniq-mem-error-out.log | awk '{print $4}'` do if [ -n "$memError" ]; then if [ "$memError" -gt 12 ]; then @@ -74,8 +74,8 @@ matrix: fi done - grep 'start to execute\|definitely lost:' mem-error-out.txt|grep -v 'grep'|uniq|tee uniq-definitely-lost-out.txt - for defiMemError in `grep 'definitely lost:' uniq-definitely-lost-out.txt | awk '{print $7}'` + grep 'start to execute\|definitely lost:' mem-error-out.log|grep -v 'grep'|uniq|tee uniq-definitely-lost-out.log + for defiMemError in `grep 'definitely lost:' uniq-definitely-lost-out.log | awk '{print $7}'` do if [ -n "$defiMemError" ]; then if [ "$defiMemError" -gt 13 ]; then diff --git a/tests/pytest/fulltest.sh b/tests/pytest/fulltest.sh index cceb17b0de..bf3523dc0f 100755 --- a/tests/pytest/fulltest.sh +++ b/tests/pytest/fulltest.sh @@ -1,4 +1,6 @@ #!/bin/bash +ulimit -c unlimited + python3 ./test.py -f insert/basic.py python3 ./test.py -f insert/int.py python3 ./test.py -f insert/float.py diff --git a/tests/pytest/smoketest.sh b/tests/pytest/smoketest.sh index 57a9a67936..df4a5ed5c5 100755 --- a/tests/pytest/smoketest.sh +++ b/tests/pytest/smoketest.sh @@ -1,4 +1,6 @@ #!/bin/bash +ulimit -c unlimited + # insert python3 ./test.py $1 -f insert/basic.py python3 ./test.py $1 -s && sleep 1 diff --git a/tests/pytest/util/dnodes.py b/tests/pytest/util/dnodes.py index 13038f4dda..4c839d87a3 100644 --- a/tests/pytest/util/dnodes.py +++ b/tests/pytest/util/dnodes.py @@ -38,9 +38,9 @@ class TDSimClient: tdLog.exit(cmd) def deploy(self): - self.logDir = "%s/pysim/psim/log" % (self.path,) - self.cfgDir = "%s/pysim/psim/cfg" % (self.path) - self.cfgPath = "%s/pysim/psim/cfg/taos.cfg" % (self.path) + self.logDir = "%s/sim/psim/log" % (self.path,) + self.cfgDir = "%s/sim/psim/cfg" % (self.path) + self.cfgPath = "%s/sim/psim/cfg/taos.cfg" % (self.path) cmd = "rm -rf " + self.logDir if os.system(cmd) != 0: @@ -113,10 +113,10 @@ class TDDnode: return totalSize def deploy(self): - self.logDir = "%s/pysim/dnode%d/log" % (self.path, self.index) - self.dataDir = "%s/pysim/dnode%d/data" % (self.path, self.index) - self.cfgDir = "%s/pysim/dnode%d/cfg" % (self.path, self.index) - self.cfgPath = "%s/pysim/dnode%d/cfg/taos.cfg" % ( + self.logDir = "%s/sim/dnode%d/log" % (self.path, self.index) + self.dataDir = "%s/sim/dnode%d/data" % (self.path, self.index) + self.cfgDir = "%s/sim/dnode%d/cfg" % (self.path, self.index) + self.cfgPath = "%s/sim/dnode%d/cfg/taos.cfg" % ( self.path, self.index) cmd = "rm -rf " + self.dataDir @@ -298,11 +298,11 @@ class TDDnode: tdLog.exit(cmd) def getDnodeRootDir(self, index): - dnodeRootDir = "%s/pysim/psim/dnode%d" % (self.path, index) + dnodeRootDir = "%s/sim/psim/dnode%d" % (self.path, index) return dnodeRootDir def getDnodesRootDir(self): - dnodesRootDir = "%s/pysim/psim" % (self.path) + dnodesRootDir = "%s/sim/psim" % (self.path) return dnodesRootDir @@ -455,7 +455,7 @@ class TDDnodes: # tdLog.exit(cmd) def getDnodesRootDir(self): - dnodesRootDir = "%s/pysim" % (self.path) + dnodesRootDir = "%s/sim" % (self.path) return dnodesRootDir def getSimCfgPath(self): diff --git a/tests/script/sh/cfg.sh b/tests/script/sh/cfg.sh index f28b401b78..0705343fec 100755 --- a/tests/script/sh/cfg.sh +++ b/tests/script/sh/cfg.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash if [ $# != 6 ]; then echo "argument list need input : " @@ -33,10 +33,19 @@ SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/debug/build +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TAOS_DIR/$BIN_DIR + SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/$NODE_NAME diff --git a/tests/script/sh/clear.sh b/tests/script/sh/clear.sh index 0d58b5aec4..8c92054352 100755 --- a/tests/script/sh/clear.sh +++ b/tests/script/sh/clear.sh @@ -36,12 +36,20 @@ cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` echo "SCRIPT_DIR: $SCRIPT_DIR" -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/debug/build -SIM_DIR=$TAOS_DIR/sim +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` +BUILD_DIR=$TAOS_DIR/$BIN_DIR + +SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/$NODE_NAME EXE_DIR=$BUILD_DIR/bin CFG_DIR=$NODE_DIR/cfg diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 47f9f7109d..e1669ac3d7 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash echo "Executing deploy.sh" @@ -31,10 +31,19 @@ cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` echo "SCRIPT_DIR: $SCRIPT_DIR" -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/debug/build +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TAOS_DIR/$BIN_DIR + SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/$NODE_NAME diff --git a/tests/script/sh/exec.sh b/tests/script/sh/exec.sh index f3fcd0325f..ebfe8861b0 100755 --- a/tests/script/sh/exec.sh +++ b/tests/script/sh/exec.sh @@ -1,4 +1,4 @@ -#!/bin/sh +#!/bin/bash # if [ $# != 4 || $# != 5 ]; then # echo "argument list need input : " @@ -42,10 +42,19 @@ SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/debug/build +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TAOS_DIR/$BIN_DIR + SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/$NODE_NAME EXE_DIR=$BUILD_DIR/bin @@ -86,9 +95,9 @@ else if [ -n "$PID" ]; then if [ "$SIGNAL" = "SIGINT" ]; then echo killed by signal - sudo kill -sigint $PID + kill -sigint $PID else - sudo kill -9 $PID + kill -9 $PID fi fi fi diff --git a/tests/script/sh/exec_tarbitrator.sh b/tests/script/sh/exec_tarbitrator.sh index cb0a8858cb..430d0920d2 100755 --- a/tests/script/sh/exec_tarbitrator.sh +++ b/tests/script/sh/exec_tarbitrator.sh @@ -39,10 +39,19 @@ SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/../debug/build +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TAOS_DIR/$BIN_DIR + SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/arbitrator EXE_DIR=$BUILD_DIR/bin @@ -57,8 +66,8 @@ else #relative path PID=`ps -ef|grep tarbitrator | grep -v grep | awk '{print $2}'` if [ -n "$PID" ]; then - sudo kill -9 $PID - sudo pkill -9 tarbitrator + kill -9 $PID + pkill -9 tarbitrator fi fi diff --git a/tests/script/sh/exec_up.sh b/tests/script/sh/exec_up.sh index abe2822450..ed20117379 100755 --- a/tests/script/sh/exec_up.sh +++ b/tests/script/sh/exec_up.sh @@ -42,10 +42,19 @@ SCRIPT_DIR=`dirname $0` cd $SCRIPT_DIR/../ SCRIPT_DIR=`pwd` -cd ../../ +TDINTERNAL="TDinternal" +if [[ "$SCRIPT_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TAOS_DIR=`pwd` -BUILD_DIR=$TAOS_DIR/../debug/build +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TAOS_DIR/$BIN_DIR + SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/$NODE_NAME EXE_DIR=$BUILD_DIR/bin @@ -91,9 +100,9 @@ else if [ -n "$PID" ]; then if [ "$SIGNAL" = "SIGINT" ]; then echo killed by signal - sudo kill -sigint $PID + kill -sigint $PID else - sudo kill -9 $PID + kill -9 $PID fi fi fi diff --git a/tests/script/test.sh b/tests/script/test.sh index 984eb13c4c..f5485bd881 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -40,9 +40,20 @@ cd . # Get responsible directories CODE_DIR=`dirname $0` CODE_DIR=`pwd` -cd ../../ + +TDINTERNAL="TDinternal" +if [[ "$CODE_DIR" == *"$TDINTERNAL"* ]]; then + cd ../../.. +else + cd ../../ +fi + TOP_DIR=`pwd` -BUILD_DIR=$TOP_DIR/debug/build + +BIN_DIR=`find . -name "taosd"|grep bin| cut -d '/' --fields=2,3` + +BUILD_DIR=$TOP_DIR/$BIN_DIR + SIM_DIR=$TOP_DIR/sim if [ $ASYNC -eq 0 ]; then @@ -51,11 +62,6 @@ else PROGRAM="$BUILD_DIR/bin/tsim -a" fi -if [ $UNIQUE -eq 0 ]; then - PROGRAM=$BUILD_DIR/bin/tsim -else - PROGRAM="$TOP_DIR/../debug/build/bin/tsim" -fi PRG_DIR=$SIM_DIR/tsim CFG_DIR=$PRG_DIR/cfg diff --git a/tests/test-all.sh b/tests/test-all.sh index a56b5eeef7..fdc607ed66 100755 --- a/tests/test-all.sh +++ b/tests/test-all.sh @@ -9,10 +9,10 @@ NC='\033[0m' echo "### run TSIM script ###" cd script -./test.sh -f basicSuite.sim 2>&1 | grep 'success\|failed\|fault' | grep -v 'default' | tee out.txt +./test.sh -f basicSuite.sim 2>&1 | grep 'success\|failed\|fault' | grep -v 'default' | tee out.log -totalSuccess=`grep 'success' out.txt | wc -l` -totalBasic=`grep success out.txt | grep Suite | wc -l` +totalSuccess=`grep 'success' out.log | wc -l` +totalBasic=`grep success out.log | grep Suite | wc -l` if [ "$totalSuccess" -gt "0" ]; then totalSuccess=`expr $totalSuccess - $totalBasic` @@ -20,7 +20,7 @@ fi echo -e "${GREEN} ### Total $totalSuccess TSIM case(s) succeed! ### ${NC}" -totalFailed=`grep 'failed\|fault' out.txt | wc -l` +totalFailed=`grep 'failed\|fault' out.log | wc -l` # echo -e "${RED} ### Total $totalFailed TSIM case(s) failed! ### ${NC}" if [ "$totalFailed" -ne "0" ]; then @@ -33,17 +33,17 @@ echo "### run Python script ###" cd ../pytest if [ "$1" == "cron" ]; then - ./fulltest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.txt + ./fulltest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.log else - ./smoketest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.txt + ./smoketest.sh 2>&1 | grep 'successfully executed\|failed\|fault' | grep -v 'default'| tee pytest-out.log fi -totalPySuccess=`grep 'successfully executed' pytest-out.txt | wc -l` +totalPySuccess=`grep 'successfully executed' pytest-out.log | wc -l` if [ "$totalPySuccess" -gt "0" ]; then echo -e "${GREEN} ### Total $totalPySuccess python case(s) succeed! ### ${NC}" fi -totalPyFailed=`grep 'failed\|fault' pytest-out.txt | wc -l` +totalPyFailed=`grep 'failed\|fault' pytest-out.log | wc -l` if [ "$totalPyFailed" -ne "0" ]; then echo -e "${RED} ### Total $totalPyFailed python case(s) failed! ### ${NC}" # exit $totalPyFailed -- GitLab