From d858b26939c528a46454d338e791deeec1656708 Mon Sep 17 00:00:00 2001 From: slzhou Date: Fri, 22 Sep 2023 13:34:14 +0800 Subject: [PATCH] enhance: add bi mode to script --- tests/parallel_test/cases.task | 1 + tests/script/tsim/query/bi_star_table.sim | 29 +++++++++++++++++++++++ utils/tsim/inc/simInt.h | 2 ++ utils/tsim/src/simExe.c | 20 ++++++++++++++++ utils/tsim/src/simParse.c | 27 +++++++++++++++++++++ 5 files changed, 79 insertions(+) create mode 100644 tests/script/tsim/query/bi_star_table.sim diff --git a/tests/parallel_test/cases.task b/tests/parallel_test/cases.task index 1d90cb12ad..af0c5dcd51 100644 --- a/tests/parallel_test/cases.task +++ b/tests/parallel_test/cases.task @@ -1011,6 +1011,7 @@ ,,y,script,./test.sh -f tsim/query/partitionby.sim ,,y,script,./test.sh -f tsim/query/tableCount.sim ,,y,script,./test.sh -f tsim/query/show_db_table_kind.sim +,,y,script,./test.sh -f tsim/query/bi_star_tbname.sim ,,y,script,./test.sh -f tsim/query/tag_scan.sim ,,y,script,./test.sh -f tsim/query/nullColSma.sim ,,y,script,./test.sh -f tsim/query/bug3398.sim diff --git a/tests/script/tsim/query/bi_star_table.sim b/tests/script/tsim/query/bi_star_table.sim new file mode 100644 index 0000000000..5112ae3839 --- /dev/null +++ b/tests/script/tsim/query/bi_star_table.sim @@ -0,0 +1,29 @@ +system sh/stop_dnodes.sh +system sh/deploy.sh -n dnode1 -i 1 +system sh/exec.sh -n dnode1 -s start +sql connect + +sql drop database if exists db1; +sql create database db1 vgroups 3; +sql create database db1; +sql use db1; +sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create stable stb (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create table tba1 using sta tags(1, 1, 1); +sql create table tba2 using sta tags(2, 2, 2); +sql insert into tba1 values(now, 1, "1"); +sql insert into tba2 values(now + 1s, 2, "2"); +sql create table tbn1 (ts timestamp, f1 int); +sql create database db2 vgroups 3; +sql create database db2; +sql use db2; +sql create stable sta (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create stable stb (ts timestamp, f1 int, f2 binary(200)) tags(t1 int, t2 int, t3 int); +sql create table tba1 using sta tags(1, 1, 1); +sql create table tba2 using sta tags(2, 2, 2); + +set_bi_mode 1 +sql select * from db1.sta; +print $rows +print $data00 $data01 $data02 $data03 $data04 $data05 $data06 +system sh/exec.sh -n dnode1 -s stop -x SIGINT diff --git a/utils/tsim/inc/simInt.h b/utils/tsim/inc/simInt.h index 8ff3f3b183..fb92c18a5a 100644 --- a/utils/tsim/inc/simInt.h +++ b/utils/tsim/inc/simInt.h @@ -123,6 +123,7 @@ enum { SIM_CMD_RETURN, SIM_CMD_LINE_INSERT, SIM_CMD_LINE_INSERT_ERROR, + SIM_CMD_SET_BI_MODE, SIM_CMD_END }; @@ -210,6 +211,7 @@ bool simExecuteSqlSlowCmd(SScript *script, char *option); bool simExecuteRestfulCmd(SScript *script, char *rest); bool simExecuteLineInsertCmd(SScript *script, char *option); bool simExecuteLineInsertErrorCmd(SScript *script, char *option); +bool simExecuteSetBIModeCmd(SScript *script, char *option); void simVisuallizeOption(SScript *script, char *src, char *dst); #endif /*_TD_SIM_INT_H_*/ diff --git a/utils/tsim/src/simExe.c b/utils/tsim/src/simExe.c index 9a0a156717..4fd218bd14 100644 --- a/utils/tsim/src/simExe.c +++ b/utils/tsim/src/simExe.c @@ -502,6 +502,26 @@ bool simExecuteSystemContentCmd(SScript *script, char *option) { return true; } +bool simExecuteSetBIModeCmd(SScript *script, char *option) { + char buf[1024]; + + simVisuallizeOption(script, option, buf); + option = buf; + + int32_t mode = atoi(option); + + simInfo("script:%s, set bi mode %d", script->fileName, mode); + + if (mode != 0) { + taos_set_conn_mode(script->taos, TAOS_CONN_MODE_BI, 1); + } else { + taos_set_conn_mode(script->taos, TAOS_CONN_MODE_BI, 0); + } + + script->linePos++; + return true; +} + bool simExecutePrintCmd(SScript *script, char *rest) { char buf[65536]; diff --git a/utils/tsim/src/simParse.c b/utils/tsim/src/simParse.c index cdd918ac00..fbaf08bf3b 100644 --- a/utils/tsim/src/simParse.c +++ b/utils/tsim/src/simParse.c @@ -745,6 +745,25 @@ bool simParseSystemContentCmd(char *rest, SCommand *pCmd, int32_t lineNum) { return true; } +bool simParseSetBIModeCmd(char *rest, SCommand *pCmd, int32_t lineNum) { + char *token; + int32_t tokenLen; + + cmdLine[numOfLines].cmdno = SIM_CMD_SET_BI_MODE; + cmdLine[numOfLines].lineNum = lineNum; + + paGetToken(rest, &token, &tokenLen); + if (tokenLen > 0) { + cmdLine[numOfLines].optionOffset = optionOffset; + memcpy(optionBuffer + optionOffset, token, tokenLen); + optionOffset += tokenLen + 1; + *(optionBuffer + optionOffset - 1) = 0; + } + + numOfLines++; + return true; +} + bool simParseSleepCmd(char *rest, SCommand *pCmd, int32_t lineNum) { char *token; int32_t tokenLen; @@ -1074,6 +1093,14 @@ void simInitsimCmdList() { simCmdList[cmdno].executeCmd = simExecuteReturnCmd; simAddCmdIntoHash(&(simCmdList[cmdno])); + cmdno = SIM_CMD_SET_BI_MODE; + simCmdList[cmdno].cmdno = cmdno; + strcpy(simCmdList[cmdno].name, "set_bi_mode"); + simCmdList[cmdno].nlen = (int16_t)strlen(simCmdList[cmdno].name); + simCmdList[cmdno].parseCmd = simParseSetBIModeCmd; + simCmdList[cmdno].executeCmd = simExecuteSetBIModeCmd; + simAddCmdIntoHash(&(simCmdList[cmdno])); + #if 0 cmdno = SIM_CMD_LINE_INSERT; simCmdList[cmdno].cmdno = cmdno;