diff --git a/documentation20/cn/00.index/docs.md b/documentation20/cn/00.index/docs.md index 463e59d27fcfd944bfef751d427a85bdea8e5045..a48ea49f59ce3fbccf5370de2276692f8e367fe3 100644 --- a/documentation20/cn/00.index/docs.md +++ b/documentation20/cn/00.index/docs.md @@ -95,7 +95,7 @@ TDengine 是一个高效的存储、查询、分析时序大数据的平台, - [Grafana](/connections#grafana):获取并可视化保存在 TDengine 的数据 - [IDEA Database](https://www.taosdata.com/blog/2020/08/27/1767.html):通过 IDEA 数据库管理工具可视化使用 TDengine - [TDengineGUI](https://github.com/skye0207/TDengineGUI):基于 Electron 开发的跨平台 TDengine 图形化管理工具 -- [DataX](https://www.taosdata.com/blog/2021/10/26/3156.html):支持 TDeninge 和其他数据库之间进行数据迁移的工具 +- [DataX](https://www.taosdata.com/blog/2021/10/26/3156.html):支持 TDengine 和其他数据库之间进行数据迁移的工具 ## [TDengine 集群的安装、管理](/cluster) diff --git a/src/client/src/tscLocal.c b/src/client/src/tscLocal.c index b6c8b3de3f9b1b0d84f9b1ea5eecc496cf58ba0c..f648baa9744cf00545e3f96b736661dce6e958e0 100644 --- a/src/client/src/tscLocal.c +++ b/src/client/src/tscLocal.c @@ -385,7 +385,7 @@ static int32_t tscGetTableTagValue(SCreateBuilder *builder, char *result) { if (i == num_fields - 1) { if (fields[i].type == TSDB_DATA_TYPE_JSON) { - sprintf(result + strlen(result) - 1, "%s'", ")"); + sprintf(result + strlen(result) - 1, "'%s", ")"); } else { sprintf(result + strlen(result) - 1, "%s", ")"); } diff --git a/src/common/src/texpr.c b/src/common/src/texpr.c index fc8872ea70d7bb4e1b0496bc678ed2a5bacf13c2..2774d9e2fabd11a3fcb45d650dc696518d504501 100644 --- a/src/common/src/texpr.c +++ b/src/common/src/texpr.c @@ -1364,7 +1364,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { } char fraction[32] = {0}; NUM_TO_STRING(child->resultType, &child->pVal->i64, sizeof(fraction), fraction); - int32_t tsDigits = strlen(fraction); + int32_t tsDigits = (int32_t)strlen(fraction); if (tsDigits > TSDB_TIME_PRECISION_SEC_DIGITS && tsDigits != TSDB_TIME_PRECISION_MILLI_DIGITS && tsDigits != TSDB_TIME_PRECISION_MICRO_DIGITS && @@ -1444,7 +1444,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { if (child0->pVal->nType == TSDB_DATA_TYPE_BIGINT) { char fraction[32] = {0}; NUM_TO_STRING(child0->resultType, &child0->pVal->i64, sizeof(fraction), fraction); - int32_t tsDigits = strlen(fraction); + int32_t tsDigits = (int32_t)strlen(fraction); if (tsDigits > TSDB_TIME_PRECISION_SEC_DIGITS && tsDigits != TSDB_TIME_PRECISION_MILLI_DIGITS && tsDigits != TSDB_TIME_PRECISION_MICRO_DIGITS && @@ -1525,7 +1525,7 @@ int32_t exprValidateTimeNode(char *msgbuf, tExprNode *pExpr) { if (child[i]->pVal->nType == TSDB_DATA_TYPE_BIGINT) { char fraction[32] = {0}; NUM_TO_STRING(child[i]->resultType, &child[i]->pVal->i64, sizeof(fraction), fraction); - int32_t tsDigits = strlen(fraction); + int32_t tsDigits = (int32_t)strlen(fraction); if (tsDigits > TSDB_TIME_PRECISION_SEC_DIGITS && tsDigits != TSDB_TIME_PRECISION_MILLI_DIGITS && tsDigits != TSDB_TIME_PRECISION_MICRO_DIGITS && @@ -2234,7 +2234,7 @@ void convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec, i if (type == TSDB_DATA_TYPE_BINARY) { newColData = calloc(1, charLen + 1); memcpy(newColData, varDataVal(inputData), charLen); - taosParseTime(newColData, timeVal, charLen, timePrec, 0); + taosParseTime(newColData, timeVal, charLen, (int32_t)timePrec, 0); tfree(newColData); } else if (type == TSDB_DATA_TYPE_NCHAR) { newColData = calloc(1, charLen / TSDB_NCHAR_SIZE + 1); @@ -2245,7 +2245,7 @@ void convertStringToTimestamp(int16_t type, char *inputData, int64_t timePrec, i return; } newColData[len] = 0; - taosParseTime(newColData, timeVal, len + 1, timePrec, 0); + taosParseTime(newColData, timeVal, len + 1, (int32_t)timePrec, 0); tfree(newColData); } else { uError("input type should be binary/nchar string"); @@ -2304,7 +2304,7 @@ void vectorTimeFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numIn char fraction[20] = {0}; bool hasFraction = false; NUM_TO_STRING(pInputs[0].type, inputData[0], sizeof(fraction), fraction); - int32_t tsDigits = strlen(fraction); + int32_t tsDigits = (int32_t)strlen(fraction); char buf[64] = {0}; int64_t timeVal; @@ -2328,7 +2328,7 @@ void vectorTimeFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numIn int32_t len = (int32_t)strlen(buf); if (hasFraction) { - int32_t fracLen = strlen(fraction) + 1; + int32_t fracLen = (int32_t)strlen(fraction) + 1; char *tzInfo = strchr(buf, '+'); if (tzInfo) { memmove(tzInfo + fracLen, tzInfo, strlen(tzInfo)); @@ -2399,7 +2399,7 @@ void vectorTimeFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numIn char buf[20] = {0}; NUM_TO_STRING(TSDB_DATA_TYPE_BIGINT, &timeVal, sizeof(buf), buf); - int32_t tsDigits = strlen(buf); + int32_t tsDigits = (int32_t)strlen(buf); timeUnit = timeUnit * 1000 / factor; switch (timeUnit) { case 0: { /* 1u */ @@ -2572,7 +2572,7 @@ void vectorTimeFunc(int16_t functionId, tExprOperandInfo *pInputs, int32_t numIn } char buf[20] = {0}; NUM_TO_STRING(TSDB_DATA_TYPE_BIGINT, &timeVal[j], sizeof(buf), buf); - int32_t tsDigits = strlen(buf); + int32_t tsDigits = (int32_t)strlen(buf); if (tsDigits <= TSDB_TIME_PRECISION_SEC_DIGITS) { timeVal[j] = timeVal[j] * 1000000000; } else if (tsDigits == TSDB_TIME_PRECISION_MILLI_DIGITS) { diff --git a/src/kit/taos-tools b/src/kit/taos-tools index 14fb199c68ed7d32d616cd9be231b332ceae9911..e15409c5184167a96a9fe9ade026387073443d2f 160000 --- a/src/kit/taos-tools +++ b/src/kit/taos-tools @@ -1 +1 @@ -Subproject commit 14fb199c68ed7d32d616cd9be231b332ceae9911 +Subproject commit e15409c5184167a96a9fe9ade026387073443d2f diff --git a/src/query/src/qAggMain.c b/src/query/src/qAggMain.c index 6dd7f17f7f9f9dd67e6a28dbc8b9d5579600119c..1657070fcf07ec33ae98085c1101f93bf02ea732 100644 --- a/src/query/src/qAggMain.c +++ b/src/query/src/qAggMain.c @@ -5164,7 +5164,7 @@ static void copyRes(SQLFunctionCtx *pCtx, void *data, int32_t bytes) { char *tsOutput = pCtx->ptsOutputBuf; char *output = pCtx->pOutput; int32_t step = GET_FORWARD_DIRECTION_FACTOR(pCtx->param[3].i64); - char *tvp = data + (size * ((pCtx->param[3].i64 == TSDB_ORDER_ASC) ? 0 : len -1)); + char *tvp = (char*)data + (size * ((pCtx->param[3].i64 == TSDB_ORDER_ASC) ? 0 : len -1)); for (int32_t i = 0; i < len; ++i) { memcpy(tsOutput, tvp, sizeof(int64_t)); memcpy(output, tvp + sizeof(int64_t), bytes); @@ -5184,7 +5184,7 @@ static void copyRes(SQLFunctionCtx *pCtx, void *data, int32_t bytes) { pData[i] = pCtx->tagInfo.pTagCtxList[i]->pOutput; } - tvp = data + (size * ((pCtx->param[3].i64 == TSDB_ORDER_ASC) ? 0 : len -1)); + tvp = (char*)data + (size * ((pCtx->param[3].i64 == TSDB_ORDER_ASC) ? 0 : len -1)); for (int32_t i = 0; i < len; ++i) { int32_t offset = (int32_t)sizeof(int64_t) + bytes; for (int32_t j = 0; j < pCtx->tagInfo.numOfTagCols; ++j) { @@ -5596,7 +5596,7 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) { } // if(pCtx->stableQuery){ - GET_RES_INFO(pCtx)->numOfRes = pRes->num - pCtx->param[1].i64; + GET_RES_INFO(pCtx)->numOfRes = pRes->num - (int32_t)pCtx->param[1].i64; // }else{ // GET_RES_INFO(pCtx)->numOfRes = pRes->num; // } @@ -5611,7 +5611,7 @@ static void tail_func_finalizer(SQLFunctionCtx *pCtx) { return; } for(int32_t i = 0; i < GET_RES_INFO(pCtx)->numOfRes; i++){ - memcpy(data + i * size, pRes->res[i], size); + memcpy((char*)data + i * size, pRes->res[i], size); } SortSupporter support = {0}; diff --git a/tests/compatibility/init.sh b/tests/compatibility/init.sh new file mode 100755 index 0000000000000000000000000000000000000000..78002179871ba818fe79794abd40965140a46cd5 --- /dev/null +++ b/tests/compatibility/init.sh @@ -0,0 +1,118 @@ +#!/bin/bash + +function usage() { + echo "$0" + echo -e "\t -w work dir" + echo -e "\t -o old version package" + echo -e "\t -n new version package" + echo -e "\t -c client package" + echo -e "\t -h help" +} + +while getopts "w:o:n:c:h" opt; do + case $opt in + w) + WORK_DIR=$OPTARG + ;; + o) + TAOS_PKG1=$OPTARG + ;; + n) + TAOS_PKG2=$OPTARG + ;; + c) + CLIENT_PKG=$OPTARG + ;; + h) + usage + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" + usage + exit 0 + ;; + esac +done + +if [ -z "$WORK_DIR" ]; then + usage + exit 1 +fi +if [ -z "$TAOS_PKG1" ]; then + usage + exit 1 +fi +if [ -z "$TAOS_PKG2" ]; then + usage + exit 1 +fi +if [ ! -z "$CLIENT_PKG" ]; then + if [ ! -f "$CLIENT_PKG" ]; then + echo "$CLIENT_PKG not found" + exit 1 + fi +fi + +script_dir=`dirname $0` +cd $script_dir + +source settings.sh + +code_dir=$WORK_DIR/TDinternal +container_workdir1=$WORK_DIR/compatibility/$container_name1 +container_workdir2=$WORK_DIR/compatibility/$container_name2 +container_workdir3=$WORK_DIR/compatibility/$container_name3 +container_workdir4=$WORK_DIR/compatibility/$container_name4 + + +mkdir -p $container_workdir1 +mkdir -p $container_workdir2 +mkdir -p $container_workdir3 +mkdir -p $container_workdir4 + +docker rm -f $container_name1 >/dev/null 2>&1 +docker rm -f $container_name2 >/dev/null 2>&1 +docker rm -f $container_name3 >/dev/null 2>&1 +docker rm -f $container_name4 >/dev/null 2>&1 + +net_name=mynet +docker network create --driver bridge --subnet 172.31.30.0/24 --gateway 172.31.30.1 $net_name + +./init_container.sh -d $code_dir -w $container_workdir1 -p $TAOS_PKG1 -q $TAOS_PKG2 -n $net_name -c $container_name1 & +./init_container.sh -d $code_dir -w $container_workdir2 -p $TAOS_PKG1 -q $TAOS_PKG2 -n $net_name -c $container_name2 & +./init_container.sh -d $code_dir -w $container_workdir3 -p $TAOS_PKG1 -q $TAOS_PKG2 -n $net_name -c $container_name3 & +./init_container.sh -d $code_dir -w $container_workdir4 -p $TAOS_PKG1 -q $TAOS_PKG2 -n $net_name -c $container_name4 & + +RET=0 +pids=`jobs -p` +for pid in $pids; do + wait $pid + status=$? + if [ $status -ne 0 ]; then + echo "init container $pid status is $status!" + RET=$status + fi +done + +if [ $RET -eq 0 ]; then + if [ -z "$CLIENT_PKG" ]; then + docker exec $container_name4 pip3 install /home/TDinternal/community/src/connector/python + RET=$? + else + pkg_name=`basename $CLIENT_PKG` + pkg_dir=`echo "$pkg_name"|sed "s/-Linux-x64.tar.gz//"` + docker cp $CLIENT_PKG $container_name4:/home/ + docker exec $container_name4 sh -c "cd /home;tar xzf $pkg_name;if [ -d /home/$pkg_dir/connector/python/linux/python3 ]; then pip3 install /home/$pkg_dir/connector/python/linux/python3; else pip3 install /home/$pkg_dir/connector/python; fi" + RET=$? + fi +fi + +if [ $RET -eq 0 ]; then + echo "containers created" +else + echo "containers create failed" +fi + +exit $RET + diff --git a/tests/compatibility/init_container.sh b/tests/compatibility/init_container.sh new file mode 100755 index 0000000000000000000000000000000000000000..ce1f70fee2d0f3e5d215b1f2a579807f9a1ce55a --- /dev/null +++ b/tests/compatibility/init_container.sh @@ -0,0 +1,105 @@ +#!/bin/bash + +function usage() { + echo "$0" + echo -e "\t -w work dir" + echo -e "\t -d TDinternal code dir" + echo -e "\t -p old package" + echo -e "\t -q new package" + echo -e "\t -c container name" + echo -e "\t -h help" +} + +while getopts "w:p:q:n:c:d:h" opt; do + case $opt in + w) + WORK_DIR=$OPTARG + ;; + d) + CODE_DIR=$OPTARG + ;; + p) + TAOS_PKG1=$OPTARG + ;; + q) + TAOS_PKG2=$OPTARG + ;; + c) + CONTAINER_NAME=$OPTARG + ;; + n) + NET_NAME=$OPTARG + ;; + h) + usage + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" + usage + exit 0 + ;; + esac +done + +if [ -z "$WORK_DIR" ]; then + usage + exit 1 +fi +if [ -z "$TAOS_PKG1" ]; then + usage + exit 1 +fi +if [ -z "$TAOS_PKG2" ]; then + usage + exit 1 +fi +if [ -z "$CONTAINER_NAME" ]; then + usage + exit 1 +fi +if [ -z "$NET_NAME" ]; then + usage + exit 1 +fi +if [ -z "$CODE_DIR" ]; then + usage + exit 1 +fi +if [ ! -f "$TAOS_PKG1" ]; then + echo "$TAOS_PKG1 not found" + exit 1 +fi +if [ ! -f "$TAOS_PKG2" ]; then + echo "$TAOS_PKG2 not found" + exit 1 +fi + +pkg_name1=`basename $TAOS_PKG1` +pkg_dir1=`echo "$pkg_name1"|sed "s/-Linux-x64.tar.gz//"` +pkg_name2=`basename $TAOS_PKG2` +pkg_dir2=`echo "$pkg_name2"|sed "s/-Linux-x64.tar.gz//"` + +RET=0 +docker run -d --name $CONTAINER_NAME \ + --hostname $CONTAINER_NAME \ + --net $NET_NAME --ulimit core=-1 -it \ + -v $TAOS_PKG1:/home/tdengine1.tar.gz:ro \ + -v $TAOS_PKG2:/home/tdengine2.tar.gz:ro \ + -v $WORK_DIR/coredump:/home/coredump \ + -v $CODE_DIR:/home/TDinternal \ + taos_test:v1.0 bash +RET=$? +if [ $RET -ne 0 ]; then + echo "docker run failed with $RET" + exit $RET +fi + +docker exec $CONTAINER_NAME sh -c "cd /home;tar xzf tdengine1.tar.gz;tar xzf tdengine2.tar.gz;cd $pkg_dir1;./install.sh -v server -e no" +RET=$? +if [ $RET -ne 0 ]; then + echo "docker exec install.sh failed with $RET" + exit $RET +fi +exit 0 + diff --git a/tests/compatibility/run_test.sh b/tests/compatibility/run_test.sh new file mode 100755 index 0000000000000000000000000000000000000000..7f29b75886054f8552ad37d4728e9d943123452d --- /dev/null +++ b/tests/compatibility/run_test.sh @@ -0,0 +1,190 @@ +#!/bin/bash + +function usage() { + echo "$0" + echo -e "\t -w work dir" + echo -e "\t -o old package" + echo -e "\t -n new package" + echo -e "\t -c client package" + echo -e "\t -h help" +} + +while getopts "w:o:n:c:h" opt; do + case $opt in + w) + WORK_DIR=$OPTARG + ;; + o) + OLD_PACKAGE=$OPTARG + ;; + n) + NEW_PACKAGE=$OPTARG + ;; + c) + CLIENT_PACKAGE_PARAM="-c $OPTARG" + ;; + h) + usage + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" + usage + exit 0 + ;; + esac +done + +if [ -z "$WORK_DIR" ]; then + usage + exit 1 +fi +if [ -z "$OLD_PACKAGE" ]; then + usage + exit 1 +fi +if [ -z "$NEW_PACKAGE" ]; then + usage + exit 1 +fi + +script_dir=`dirname $0` +cd $script_dir + +pkg_name=`basename $NEW_PACKAGE` +new_version=`echo "$pkg_name"|sed "s/TDengine-enterprise-server-//"|sed "s/-Linux-x64.tar.gz//"` +pkg_name=`basename $OLD_PACKAGE` +old_version=`echo "$pkg_name"|sed "s/TDengine-enterprise-server-//"|sed "s/-Linux-x64.tar.gz//"` + +source settings.sh + +containers="$container_name1 $container_name2 $container_name3" + +# initialize all containers and install with old version package +./init.sh -w $WORK_DIR -o $OLD_PACKAGE -n $NEW_PACKAGE $CLIENT_PACKAGE_PARAM + +# upgrade with new version package +function upgrade() { + local container_name=$1 + local new_pkg_name=`basename $NEW_PACKAGE` + local new_pkg_dir=`echo "$new_pkg_name"|sed "s/-Linux-x64.tar.gz//"` + local ret=0 + echo "upgrade ${container_name}" + docker exec $container_name service taosd stop + ret=$? + if [ $ret -ne 0 ]; then + echo "docker exec $container_name service taosd stop, exit: $ret" + return $ret + fi + docker exec $container_name sh -c "cd /home/$new_pkg_dir;./install.sh -v server -e no" + ret=$? + if [ $ret -ne 0 ]; then + echo "docker exec $container_name install.sh, exit: $ret" + return $ret + fi + docker exec $container_name service taosd start + ret=$? + if [ $ret -ne 0 ]; then + echo "docker exec $container_name service taosd start, exit: $ret" + return $ret + fi + return 0 +} + +function checkStatus() { + local container_name=$1 + local check_version=$2 + echo "python3 manualTest/TD-5114/checkClusterStatus.py $container_name $check_version" + docker exec $container_name4 sh -c "cd /home/TDinternal/community/tests/pytest;python3 manualTest/TD-5114/checkClusterStatus.py $container_name $check_version" + return $? +} + +# config container /etc/taos/taos.cfg +taos_cfg=/etc/taos/taos.cfg +for container in $containers; do + docker exec $container sed -i "s/^.*firstEp.*$/firstEp $container_name1:6030/" $taos_cfg + docker exec $container sed -i "s/^.*fqdn.*$/fqdn $container/" $taos_cfg + docker exec $container sed -i "s/^.*numOfMnodes.*$/numOfMnodes 3/" $taos_cfg +done + +# start taosd +docker exec $container_name1 service taosd start +docker exec $container_name4 taos -h $container_name1 -s "CREATE DNODE \"$container_name2:6030\";" +docker exec $container_name4 taos -h $container_name1 -s "CREATE DNODE \"$container_name3:6030\";" + +# start taosd +docker exec $container_name2 service taosd start +docker exec $container_name3 service taosd start + +sleep 10 + +# show nodes +docker exec $container_name4 taos -h $container_name1 -s "SHOW DNODES;" +docker exec $container_name4 taos -h $container_name1 -s "SHOW MNODES;" + +# check cluster status +for container in $containers; do + checkStatus $container $old_version + RET=$? + if [ $RET -ne 0 ]; then + echo "check cluster status $container error: $RET" + exit $RET + fi + echo "check cluster status $container ret: $RET" +done + +sleep 1 + +# upgrade +upgrade ${container_name3} +RET=$? +if [ $RET -ne 0 ]; then + echo "upgrade ${container_name3} error: $RET" + exit $RET +fi +sleep 10 +# check cluster status +checkStatus ${container_name3} $old_version +RET=$? +if [ $RET -ne 0 ]; then + echo "check cluster status ${container_name3} error: $RET" + exit $RET +fi +echo "check cluster status ${container_name3} ret: $RET" + +# upgrade +upgrade ${container_name2} +RET=$? +if [ $RET -ne 0 ]; then + echo "upgrade ${container_name2} error: $RET" + exit $RET +fi +sleep 10 +# check cluster status +checkStatus ${container_name2} $old_version +RET=$? +if [ $RET -ne 0 ]; then + echo "check cluster status ${container_name2} error: $RET" + exit $RET +fi +echo "check cluster status ${container_name2} ret: $RET" + +# upgrade +upgrade ${container_name1} +RET=$? +if [ $RET -ne 0 ]; then + echo "upgrade ${container_name1} error: $RET" + exit $RET +fi +sleep 10 +# check cluster status +checkStatus ${container_name3} $new_version +RET=$? +if [ $RET -ne 0 ]; then + echo "check cluster status ${container_name3} error: $RET" + exit $RET +fi +echo "check cluster status ${container_name3} ret: $RET" + +exit $RET + diff --git a/tests/compatibility/settings.sh b/tests/compatibility/settings.sh new file mode 100644 index 0000000000000000000000000000000000000000..d11e9d19c24db1b0625eb6e511c1fe84d14e229d --- /dev/null +++ b/tests/compatibility/settings.sh @@ -0,0 +1,5 @@ + +container_name1=compat_container1 +container_name2=compat_container2 +container_name3=compat_container3 +container_name4=compat_container4 diff --git a/tests/parallel_test/arm.cases.task b/tests/parallel_test/arm.cases.task new file mode 100644 index 0000000000000000000000000000000000000000..b6441b6324f23c3b94bce5c7083776c82b3f8325 --- /dev/null +++ b/tests/parallel_test/arm.cases.task @@ -0,0 +1,19 @@ +4,,pytest,python3 test.py -f insert/double.py +4,,pytest,python3 test.py -f insert/date.py +4,,pytest,python3 test.py -f insert/bug3654.py +4,,pytest,python3 test.py -f insert/bool.py +4,,pytest,python3 test.py -f insert/bigint.py +4,,pytest,python3 test.py -f insert/basic.py +4,,pytest,python3 test.py -f insert/alterTableAndInsert.py +4,,pytest,python3 test.py -f import_merge/importHeadPartOverlap.py +4,,pytest,python3 test.py -f functions/function_stddev_td2555.py +4,,pytest,python3 test.py -f dbmgmt/nanoSecondCheck.py +4,,pytest,python3 bug2265.py +4,,pytest,python3 test.py -f alter/alterTabAddTagWithNULL.py +4,,pytest,python3 test.py -f alter/alter_debugFlag.py +4,,pytest,python3 test.py -f alter/alter_create_exception.py +3,,pytest,python3 test.py -f tag_lite/binary.py +3,,pytest,python3 test.py -f query/filterAllIntTypes.py +3,,develop-test,python3 ./test.py -f 2-query/ts_hidden_column.py +#3,,script,./test.sh -f general/compute/scalar_triangle.sim +3,,script,./test.sh -f general/compute/scalar_str_concat_len.sim diff --git a/tests/parallel_test/arm.json b/tests/parallel_test/arm.json new file mode 100644 index 0000000000000000000000000000000000000000..585c59647035cd5a4485fb86c07aa60986c657e5 --- /dev/null +++ b/tests/parallel_test/arm.json @@ -0,0 +1,12 @@ +[{ + "host":"192.168.1.207", + "username":"root", + "workdir":"/var/data/jenkins/workspace", + "thread":2 +}, +{ + "host":"192.168.1.204", + "username":"root", + "workdir":"/var/data/jenkins/workspace", + "thread":2 +}] diff --git a/tests/parallel_test/compat.json b/tests/parallel_test/compat.json new file mode 100644 index 0000000000000000000000000000000000000000..b932c2b3aeba82268a79eb7dd8edd5e222f3810b --- /dev/null +++ b/tests/parallel_test/compat.json @@ -0,0 +1,14 @@ +[ + { + "host": "192.168.0.38", + "username": "root", + "workdir": "/var/data/jenkins/workspace", + "thread": 10 + }, + { + "host": "192.168.0.39", + "username": "root", + "workdir": "/var/data/jenkins/workspace", + "thread": 10 + } +] diff --git a/tests/parallel_test/container_build.sh b/tests/parallel_test/container_build.sh new file mode 100755 index 0000000000000000000000000000000000000000..0873f6030ba1a9cb651add3eb06341edfeb9e606 --- /dev/null +++ b/tests/parallel_test/container_build.sh @@ -0,0 +1,51 @@ +#!/bin/bash + +function usage() { + echo "$0" + echo -e "\t -w work dir" + echo -e "\t -c community version" + echo -e "\t -t make thread count" + echo -e "\t -h help" +} + +while getopts "w:t:ch" opt; do + case $opt in + w) + WORKDIR=$OPTARG + ;; + c) + COMMUNITY=community + ;; + t) + THREAD_COUNT=$OPTARG + ;; + h) + usage + exit 0 + ;; + \?) + echo "Invalid option: -$OPTARG" + usage + exit 0 + ;; + esac +done + +if [ -z "$WORKDIR" ]; then + usage + exit 1 +fi +if [ -z "$THREAD_COUNT" ]; then + THREAD_COUNT=1 +fi + +ulimit -c unlimited + +INTERNAL_REPDIR=$WORKDIR/TDinternal + +docker run \ + -v $INTERNAL_REPDIR:/home \ + --rm --ulimit core=-1 taos_test:v1.0 sh -c "cd /home/$COMMUNITY;rm -rf debug;mkdir -p debug;cd debug;cmake .. -DBUILD_HTTP=false -DBUILD_TOOLS=true;make -j $THREAD_COUNT" + +ret=$? +exit $ret diff --git a/tests/parallel_test/run.sh b/tests/parallel_test/run.sh index 026bfb020d9a77d5cd1b05e9030cfce69a7ba4c7..a9263929f4a2d5abd6048d2d93114ebecd45c9a9 100755 --- a/tests/parallel_test/run.sh +++ b/tests/parallel_test/run.sh @@ -6,10 +6,11 @@ function usage() { echo -e "\t -t task file" echo -e "\t -b branch" echo -e "\t -l log dir" + echo -e "\t -o default timeout value" echo -e "\t -h help" } -while getopts "m:t:b:l:h" opt; do +while getopts "m:t:b:l:o:h" opt; do case $opt in m) config_file=$OPTARG @@ -23,6 +24,9 @@ while getopts "m:t:b:l:h" opt; do l) log_dir=$OPTARG ;; + o) + timeout_param="-o $OPTARG" + ;; h) usage exit 0 @@ -201,18 +205,21 @@ function run_thread() { if [ -z "$case_file" ]; then continue fi - case_file="$exec_dir/${case_file}.${index}.${thread_no}" + case_file="$exec_dir/${case_file}.${index}.${thread_no}.${count}" count=$(( count + 1 )) local case_path=`dirname "$case_file"` if [ ! -z "$case_path" ]; then mkdir -p $log_dir/$case_path fi - cmd="${runcase_script} ${script} -w ${workdirs[index]} -c \"${case_cmd}\" -t ${thread_no} -d ${exec_dir}" + cmd="${runcase_script} ${script} -w ${workdirs[index]} -c \"${case_cmd}\" -t ${thread_no} -d ${exec_dir} ${timeout_param}" # echo "$thread_no $count $cmd" local ret=0 local redo_count=1 start_time=`date +%s` while [ ${redo_count} -lt 6 ]; do + if [ -f $log_dir/$case_file.log ]; then + cp $log_dir/$case_file.log $log_dir/$case_file.${redo_count}.redolog + fi echo "${hosts[index]}-${thread_no} order:${count}, redo:${redo_count} task:${line}" >$log_dir/$case_file.log echo -e "\e[33m >>>>> \e[0m ${case_cmd}" date >>$log_dir/$case_file.log @@ -220,6 +227,7 @@ function run_thread() { # ret=${PIPESTATUS[0]} $cmd >>$log_dir/$case_file.log 2>&1 ret=$? + echo "${hosts[index]} `date` ret:${ret}" >>$log_dir/$case_file.log if [ $ret -eq 0 ]; then break fi diff --git a/tests/parallel_test/run_case.sh b/tests/parallel_test/run_case.sh index 5b7802ac2b346547e4d2cd171e93c1d5937a5360..50b8b5fcfe9a6b8afb3f6d2adfa1ff129c294559 100755 --- a/tests/parallel_test/run_case.sh +++ b/tests/parallel_test/run_case.sh @@ -1,18 +1,16 @@ #!/bin/bash CONTAINER_TESTDIR=/home/community -# CONTAINER_TESTDIR=/root/tang/repository/TDengine - -# export PATH=$PATH:$CONTAINER_TESTDIR/debug/build/bin function usage() { echo "$0" echo -e "\t -d execution dir" echo -e "\t -c command" + echo -e "\t -o default timeout value" echo -e "\t -h help" } -while getopts "d:c:h" opt; do +while getopts "d:c:o:h" opt; do case $opt in d) exec_dir=$OPTARG @@ -20,6 +18,9 @@ while getopts "d:c:h" opt; do c) cmd=$OPTARG ;; + o) + TIMEOUT_CMD="timeout $OPTARG" + ;; h) usage exit 0 @@ -41,29 +42,15 @@ if [ -z "$cmd" ]; then exit 0 fi -go env -w GOPROXY=https://goproxy.cn -echo "StrictHostKeyChecking no" >>/etc/ssh/ssh_config +export PATH=$PATH:/home/debug/build/bin ln -s /home/debug/build/lib/libtaos.so /usr/lib/libtaos.so 2>/dev/null -npm config -g set unsafe-perm -npm config -g set registry https://registry.npm.taobao.org mkdir -p /home/sim/tsim mkdir -p /var/lib/taos/subscribe -rm -rf ${CONTAINER_TESTDIR}/src/connector/nodejs/node_modules -rm -rf ${CONTAINER_TESTDIR}/tests/examples/nodejs/node_modules -rm -rf ${CONTAINER_TESTDIR}/tests/connectorTest/nodejsTest/nanosupport/node_modules -# ln -s /home/node_modules ${CONTAINER_TESTDIR}/src/connector/nodejs/ -# ln -s /home/node_modules ${CONTAINER_TESTDIR}/tests/examples/nodejs/ -# ln -s /home/node_modules ${CONTAINER_TESTDIR}/tests/connectorTest/nodejsTest/nanosupport/ -# echo "$cmd"|grep -q "nodejs" -# if [ $? -eq 0 ]; then -# cd $CONTAINER_TESTDIR/src/connector/nodejs -# npm install node-gyp-build@4.3.0 --ignore-scripts -# fi cd $CONTAINER_TESTDIR/tests/$exec_dir ulimit -c unlimited -$cmd +$TIMEOUT_CMD $cmd RET=$? if [ $RET -ne 0 ]; then diff --git a/tests/parallel_test/run_container.sh b/tests/parallel_test/run_container.sh index 35ef3ad5a72b8c44b4de3db3159830c54cd1a6a3..5c6751148a2a168934c9d155695bbf51ec01f77b 100755 --- a/tests/parallel_test/run_container.sh +++ b/tests/parallel_test/run_container.sh @@ -6,10 +6,11 @@ function usage() { echo -e "\t -d execution dir" echo -e "\t -c command" echo -e "\t -t thread number" + echo -e "\t -o default timeout value" echo -e "\t -h help" } -while getopts "w:d:c:t:h" opt; do +while getopts "w:d:c:t:o:h" opt; do case $opt in w) WORKDIR=$OPTARG @@ -23,6 +24,9 @@ while getopts "w:d:c:t:h" opt; do t) thread_no=$OPTARG ;; + o) + timeout_param="-o $OPTARG" + ;; h) usage exit 0 @@ -71,12 +75,6 @@ if [ ! -d "${TMP_DIR}/thread_volume/$thread_no/$exec_dir" ]; then fi MOUNT_DIR="$TMP_DIR/thread_volume/$thread_no/$exec_dir:$CONTAINER_TESTDIR/tests/$exec_dir" echo "$thread_no -> ${exec_dir}:$cmd" -echo "$cmd"|grep -q "nodejs" -if [ $? -eq 0 ]; then - MOUNT_NODE_MOD="-v $TMP_DIR/thread_volume/$thread_no/node_modules:${CONTAINER_TESTDIR}/src/connector/nodejs/node_modules \ --v $TMP_DIR/thread_volume/$thread_no/node_modules:${CONTAINER_TESTDIR}/tests/examples/nodejs/node_modules \ --v $TMP_DIR/thread_volume/$thread_no/node_modules:${CONTAINER_TESTDIR}/tests/connectorTest/nodejsTest/nanosupport/node_modules" -fi if [ -f "$REPDIR/src/plugins/taosadapter/example/config/taosadapter.toml" ]; then TAOSADAPTER_TOML="-v $REPDIR/src/plugins/taosadapter/example/config/taosadapter.toml:/etc/taos/taosadapter.toml:ro" fi @@ -99,9 +97,7 @@ docker run \ -v $REPDIR/README.md:$CONTAINER_TESTDIR/README.md:ro \ -v $REPDIR/src/connector/python/taos:/usr/local/lib/python3.8/site-packages/taos:ro \ -e LD_LIBRARY_PATH=/home/debug/build/lib:/home/debug/build/lib64 \ - -e PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/debug/build/bin:/usr/local/go/bin:/usr/local/node-v12.20.0-linux-x64/bin:/usr/local/apache-maven-3.8.4/bin:/usr/local/jdk1.8.0_144/bin \ - -e JAVA_HOME=/usr/local/jdk1.8.0_144 \ - --rm --ulimit core=-1 taos_test:v1.0 $CONTAINER_TESTDIR/tests/parallel_test/run_case.sh -d "$exec_dir" -c "$cmd" + --rm --ulimit core=-1 taos_test:v1.0 $CONTAINER_TESTDIR/tests/parallel_test/run_case.sh -d "$exec_dir" -c "$cmd" $timeout_param ret=$? exit $ret diff --git a/tests/pytest/manualTest/TD-5114/checkClusterStatus.py b/tests/pytest/manualTest/TD-5114/checkClusterStatus.py new file mode 100644 index 0000000000000000000000000000000000000000..c6bff305a5b3317d03a793c9634b1ea19b3b7217 --- /dev/null +++ b/tests/pytest/manualTest/TD-5114/checkClusterStatus.py @@ -0,0 +1,113 @@ +################################################################### +# Copyright (c) 2016 by TAOS Technologies, Inc. +# All rights reserved. +# +# This file is proprietary and confidential to TAOS Technologies. +# No part of this file may be reproduced, stored, transmitted, +# disclosed or used in any form or by any means other than as +# expressly provided by the written permission from Jianhui Tao +# +################################################################### + +# -*- coding: utf-8 -*- + +import os +import sys +sys.path.insert(0, os.getcwd()) +from util.log import * +from util.sql import * +from util.dnodes import * +import taos +import threading +import subprocess +import datetime +from random import choice + +class TwoClients: + def initConnection(self): + self.host = sys.argv[1] + self.user = "root" + self.password = "taosdata" + self.config = "/etc/taos/" + self.port =6030 + self.rowNum = 10 + self.ts = 1537146000000 + + def run(self): + + # new taos client + conn1 = taos.connect(host=self.host, user=self.user, password=self.password, config=self.config ) + cur1 = conn1.cursor() + print(cur1) + tdSql.init(cur1, True) + + # insert data with python connector , if you want to use this case ,cancel note. + + # check cluster status + tdSql.query("show dnodes") + print(tdSql.queryRows) + for i in range(tdSql.queryRows): + for j in range(1,tdSql.queryRows+1): + if (tdSql.queryResult[i][1] == "compat_container%d:6030" %j): + tdSql.checkData(i,4,"ready") + + tdSql.query("show mnodes") + tdSql.checkRows(3) + roles = "master slave" + for i in range(tdSql.queryRows): + if (tdSql.queryResult[i][2] in roles ): + ep = tdSql.queryResult[i][1] + role = tdSql.queryResult[i][2] + print(" the role of %s is %s " %(ep,role)) + else: + print("cluster is not ready") + + version = sys.argv[2] + tdSql.query("show variables") + for i in range(tdSql.queryRows): + if (tdSql.queryResult[i][0] == "version" ): + tdSql.checkData(i,1,"%s" % version) + + + + # for x in range(10): + dataType= [ "tinyint", "smallint", "int", "bigint", "float", "double", "bool", " binary(20)", "nchar(20)", "tinyint unsigned", "smallint unsigned", "int unsigned", "bigint unsigned"] + tdSql.execute("drop database if exists db1") + tdSql.execute("create database db1 keep 3650 replica 2 ") + tdSql.execute("use db1") + tdSql.execute('''create table test(ts timestamp, col0 tinyint, col1 tinyint, col2 smallint, col3 int, col4 bigint, col5 float, col6 double, + col7 bool, col8 binary(20), col9 nchar(20), col10 tinyint unsigned, col11 smallint unsigned, col12 int unsigned, col13 bigint unsigned) tags(loc nchar(3000), tag1 int)''') + print(datetime.datetime.now()) + rowNum1= 20 + for i in range(rowNum1): + tdSql.execute("alter table test add column col%d %s ;" %( i+14, choice(dataType)) ) + rowNum2= 20 + for i in range(rowNum2): + tdSql.execute("alter table test drop column col%d ;" %( i+14) ) + self.rowNum3 = 50 + self.rowNum4 = 100 + self.ts = 1537146000000 + for j in range(self.rowNum4): + tdSql.execute("create table test%d using test tags('beijing%d', 10)" % (j,j) ) + for i in range(self.rowNum3): + tdSql.execute("insert into test%d values(%d, %d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d)" + % (j, self.ts + i*1000, i + 1, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1)) + print(datetime.datetime.now()) + # check data correct + tdSql.execute("show databases") + tdSql.execute("use db1") + tdSql.query("select count (tbname) from test") + tdSql.checkData(0, 0, 100) + tdSql.query("select count (*) from test") + tdSql.checkData(0, 0, 5000) + + + # delete useless file + testcaseFilename = os.path.split(__file__)[-1] + os.system("rm -rf ./insert_res.txt") + os.system("rm -rf manualTest/TD-5114/%s.sql" % testcaseFilename ) + +clients = TwoClients() +clients.initConnection() +# clients.getBuildPath() +clients.run() \ No newline at end of file diff --git a/tests/pytest/table/create_db_from_normal_db.py b/tests/pytest/table/create_db_from_normal_db.py index 8b5182c3b16ca31b2bbf966df294e2c4e4c12ff3..ad21ebfac27c099e3b3f3013b47e52d8bf93af15 100644 --- a/tests/pytest/table/create_db_from_normal_db.py +++ b/tests/pytest/table/create_db_from_normal_db.py @@ -34,7 +34,26 @@ class TDTestCase: tdSql.execute("drop table if exists db.state2;") tdSql.execute("create table db.state2 (ts timestamp, c1 int) tags (t binary(20));") tdSql.query("create table db.test2 using db.state2 tags('tt');") - tdSql.error("create table db.test22 using db.test2 tags('tt');") + tdSql.error("create table db.test22 using db.test2 tags('tt');") + + # test case for TS-1289 + tdSql.execute("create database test") + tdSql.execute("use test") + tdSql.execute("create table `metrics` (`ts` TIMESTAMP,`value` DOUBLE) TAGS (`labels` JSON)") + tdSql.execute('''CREATE TABLE `t_eb22c740776471c56ed97eff4951eb41` USING `metrics` TAGS ('{"__name__":"node_exporter:memory:used:percent","datacenter":"cvte + ","hostname":"p-tdengine-s-002","instance":"10.21.46.53:9100","ipaddress":"10.21.46.53","job":"node","product":"Prometheus","productline":"INFRA + "}');''') + + tdSql.query("show create table t_eb22c740776471c56ed97eff4951eb41") + sql = tdSql.getData(0, 1) + tdSql.execute("drop table t_eb22c740776471c56ed97eff4951eb41") + tdSql.query("show tables") + tdSql.checkRows(0) + + tdSql.execute(sql) + tdSql.query("show tables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 't_eb22c740776471c56ed97eff4951eb41') def stop(self): tdSql.close() diff --git a/tests/pytest/tools/taosdumpTest2.py b/tests/pytest/tools/taosdumpTest2.py index 6258024de8729d799690515a7133c5d9aa04330e..c405d4c5c67611ff87bee69e87c79820237419cb 100644 --- a/tests/pytest/tools/taosdumpTest2.py +++ b/tests/pytest/tools/taosdumpTest2.py @@ -11,15 +11,19 @@ # -*- coding: utf-8 -*- +from logging.config import dictConfig import sys import os from util.log import * from util.cases import * from util.sql import * from util.dnodes import * +import string +import random -class TDTestCase: +class TDTestCase: + def init(self, conn, logSql): tdLog.debug("start to execute %s" % __file__) tdSql.init(conn.cursor(), logSql) @@ -44,6 +48,13 @@ class TDTestCase: break return buildPath + def generateString(self, length): + chars = string.ascii_uppercase + string.ascii_lowercase + v = "" + for i in range(length): + v += random.choice(chars) + return v + def run(self): tdSql.prepare() @@ -70,14 +81,14 @@ class TDTestCase: os.system("rm /tmp/*.sql") os.system("rm /tmp/*.avro*") os.system( - "%staosdump --databases db -o /tmp -B 16384" % + "%staosdump --databases db -o /tmp " % binPath) tdSql.execute("drop database db") tdSql.query("show databases") tdSql.checkRows(0) - os.system("%staosdump -i /tmp" % binPath) + os.system("%staosdump -i /tmp -y" % binPath) tdSql.query("show databases") tdSql.checkRows(1) @@ -89,7 +100,33 @@ class TDTestCase: tdSql.checkData(0, 0, 'st') tdSql.query("select count(*) from t1") - tdSql.checkData(0, 0, self.numberOfRecords) + tdSql.checkData(0, 0, self.numberOfRecords) + + # test case for TS-1225 + tdSql.execute("create database test") + tdSql.execute("use test") + tdSql.execute("create table stb(ts timestamp, c1 binary(16374), c2 binary(16374), c3 binary(16374)) tags(t1 nchar(256))") + tdSql.execute("insert into t1 using stb tags('t1') values(now, '%s', '%s', '%s')" % (self.generateString(16374), self.generateString(16374), self.generateString(16374))) + + os.system("rm /tmp/*.sql") + os.system("rm /tmp/*.avro*") + os.system("%staosdump -D test -o /tmp -y" % binPath) + + tdSql.execute("drop database test") + tdSql.query("show databases") + tdSql.checkRows(1) + + os.system("%staosdump -i /tmp -y" % binPath) + + tdSql.execute("use test") + tdSql.error("show vnodes '' ") + tdSql.query("show stables") + tdSql.checkRows(1) + tdSql.checkData(0, 0, 'stb') + + tdSql.query("select * from stb") + tdSql.checkRows(1) + os.system("rm -rf dump_result.txt") def stop(self): tdSql.close() diff --git a/tests/pytest/tools/taosdumpTestBenchmark.py b/tests/pytest/tools/taosdumpTestBenchmark.py index 63af4b62b5a84444dd97b3889b7e1115aeaabb7c..97dcf3e54bc972bceec4b250df690436fa3bbbc3 100644 --- a/tests/pytest/tools/taosdumpTestBenchmark.py +++ b/tests/pytest/tools/taosdumpTestBenchmark.py @@ -52,15 +52,15 @@ class TDTestCase: return buildPath def insert_data(self, tbname, ts_start, count): - pre_insert = "insert into %s values"%tbname + pre_insert = "insert into %s values" % tbname sql = pre_insert - tdLog.debug("doing insert table %s rows=%d ..."%(tbname, count)) + tdLog.debug("doing insert table %s rows=%d ..." % (tbname, count)) for i in range(count): - sql += " (%d,%d)"%(ts_start + i*1000, i) - if i >0 and i%30000 == 0: + sql += " (%d,%d)" % (ts_start + i * 1000, i) + if i > 0 and i % 30000 == 0: tdSql.execute(sql) sql = pre_insert - # end sql + # end sql if sql != pre_insert: tdSql.execute(sql) @@ -72,14 +72,14 @@ class TDTestCase: os.makedirs("./taosdumptest") else: os.system("rm -rf ./taosdumptest") - os.makedirs("./taosdumptest") + os.makedirs("./taosdumptest") for i in range(2): - if not os.path.exists("./taosdumptest/tmp%d"%i): - os.makedirs("./taosdumptest/tmp%d"%i) + if not os.path.exists("./taosdumptest/tmp%d" % i): + os.makedirs("./taosdumptest/tmp%d" % i) else: - os.system("rm -rf ./taosdumptest/tmp%d"%i) - os.makedirs("./taosdumptest/tmp%d"%i) + os.system("rm -rf ./taosdumptest/tmp%d" % i) + os.makedirs("./taosdumptest/tmp%d" % i) buildPath = self.getBuildPath() if (buildPath == ""): @@ -93,129 +93,179 @@ class TDTestCase: tdSql.execute("drop database if exists dp2") tdSql.execute("create database if not exists dp1") tdSql.execute("use dp1") - tdSql.execute('''create table st0(ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, - c7 bool, c8 binary(20), c9 nchar(20), c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned, c15 timestamp ) - tags(t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 bool, t8 binary(20), t9 nchar(20), t11 tinyint unsigned, + tdSql.execute( + '''create table st0(ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, + c7 bool, c8 binary(20), c9 nchar(20), c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned, c15 timestamp ) + tags(t1 tinyint, t2 smallint, t3 int, t4 bigint, t5 float, t6 double, t7 bool, t8 binary(20), t9 nchar(20), t11 tinyint unsigned, t12 smallint unsigned, t13 int unsigned, t14 bigint unsigned, t15 timestamp)''') - tdSql.execute('''create table st1(ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, + tdSql.execute( + '''create table st1(ts timestamp, c1 tinyint, c2 smallint, c3 int, c4 bigint, c5 float, c6 double, c7 bool, c8 binary(20), c9 nchar(20), c11 tinyint unsigned, c12 smallint unsigned, c13 int unsigned, c14 bigint unsigned, c15 timestamp ) tags(jtag json)''') - intData = [] + intData = [] floatData = [] rowNum = 10 tabNum = 10 ts = 1537146000000 for j in range(tabNum): - tdSql.execute("create table st0_%d using st0 tags( %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d);" - % (j, j + 1, j + 1, j + 1, j + 1, j + 0.1, j + 0.1, j % 2, j + 1, j + 1, j + 1, j + 1, j + 1, j + 1, ts)) + tdSql.execute( + "create table st0_%d using st0 tags( %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d);" % + (j, + j + + 1, + j + + 1, + j + + 1, + j + + 1, + j + + 0.1, + j + + 0.1, + j % + 2, + j + + 1, + j + + 1, + j + + 1, + j + + 1, + j + + 1, + j + + 1, + ts)) for i in range(rowNum): - tdSql.execute("insert into st0_%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d)" - % (j, ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, ts)) - intData.append(i + 1) - floatData.append(i + 0.1) + tdSql.execute( + "insert into st0_%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d)" % + (j, ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % + 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, ts)) + intData.append(i + 1) + floatData.append(i + 0.1) rowNum = 20 tabNum = 20 for j in range(tabNum): - tdSql.execute("create table st1_%d using st1 tags('{\"nv\":null,\"tea\":true,\"\":false,\" \":123%d,\"tea\":false}');" % (j, j + 1)) + tdSql.execute( + "create table st1_%d using st1 tags('{\"nv\":null,\"tea\":true,\"\":false,\" \":123%d,\"tea\":false}');" % + (j, j + 1)) for i in range(rowNum): - tdSql.execute("insert into st1_%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d)" - % (j, self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, self.ts)) - intData.append(i + 1) - floatData.append(i + 0.1) + tdSql.execute( + "insert into st1_%d values(%d, %d, %d, %d, %d, %f, %f, %d, 'taosdata%d', '涛思数据%d', %d, %d, %d, %d, %d)" % + (j, self.ts + i, i + 1, i + 1, i + 1, i + 1, i + 0.1, i + 0.1, i % + 2, i + 1, i + 1, i + 1, i + 1, i + 1, i + 1, self.ts)) + intData.append(i + 1) + floatData.append(i + 0.1) # os.system("%staosBenchmark -f tools/taosdump-insert-dp1.json -y " % binPath) - - # create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1 - # \stb3,include ctables stb3_0 and stb3_1 + # create db1 , three stables:stb0,include ctables stb0_0 \ stb0_1,stb1 include ctables stb1_0 and stb1_1 + # \stb3,include ctables stb3_0 and stb3_1 # create general three tables gt0 gt1 gt2 tdSql.execute("create database if not exists dp2") tdSql.execute("use dp2") - tdSql.execute("create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)") - tdSql.execute("create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) ") - tdSql.execute("insert into st0_0 values(1614218412000,8600,'R')(1614218422000,8600,'E')") - tdSql.execute("insert into st0_1 values(1614218413000,8601,'A')(1614218423000,8601,'D')") - tdSql.execute("create stable st1(ts timestamp, c11 float, c12 nchar(10)) tags(t1 int)") - tdSql.execute("create table st1_0 using st1 tags(0) st1_1 using st1 tags(1) ") - tdSql.execute("insert into st1_0 values(1614218412000,8610.1,'R')(1614218422000,8610.1,'E')") - tdSql.execute("insert into st1_1 values(1614218413000,8611.2,'A')(1614218423000,8611.1,'D')") - tdSql.execute("create stable st2(ts timestamp, c21 float, c22 nchar(10)) tags(t1 int)") - tdSql.execute("create table st20 using st2 tags(0) st21 using st2 tags(1) ") - tdSql.execute("insert into st20 values(1614218412000,8620.3,'R')(1614218422000,8620.3,'E')") - tdSql.execute("insert into st21 values(1614218413000,8621.4,'A')(1614218423000,8621.4,'D')") - tdSql.execute("create table if not exists gt0 (ts timestamp, c00 int, c01 float) ") - tdSql.execute("create table if not exists gt1 (ts timestamp, c10 int, c11 double) ") - tdSql.execute("create table if not exists gt2 (ts timestamp, c20 int, c21 float) ") + tdSql.execute( + "create stable st0(ts timestamp, c01 int, c02 nchar(10)) tags(t1 int)") + tdSql.execute( + "create table st0_0 using st0 tags(0) st0_1 using st0 tags(1) ") + tdSql.execute( + "insert into st0_0 values(1614218412000,8600,'R')(1614218422000,8600,'E')") + tdSql.execute( + "insert into st0_1 values(1614218413000,8601,'A')(1614218423000,8601,'D')") + tdSql.execute( + "create stable st1(ts timestamp, c11 float, c12 nchar(10)) tags(t1 int)") + tdSql.execute( + "create table st1_0 using st1 tags(0) st1_1 using st1 tags(1) ") + tdSql.execute( + "insert into st1_0 values(1614218412000,8610.1,'R')(1614218422000,8610.1,'E')") + tdSql.execute( + "insert into st1_1 values(1614218413000,8611.2,'A')(1614218423000,8611.1,'D')") + tdSql.execute( + "create stable st2(ts timestamp, c21 float, c22 nchar(10)) tags(t1 int)") + tdSql.execute( + "create table st20 using st2 tags(0) st21 using st2 tags(1) ") + tdSql.execute( + "insert into st20 values(1614218412000,8620.3,'R')(1614218422000,8620.3,'E')") + tdSql.execute( + "insert into st21 values(1614218413000,8621.4,'A')(1614218423000,8621.4,'D')") + tdSql.execute( + "create table if not exists gt0 (ts timestamp, c00 int, c01 float) ") + tdSql.execute( + "create table if not exists gt1 (ts timestamp, c10 int, c11 double) ") + tdSql.execute( + "create table if not exists gt2 (ts timestamp, c20 int, c21 float) ") tdSql.execute("insert into gt0 values(1614218412700,8637,78.86155)") - tdSql.execute("insert into gt1 values(1614218413800,8638,78.862020199)") + tdSql.execute( + "insert into gt1 values(1614218413800,8638,78.862020199)") tdSql.execute("insert into gt2 values(1614218413900,8639,78.863)") # self.insert_data("t", self.ts, 300*10000); # os.system("%staosBenchmark -f tools/taosdump-insert-dp2.json -y " % binPath) - - - # # taosdump data # os.system("%staosdump -o ./taosdumptest/tmp1 taosdump -h -ptaosdata -P 6030 -u root -o taosdumptest \ # -D dp1,dp3 -N -c /home/chr/TDinternal/community/sim/dnode1/cfg/taos.cfg -s -d deflate" % binPath) - os.system("%staosdump -o ./taosdumptest/tmp0 -D dp2,dp1 -T 8 -B 100000" % binPath) - os.system("%staosdump -o ./taosdumptest/tmp1 dp2 st0 st1_0 gt0 -T 8 -B 1000" % binPath) - - - #check taosdumptest/tmp0 + os.system( + "%staosdump -o ./taosdumptest/tmp0 -D dp2,dp1 -T 8" % + binPath) + os.system( + "%staosdump -o ./taosdumptest/tmp1 dp2 st0 st1_0 gt0 -T 8" % + binPath) + + # check taosdumptest/tmp0 tdSql.execute("drop database dp1") tdSql.execute("drop database dp2") os.system("%staosdump -i ./taosdumptest/tmp0 -T 8 " % binPath) tdSql.execute("reset query cache") - + tdSql.execute("use dp1") tdSql.query("show stables") tdSql.checkRows(3) for i in range(3): - for j in range(3): + for j in range(3): if j < 2: - if tdSql.queryResult[i][0] == 'st%d'%j: - tdSql.checkData(i, 4, (j+1)*10) + if tdSql.queryResult[i][0] == 'st%d' % j: + tdSql.checkData(i, 4, (j + 1) * 10) else: - if tdSql.queryResult[i][0] == 'st%d'%j: - tdSql.checkData(i, 4, 100002) + if tdSql.queryResult[i][0] == 'st%d' % j: + tdSql.checkData(i, 4, 100002) tdSql.query("select count(*) from st0") - tdSql.checkData(0, 0, 100) + tdSql.checkData(0, 0, 100) tdSql.query("select count(*) from st1") - tdSql.checkData(0, 0, 400) + tdSql.checkData(0, 0, 400) tdSql.query("select count(*) from st2") - tdSql.checkData(0, 0, 1000020) - + tdSql.checkData(0, 0, 1000020) tdSql.execute("use dp2") tdSql.query("show stables") tdSql.checkRows(3) for i in range(3): - for j in range(3): + for j in range(3): if j < 2: - if tdSql.queryResult[i][0] == 'st%d'%j: + if tdSql.queryResult[i][0] == 'st%d' % j: # print(i,"stb%d"%j) tdSql.checkData(i, 4, 2) else: - if tdSql.queryResult[i][0] == 'st%d'%j: + if tdSql.queryResult[i][0] == 'st%d' % j: tdSql.checkData(i, 4, 100002) tdSql.query("select count(*) from st0") - tdSql.checkData(0, 0, 4) + tdSql.checkData(0, 0, 4) tdSql.query("select count(*) from st1") - tdSql.checkData(0, 0, 4) + tdSql.checkData(0, 0, 4) tdSql.query("select count(*) from st2") - tdSql.checkData(0, 0, 1000024) + tdSql.checkData(0, 0, 1000024) tdSql.query("select ts from gt0") - tdSql.checkData(0,0,'2021-02-25 10:00:12.700') + tdSql.checkData(0, 0, '2021-02-25 10:00:12.700') tdSql.query("select c10 from gt1") tdSql.checkData(0, 0, 8638) tdSql.query("select c20 from gt2") tdSql.checkData(0, 0, 8639) - #check taosdumptest/tmp1 + # check taosdumptest/tmp1 tdSql.execute("drop database dp1") tdSql.execute("drop database dp2") - os.system("%staosdump -i ./taosdumptest/tmp1 -T 8 " % binPath) + os.system("%staosdump -i ./taosdumptest/tmp1 -T 8 " % binPath) tdSql.execute("reset query cache") tdSql.execute("use dp2") tdSql.query("show stables") @@ -223,14 +273,13 @@ class TDTestCase: tdSql.query("show tables") tdSql.checkRows(4) tdSql.query("select count(*) from st1_0") - tdSql.checkData(0,0,2) + tdSql.checkData(0, 0, 2) tdSql.query("select ts from gt0") - tdSql.checkData(0,0,'2021-02-25 10:00:12.700') + tdSql.checkData(0, 0, '2021-02-25 10:00:12.700') tdSql.error("use dp1") tdSql.error("select count(*) from st2_0") tdSql.error("select count(*) from gt2") - # #check taosdumptest/tmp2 # tdSql.execute("drop database dp1") # tdSql.execute("drop database dp2") @@ -250,10 +299,9 @@ class TDTestCase: # tdSql.error("select count(*) from gt1") # tdSql.error("use dp2") - # #check taosdumptest/tmp3 # tdSql.execute("drop database dp1") - # os.system("%staosdump -i ./taosdumptest/tmp3 -T 8 " % binPath) + # os.system("%staosdump -i ./taosdumptest/tmp3 -T 8 " % binPath) # tdSql.execute("use dp2") # tdSql.query("show stables") # tdSql.checkRows(2) @@ -269,7 +317,7 @@ class TDTestCase: # #check taosdumptest/tmp4 # tdSql.execute("drop database dp2") - # os.system("%staosdump -i ./taosdumptest/tmp4 -T 8 " % binPath) + # os.system("%staosdump -i ./taosdumptest/tmp4 -T 8 " % binPath) # tdSql.execute("use dp2") # tdSql.query("show stables") # tdSql.checkRows(2) @@ -290,10 +338,9 @@ class TDTestCase: # tdSql.error("select count(*) from st1_1") # tdSql.error("select count(*) from gt3") - # #check taosdumptest/tmp5 # tdSql.execute("drop database dp2") - # os.system("%staosdump -i ./taosdumptest/tmp5 -T 8 " % binPath) + # os.system("%staosdump -i ./taosdumptest/tmp5 -T 8 " % binPath) # tdSql.execute("use dp2") # tdSql.query("show stables") # tdSql.checkRows(3) @@ -330,7 +377,7 @@ class TDTestCase: # tdSql.execute("drop database dp1") # tdSql.execute("drop database dp2") # tdSql.execute("drop database dp3") - # os.system("%staosdump -i ./taosdumptest/tmp6 -T 8 " % binPath) + # os.system("%staosdump -i ./taosdumptest/tmp6 -T 8 " % binPath) # tdSql.execute("use dp3") # tdSql.query("show databases") # tdSql.checkRows(1) @@ -340,14 +387,14 @@ class TDTestCase: # tdSql.query("show tables") # tdSql.checkRows(1) # tdSql.query("select count(*) from st0_0") - # tdSql.checkData(0, 0, 2) + # tdSql.checkData(0, 0, 2) # tdSql.query("select * from st0 order by ts") # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001') # tdSql.checkData(0,1,8600) # # check taosdumptest/tmp7 # tdSql.execute("drop database dp3") - # os.system("%staosdump -i ./taosdumptest/tmp7 -T 8 " % binPath) + # os.system("%staosdump -i ./taosdumptest/tmp7 -T 8 " % binPath) # tdSql.execute("use dp3") # tdSql.query("show databases") # tdSql.checkRows(1) @@ -364,14 +411,14 @@ class TDTestCase: # # check taosdumptest/tmp8 # tdSql.execute("drop database dp3") - # os.system("%staosdump -i ./taosdumptest/tmp8 -T 8 " % binPath) + # os.system("%staosdump -i ./taosdumptest/tmp8 -T 8 " % binPath) # tdSql.execute("use dp3") # tdSql.query("show stables") # tdSql.checkRows(1) # tdSql.query("show tables") # tdSql.checkRows(1) # tdSql.query("select count(*) from st0_0") - # tdSql.checkRows(0) + # tdSql.checkRows(0) # # tdSql.query("select * from st0 order by ts") # # tdSql.checkData(0,0,'2021-02-25 10:00:12.000000001') # # tdSql.checkData(0,1,8600)