From 147f5af9b28ed364f9773343a8cc0bfe92a20ccd Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 17 Dec 2021 18:23:13 +0800 Subject: [PATCH] adjust sim script --- CMakeLists.txt | 2 +- tests/script/sh/deploy.sh | 9 ++++++--- tests/script/sh/exec.sh | 11 +++++++---- tests/script/test.sh | 25 +++++-------------------- tests/tsim/src/simSystem.c | 6 ++++++ 5 files changed, 25 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b8a3f9a1c..cda71fb3bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -31,4 +31,4 @@ add_subdirectory(tests) # docs add_subdirectory(docs) -# tests (TODO) \ No newline at end of file +# tests (TODO) diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index cde27d7dc3..03ce1c2888 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -1,5 +1,8 @@ #!/bin/bash +set +e +#set -x + echo "Executing deploy.sh" if [ $# != 4 ]; then @@ -50,12 +53,12 @@ else fi if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then - BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` + BIN_DIR=`find . -name "taosd"|grep source|head -n1|cut -d '/' ${cut_opt}2,3` else - BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` + BIN_DIR=`find . -name "taosd"|grep source|head -n1|cut -d '/' ${cut_opt}2` fi -BUILD_DIR=$TAOS_DIR/$BIN_DIR/build +BUILD_DIR=$TAOS_DIR/$BIN_DIR SIM_DIR=$TAOS_DIR/sim diff --git a/tests/script/sh/exec.sh b/tests/script/sh/exec.sh index 80b8cda428..a40912d5f4 100755 --- a/tests/script/sh/exec.sh +++ b/tests/script/sh/exec.sh @@ -8,6 +8,9 @@ # exit 1 # fi +set +e +set -x + UNAME_BIN=`which uname` OS_TYPE=`$UNAME_BIN` @@ -62,16 +65,16 @@ else fi if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then - BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` + BIN_DIR=`find . -name "taosd"|grep source|head -n1|cut -d '/' ${cut_opt}2,3` else - BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` + BIN_DIR=`find . -name "taosd"|grep source|head -n1|cut -d '/' ${cut_opt}2` fi -BUILD_DIR=$TAOS_DIR/$BIN_DIR/build +BUILD_DIR=$TAOS_DIR/$BIN_DIR SIM_DIR=$TAOS_DIR/sim NODE_DIR=$SIM_DIR/$NODE_NAME -EXE_DIR=$BUILD_DIR/bin +EXE_DIR=$BUILD_DIR/source/dnode/mgmt/daemon CFG_DIR=$NODE_DIR/cfg LOG_DIR=$NODE_DIR/log DATA_DIR=$NODE_DIR/data diff --git a/tests/script/test.sh b/tests/script/test.sh index f2dc578987..a744a56aa6 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -22,9 +22,6 @@ do f) FILE_NAME=$OPTARG ;; - a) - ASYNC=1 - ;; v) VALGRIND=1 ;; @@ -60,32 +57,22 @@ else fi if [[ "$TAOSD_DIR" == *"$IN_TDINTERNAL"* ]]; then - BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2,3` + BIN_DIR=`find . -name "taosd"|grep source|head -n1|cut -d '/' ${cut_opt}2,3` else - BIN_DIR=`find . -name "taosd"|grep bin|head -n1|cut -d '/' ${cut_opt}2` + BIN_DIR=`find . -name "taosd"|grep source|head -n1|cut -d '/' ${cut_opt}2` fi -BUILD_DIR=$TOP_DIR/$BIN_DIR/build +BUILD_DIR=$TOP_DIR/$BIN_DIR SIM_DIR=$TOP_DIR/sim -if [ $ASYNC -eq 0 ]; then - PROGRAM=$BUILD_DIR/bin/tsim -else - PROGRAM="$BUILD_DIR/bin/tsim -a" -fi - +PROGRAM=$BUILD_DIR/tests/tsim/tsim PRG_DIR=$SIM_DIR/tsim CFG_DIR=$PRG_DIR/cfg LOG_DIR=$PRG_DIR/log DATA_DIR=$PRG_DIR/data - -ARBITRATOR_PRG_DIR=$SIM_DIR/arbitrator -ARBITRATOR_LOG_DIR=$ARBITRATOR_PRG_DIR/log - - chmod -R 777 $PRG_DIR echo "------------------------------------------------------------------------" echo "Start TDengine Testing Case ..." @@ -96,12 +83,10 @@ echo "CFG_DIR : $CFG_DIR" rm -rf $LOG_DIR rm -rf $CFG_DIR -rm -rf $ARBITRATOR_LOG_DIR mkdir -p $PRG_DIR mkdir -p $LOG_DIR mkdir -p $CFG_DIR -mkdir -p $ARBITRATOR_LOG_DIR TAOS_CFG=$PRG_DIR/cfg/taos.cfg touch -f $TAOS_CFG @@ -115,7 +100,7 @@ echo "secondEp ${HOSTNAME}:7200" >> $TAOS_CFG echo "serverPort 7100" >> $TAOS_CFG echo "dataDir $DATA_DIR" >> $TAOS_CFG echo "logDir $LOG_DIR" >> $TAOS_CFG -echo "scriptDir ${CODE_DIR}/../script" >> $TAOS_CFG +echo "scriptDir ${CODE_DIR}" >> $TAOS_CFG echo "numOfLogLines 100000000" >> $TAOS_CFG echo "rpcDebugFlag 143" >> $TAOS_CFG echo "tmrDebugFlag 131" >> $TAOS_CFG diff --git a/tests/tsim/src/simSystem.c b/tests/tsim/src/simSystem.c index db32354616..cb61e6b814 100644 --- a/tests/tsim/src/simSystem.c +++ b/tests/tsim/src/simSystem.c @@ -21,6 +21,8 @@ #include "tglobal.h" #include "ttimer.h" #include "tutil.h" +#include "tglobal.h" +#include "tconfig.h" SScript *simScriptList[MAX_MAIN_SCRIPT_NUM]; SCommand simCmdList[SIM_CMD_END]; @@ -80,6 +82,10 @@ char *simParseHostName(char *varName) { bool simSystemInit() { taosGetFqdn(simHostName); + + taosInitGlobalCfg(); + taosReadCfgFromFile(); + simInitsimCmdList(); memset(simScriptList, 0, sizeof(SScript *) * MAX_MAIN_SCRIPT_NUM); return true;