From 5a2a34f1bd8593ad7d2f6d587c26fa57f610a189 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Fri, 1 Apr 2022 19:07:05 +0800 Subject: [PATCH] add multiprocess mode to CI --- tests/script/jenkins/basic.txt | 7 +++++++ tests/script/sh/deploy.sh | 15 ++++++--------- tests/script/test.sh | 16 ++++++++++++---- tests/tsim/inc/simInt.h | 1 + tests/tsim/src/simExe.c | 31 +++++++++++++++++-------------- tests/tsim/src/simMain.c | 3 +++ 6 files changed, 46 insertions(+), 27 deletions(-) diff --git a/tests/script/jenkins/basic.txt b/tests/script/jenkins/basic.txt index 811c9941f7..3a5d782716 100644 --- a/tests/script/jenkins/basic.txt +++ b/tests/script/jenkins/basic.txt @@ -50,4 +50,11 @@ ./test.sh -f tsim/stable/values.sim ./test.sh -f tsim/stable/vnode3.sim + +# --- for multi process mode +./test.sh -f tsim/user/basic1.sim -m +./test.sh -f tsim/insert/basic1.sim -m +./test.sh -f tsim/stable/vnode3.sim -m +./test.sh -f tsim/tmq/basic.sim -m + #======================b1-end=============== diff --git a/tests/script/sh/deploy.sh b/tests/script/sh/deploy.sh index 1bbfccf989..38b6d9aadb 100755 --- a/tests/script/sh/deploy.sh +++ b/tests/script/sh/deploy.sh @@ -5,18 +5,12 @@ set +e echo "Executing deploy.sh" -if [ $# != 4 ]; then - echo "argument list need input : " - echo " -n nodeName" - echo " -i nodePort" - exit 1 -fi - UNAME_BIN=`which uname` OS_TYPE=`$UNAME_BIN` NODE_NAME= NODE= -while getopts "n:i:" arg +MULTIPROCESS=0 +while getopts "n:i:m" arg do case $arg in n) @@ -25,6 +19,9 @@ do i) NODE=$OPTARG ;; + m) + MULTIPROCESS=1 + ;; ?) echo "unkonw argument" ;; @@ -145,5 +142,5 @@ echo "statusInterval 1" >> $TAOS_CFG echo "asyncLog 0" >> $TAOS_CFG echo "locale en_US.UTF-8" >> $TAOS_CFG echo "telemetryReporting 0" >> $TAOS_CFG -echo "multiProcess 0" >> $TAOS_CFG +echo "multiProcess ${MULTIPROCESS}" >> $TAOS_CFG echo " " >> $TAOS_CFG diff --git a/tests/script/test.sh b/tests/script/test.sh index f89b9fb1a2..efd193d256 100755 --- a/tests/script/test.sh +++ b/tests/script/test.sh @@ -7,7 +7,6 @@ ################################################## set +e -#set -x FILE_NAME= RELEASE=0 @@ -16,7 +15,8 @@ VALGRIND=0 UNIQUE=0 UNAME_BIN=`which uname` OS_TYPE=`$UNAME_BIN` -while getopts "f:avu" arg +MULTIPROCESS=1 +while getopts "f:avum" arg do case $arg in f) @@ -28,6 +28,9 @@ do u) UNIQUE=1 ;; + m) + MULTIPROCESS=1 + ;; ?) echo "unknow argument" ;; @@ -125,8 +128,13 @@ if [ -n "$FILE_NAME" ]; then echo valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME valgrind --tool=memcheck --leak-check=full --show-reachable=no --track-origins=yes --show-leak-kinds=all -v --workaround-gcc296-bugs=yes --log-file=${CODE_DIR}/../script/valgrind.log $PROGRAM -c $CFG_DIR -f $FILE_NAME else - echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f $FILE_NAME - $PROGRAM -c $CFG_DIR -f $FILE_NAME + if [[ $MULTIPROCESS -eq 1 ]];then + echo "ExcuteCmd(multiprocess):" $PROGRAM -m -c $CFG_DIR -f $FILE_NAME + $PROGRAM -m -c $CFG_DIR -f $FILE_NAME + else + echo "ExcuteCmd(singleprocess):" $PROGRAM -c $CFG_DIR -f $FILE_NAME + $PROGRAM -c $CFG_DIR -f $FILE_NAME + fi fi else echo "ExcuteCmd:" $PROGRAM -c $CFG_DIR -f basicSuite.sim diff --git a/tests/tsim/inc/simInt.h b/tests/tsim/inc/simInt.h index 1e2190e308..a667139de1 100644 --- a/tests/tsim/inc/simInt.h +++ b/tests/tsim/inc/simInt.h @@ -155,6 +155,7 @@ extern int32_t simScriptSucced; extern int32_t simDebugFlag; extern char simScriptDir[]; extern bool abortExecution; +extern bool useMultiProcess; SScript *simParseScript(char *fileName); SScript *simProcessCallOver(SScript *script); diff --git a/tests/tsim/src/simExe.c b/tests/tsim/src/simExe.c index 855705e904..9a0b48197a 100644 --- a/tests/tsim/src/simExe.c +++ b/tests/tsim/src/simExe.c @@ -305,25 +305,24 @@ bool simExecuteRunBackCmd(SScript *script, char *option) { return true; } -void simReplaceShToBat(char *dst) { - char *sh = strstr(dst, ".sh"); - if (sh != NULL) { +void simReplaceStr(char *buf, char *src, char *dst) { + char *begin = strstr(buf, src); + if (begin != NULL) { + int32_t srcLen = (int32_t)strlen(src); int32_t dstLen = (int32_t)strlen(dst); - char *end = dst + dstLen; - *(end + 1) = 0; + int32_t interval = (dstLen - srcLen); + int32_t remainLen = (int32_t)strlen(buf); + char *end = buf + remainLen; + *(end + interval) = 0; - for (char *p = end; p >= sh; p--) { - *(p + 1) = *p; + for (char *p = end; p >= begin; p--) { + *(p + interval) = *p; } - sh[0] = '.'; - sh[1] = 'b'; - sh[2] = 'a'; - sh[3] = 't'; - sh[4] = ' '; + memcpy(begin, dst, dstLen); } - simDebug("system cmd is %s", dst); + simInfo("system cmd is %s", buf); } bool simExecuteSystemCmd(SScript *script, char *option) { @@ -334,9 +333,13 @@ bool simExecuteSystemCmd(SScript *script, char *option) { simVisuallizeOption(script, option, buf + strlen(buf)); #else sprintf(buf, "%s%s", simScriptDir, option); - simReplaceShToBat(buf); + simReplaceStr(buf, ".sh", ".bat"); #endif + if (useMultiProcess) { + simReplaceStr(buf, "deploy.sh", "deploy.sh -m"); + } + simLogSql(buf, true); int32_t code = system(buf); int32_t repeatTimes = 0; diff --git a/tests/tsim/src/simMain.c b/tests/tsim/src/simMain.c index b57299e752..8898f1b201 100644 --- a/tests/tsim/src/simMain.c +++ b/tests/tsim/src/simMain.c @@ -18,6 +18,7 @@ bool simExecSuccess = false; bool abortExecution = false; +bool useMultiProcess = false; void simHandleSignal(int32_t signo, void *sigInfo, void *context) { simSystemCleanUp(); @@ -32,6 +33,8 @@ int32_t main(int32_t argc, char *argv[]) { tstrncpy(configDir, argv[++i], 128); } else if (strcmp(argv[i], "-f") == 0 && i < argc - 1) { strcpy(scriptFile, argv[++i]); + } else if (strcmp(argv[i], "-m") == 0) { + useMultiProcess = true; } else { printf("usage: %s [options] \n", argv[0]); printf(" [-c config]: config directory, default is: %s\n", configDir); -- GitLab