Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
慢慢CG
TDengine
提交
abfb0b68
T
TDengine
项目概览
慢慢CG
/
TDengine
与 Fork 源项目一致
Fork自
taosdata / TDengine
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
abfb0b68
编写于
7月 09, 2020
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
change sim log format
上级
a1125ff6
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
39 addition
and
51 deletion
+39
-51
tests/tsim/inc/sim.h
tests/tsim/inc/sim.h
+6
-18
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+25
-25
tests/tsim/src/simMain.c
tests/tsim/src/simMain.c
+1
-1
tests/tsim/src/simSystem.c
tests/tsim/src/simSystem.c
+7
-7
未找到文件。
tests/tsim/inc/sim.h
浏览文件 @
abfb0b68
...
...
@@ -51,24 +51,12 @@
#define FAILED_POSTFIX ""
#endif
#define simError(...) \
if (simDebugFlag & DEBUG_ERROR) { \
taosPrintLog("ERROR SIM ", 255, __VA_ARGS__); \
}
#define simWarn(...) \
if (simDebugFlag & DEBUG_WARN) { \
taosPrintLog("WARN SIM ", simDebugFlag, __VA_ARGS__); \
}
#define simTrace(...) \
if (simDebugFlag & DEBUG_TRACE) { \
taosPrintLog("SIM ", simDebugFlag, __VA_ARGS__); \
}
#define simDump(x, y) \
if (simDebugFlag & DEBUG_DUMP) { \
taosDumpData(x, y); \
}
#define simPrint(...) \
{ taosPrintLog("SIM ", 255, __VA_ARGS__); }
#define simFatal(...) { if (simDebugFlag & DEBUG_FATAL) { taosPrintLog("SIM FATAL ", simDebugFlag, __VA_ARGS__); }}
#define simError(...) { if (simDebugFlag & DEBUG_ERROR) { taosPrintLog("SIM ERROR ", simDebugFlag, __VA_ARGS__); }}
#define simWarn(...) { if (simDebugFlag & DEBUG_WARN) { taosPrintLog("SIM WARN ", simDebugFlag, __VA_ARGS__); }}
#define simInfo(...) { if (simDebugFlag & DEBUG_INFO) { taosPrintLog("SIM INFO ", simDebugFlag, __VA_ARGS__); }}
#define simDebug(...) { if (simDebugFlag & DEBUG_DEBUG) { taosPrintLog("SIM DEBUG ", simDebugFlag, __VA_ARGS__); }}
#define simTrace(...) { if (simDebugFlag & DEBUG_TRACE) { taosPrintLog("SIM TRACE ", simDebugFlag, __VA_ARGS__); }}
enum
{
SIM_SCRIPT_TYPE_MAIN
,
SIM_SCRIPT_TYPE_BACKGROUND
};
...
...
tests/tsim/src/simExe.c
浏览文件 @
abfb0b68
...
...
@@ -75,7 +75,7 @@ char *simGetVariable(SScript *script, char *varName, int varLen) {
for
(
int
i
=
0
;
i
<
MAX_QUERY_ROW_NUM
;
++
i
)
{
if
(
strncmp
(
keyName
,
script
->
data
[
i
][
0
],
keyLen
)
==
0
)
{
sim
Trace
(
"script:%s, keyName:%s, keyValue:%s"
,
script
->
fileName
,
script
->
data
[
i
][
0
],
script
->
data
[
i
][
col
]);
sim
Debug
(
"script:%s, keyName:%s, keyValue:%s"
,
script
->
fileName
,
script
->
data
[
i
][
0
],
script
->
data
[
i
][
col
]);
return
script
->
data
[
i
][
col
];
}
}
...
...
@@ -90,7 +90,7 @@ char *simGetVariable(SScript *script, char *varName, int varLen) {
return
"null"
;
}
sim
Trace
(
"script:%s, data[%d][%d]=%s"
,
script
->
fileName
,
row
,
col
,
script
->
data
[
row
][
col
]);
sim
Debug
(
"script:%s, data[%d][%d]=%s"
,
script
->
fileName
,
row
,
col
,
script
->
data
[
row
][
col
]);
return
script
->
data
[
row
][
col
];
}
}
...
...
@@ -102,7 +102,7 @@ char *simGetVariable(SScript *script, char *varName, int varLen) {
}
if
(
strncmp
(
varName
,
var
->
varName
,
varLen
)
==
0
)
{
// if (strlen(var->varValue) != 0)
// sim
Trace
("script:%s, var:%s, value:%s", script->fileName,
// sim
Debug
("script:%s, var:%s, value:%s", script->fileName,
// var->varName, var->varValue);
return
var
->
varValue
;
}
...
...
@@ -240,7 +240,7 @@ bool simExecuteRunCmd(SScript *script, char *option) {
return
false
;
}
sim
Print
(
"script:%s, start to execute"
,
newScript
->
fileName
);
sim
Info
(
"script:%s, start to execute"
,
newScript
->
fileName
);
newScript
->
type
=
SIM_SCRIPT_TYPE_MAIN
;
simScriptPos
++
;
...
...
@@ -262,7 +262,7 @@ bool simExecuteRunBackCmd(SScript *script, char *option) {
sprintf
(
script
->
error
,
"lineNum:%d. parse file:%s error"
,
script
->
lines
[
script
->
linePos
].
lineNum
,
fileName
);
return
false
;
}
sim
Print
(
"script:%s, start to execute in background"
,
newScript
->
fileName
);
sim
Info
(
"script:%s, start to execute in background"
,
newScript
->
fileName
);
newScript
->
type
=
SIM_SCRIPT_TYPE_BACKGROUND
;
script
->
bgScripts
[
script
->
bgScriptLen
++
]
=
newScript
;
...
...
@@ -336,7 +336,7 @@ bool simExecutePrintCmd(SScript *script, char *rest) {
simVisuallizeOption
(
script
,
rest
,
buf
);
rest
=
buf
;
sim
Print
(
"script:%s, %s"
,
script
->
fileName
,
rest
);
sim
Info
(
"script:%s, %s"
,
script
->
fileName
,
rest
);
script
->
linePos
++
;
return
true
;
}
...
...
@@ -351,9 +351,9 @@ bool simExecuteSleepCmd(SScript *script, char *option) {
delta
=
atoi
(
option
);
if
(
delta
<=
0
)
delta
=
5
;
sim
Print
(
"script:%s, sleep %dms begin"
,
script
->
fileName
,
delta
);
sim
Info
(
"script:%s, sleep %dms begin"
,
script
->
fileName
,
delta
);
taosMsleep
(
delta
);
sim
Print
(
"script:%s, sleep %dms finished"
,
script
->
fileName
,
delta
);
sim
Info
(
"script:%s, sleep %dms finished"
,
script
->
fileName
,
delta
);
script
->
linePos
++
;
return
true
;
...
...
@@ -372,7 +372,7 @@ bool simExecuteReturnCmd(SScript *script, char *option) {
sprintf
(
script
->
error
,
"lineNum:%d. error return %s"
,
script
->
lines
[
script
->
linePos
].
lineNum
,
option
);
return
false
;
}
else
{
sim
Print
(
"script:%s, return cmd execute with:%d"
,
script
->
fileName
,
ret
);
sim
Info
(
"script:%s, return cmd execute with:%d"
,
script
->
fileName
,
ret
);
script
->
linePos
=
script
->
numOfLines
;
}
...
...
@@ -418,7 +418,7 @@ void simCloseRestFulConnect(SScript *script) {
void
simCloseNativeConnect
(
SScript
*
script
)
{
if
(
script
->
taos
==
NULL
)
return
;
sim
Trace
(
"script:%s, taos:%p closed"
,
script
->
fileName
,
script
->
taos
);
sim
Debug
(
"script:%s, taos:%p closed"
,
script
->
fileName
,
script
->
taos
);
taos_close
(
script
->
taos
);
taosMsleep
(
1200
);
...
...
@@ -468,7 +468,7 @@ int simParseHttpCommandResult(SScript *script, char *command) {
cJSON_Delete
(
root
);
return
retcode
;
}
else
{
sim
Trace
(
"script:%s, json:status:%s not equal to succ, but code is %d, response:%s"
,
script
->
fileName
,
sim
Debug
(
"script:%s, json:status:%s not equal to succ, but code is %d, response:%s"
,
script
->
fileName
,
status
->
valuestring
,
retcode
,
command
);
cJSON_Delete
(
root
);
return
0
;
...
...
@@ -568,10 +568,10 @@ bool simCreateRestFulConnect(SScript *script, char *user, char *pass) {
for
(
int
attempt
=
0
;
attempt
<
10
;
++
attempt
)
{
success
=
simExecuteRestFulCommand
(
script
,
command
)
==
0
;
if
(
!
success
)
{
sim
Trace
(
"script:%s, user:%s connect taosd failed:%s, attempt:%d"
,
script
->
fileName
,
user
,
taos_errstr
(
NULL
),
attempt
);
sim
Debug
(
"script:%s, user:%s connect taosd failed:%s, attempt:%d"
,
script
->
fileName
,
user
,
taos_errstr
(
NULL
),
attempt
);
taosMsleep
(
1000
);
}
else
{
sim
Trace
(
"script:%s, user:%s connect taosd successed, attempt:%d"
,
script
->
fileName
,
user
,
attempt
);
sim
Debug
(
"script:%s, user:%s connect taosd successed, attempt:%d"
,
script
->
fileName
,
user
,
attempt
);
break
;
}
}
...
...
@@ -581,7 +581,7 @@ bool simCreateRestFulConnect(SScript *script, char *user, char *pass) {
return
false
;
}
sim
Trace
(
"script:%s, connect taosd successed, auth:%p"
,
script
->
fileName
,
script
->
auth
);
sim
Debug
(
"script:%s, connect taosd successed, auth:%p"
,
script
->
fileName
,
script
->
auth
);
return
true
;
}
...
...
@@ -592,10 +592,10 @@ bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
for
(
int
attempt
=
0
;
attempt
<
10
;
++
attempt
)
{
taos
=
taos_connect
(
NULL
,
user
,
pass
,
NULL
,
tsDnodeShellPort
);
if
(
taos
==
NULL
)
{
sim
Trace
(
"script:%s, user:%s connect taosd failed:%s, attempt:%d"
,
script
->
fileName
,
user
,
taos_errstr
(
NULL
),
attempt
);
sim
Debug
(
"script:%s, user:%s connect taosd failed:%s, attempt:%d"
,
script
->
fileName
,
user
,
taos_errstr
(
NULL
),
attempt
);
taosMsleep
(
1000
);
}
else
{
sim
Trace
(
"script:%s, user:%s connect taosd successed, attempt:%d"
,
script
->
fileName
,
user
,
attempt
);
sim
Debug
(
"script:%s, user:%s connect taosd successed, attempt:%d"
,
script
->
fileName
,
user
,
attempt
);
break
;
}
}
...
...
@@ -606,7 +606,7 @@ bool simCreateNativeConnect(SScript *script, char *user, char *pass) {
}
script
->
taos
=
taos
;
sim
Trace
(
"script:%s, connect taosd successed, taos:%p"
,
script
->
fileName
,
taos
);
sim
Debug
(
"script:%s, connect taosd successed, taos:%p"
,
script
->
fileName
,
taos
);
return
true
;
}
...
...
@@ -643,11 +643,11 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
ret
=
taos_errno
(
pSql
);
if
(
ret
==
TSDB_CODE_MND_TABLE_ALREADY_EXIST
||
ret
==
TSDB_CODE_MND_DB_ALREADY_EXIST
)
{
sim
Trace
(
"script:%s, taos:%p, %s success, ret:%d:%s"
,
script
->
fileName
,
script
->
taos
,
rest
,
ret
,
tstrerror
(
ret
));
sim
Debug
(
"script:%s, taos:%p, %s success, ret:%d:%s"
,
script
->
fileName
,
script
->
taos
,
rest
,
ret
,
tstrerror
(
ret
));
ret
=
0
;
break
;
}
else
if
(
ret
!=
0
)
{
sim
Trace
(
"script:%s, taos:%p, %s failed, ret:%d:%s, error:%s"
,
sim
Debug
(
"script:%s, taos:%p, %s failed, ret:%d:%s, error:%s"
,
script
->
fileName
,
script
->
taos
,
rest
,
ret
,
tstrerror
(
ret
),
taos_errstr
(
pSql
));
if
(
line
->
errorJump
==
SQL_JUMP_TRUE
)
{
...
...
@@ -672,7 +672,7 @@ bool simExecuteNativeSqlCommand(SScript *script, char *rest, bool isSlow) {
int
num_fields
=
taos_field_count
(
pSql
);
if
(
num_fields
!=
0
)
{
if
(
pSql
==
NULL
)
{
sim
Trace
(
"script:%s, taos:%p, %s failed, result is null"
,
script
->
fileName
,
script
->
taos
,
rest
);
sim
Debug
(
"script:%s, taos:%p, %s failed, result is null"
,
script
->
fileName
,
script
->
taos
,
rest
);
if
(
line
->
errorJump
==
SQL_JUMP_TRUE
)
{
script
->
linePos
=
line
->
jump
;
return
true
;
...
...
@@ -794,11 +794,11 @@ bool simExecuteRestFulSqlCommand(SScript *script, char *rest) {
ret
=
simExecuteRestFulCommand
(
script
,
command
);
if
(
ret
==
TSDB_CODE_MND_TABLE_ALREADY_EXIST
||
ret
==
TSDB_CODE_MND_DB_ALREADY_EXIST
)
{
sim
Trace
(
"script:%s, taos:%p, %s success, ret:%d:%s"
,
script
->
fileName
,
script
->
taos
,
rest
,
ret
,
tstrerror
(
ret
));
sim
Debug
(
"script:%s, taos:%p, %s success, ret:%d:%s"
,
script
->
fileName
,
script
->
taos
,
rest
,
ret
,
tstrerror
(
ret
));
ret
=
0
;
break
;
}
else
if
(
ret
!=
0
)
{
sim
Trace
(
"script:%s, taos:%p, %s failed, ret:%d"
,
sim
Debug
(
"script:%s, taos:%p, %s failed, ret:%d"
,
script
->
fileName
,
script
->
taos
,
rest
,
ret
);
if
(
line
->
errorJump
==
SQL_JUMP_TRUE
)
{
...
...
@@ -827,7 +827,7 @@ bool simExecuteSqlImpCmd(SScript *script, char *rest, bool isSlow) {
simVisuallizeOption
(
script
,
rest
,
buf
);
rest
=
buf
;
sim
Trace
(
"script:%s, exec:%s"
,
script
->
fileName
,
rest
);
sim
Debug
(
"script:%s, exec:%s"
,
script
->
fileName
,
rest
);
strcpy
(
script
->
rows
,
"-1"
);
for
(
int
row
=
0
;
row
<
MAX_QUERY_ROW_NUM
;
++
row
)
{
for
(
int
col
=
0
;
col
<
MAX_QUERY_COL_NUM
;
++
col
)
{
...
...
@@ -883,7 +883,7 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
simVisuallizeOption
(
script
,
rest
,
buf
);
rest
=
buf
;
sim
Trace
(
"script:%s, exec:%s"
,
script
->
fileName
,
rest
);
sim
Debug
(
"script:%s, exec:%s"
,
script
->
fileName
,
rest
);
strcpy
(
script
->
rows
,
"-1"
);
for
(
int
row
=
0
;
row
<
MAX_QUERY_ROW_NUM
;
++
row
)
{
for
(
int
col
=
0
;
col
<
MAX_QUERY_COL_NUM
;
++
col
)
{
...
...
@@ -929,7 +929,7 @@ bool simExecuteSqlErrorCmd(SScript *script, char *rest) {
}
if
(
ret
!=
TSDB_CODE_SUCCESS
)
{
sim
Trace
(
"script:%s, taos:%p, %s execute, expect failed, so success, ret:%d:%s"
,
sim
Debug
(
"script:%s, taos:%p, %s execute, expect failed, so success, ret:%d:%s"
,
script
->
fileName
,
script
->
taos
,
rest
,
ret
,
tstrerror
(
ret
));
script
->
linePos
++
;
return
true
;
...
...
tests/tsim/src/simMain.c
浏览文件 @
abfb0b68
...
...
@@ -49,7 +49,7 @@ int main(int argc, char *argv[]) {
exit
(
1
);
}
sim
Print
(
"simulator is running ..."
);
sim
Info
(
"simulator is running ..."
);
signal
(
SIGINT
,
simHandleSignal
);
SScript
*
script
=
simParseScript
(
scriptFile
);
...
...
tests/tsim/src/simSystem.c
浏览文件 @
abfb0b68
...
...
@@ -71,7 +71,7 @@ char *simParseHostName(char *varName) {
}
sprintf
(
hostName
,
"'%s:%d'"
,
simHostName
,
port
);
//sim
Print
("hostName:%s", hostName);
//sim
Info
("hostName:%s", hostName);
return
hostName
;
}
...
...
@@ -102,20 +102,20 @@ void simFreeScript(SScript *script) {
SScript
*
simProcessCallOver
(
SScript
*
script
)
{
if
(
script
->
type
==
SIM_SCRIPT_TYPE_MAIN
)
{
if
(
script
->
killed
)
{
sim
Print
(
"script:"
FAILED_PREFIX
"%s"
FAILED_POSTFIX
", "
FAILED_PREFIX
sim
Info
(
"script:"
FAILED_PREFIX
"%s"
FAILED_POSTFIX
", "
FAILED_PREFIX
"failed"
FAILED_POSTFIX
", error:%s"
,
script
->
fileName
,
script
->
error
);
exit
(
-
1
);
}
else
{
sim
Print
(
"script:"
SUCCESS_PREFIX
"%s"
SUCCESS_POSTFIX
", "
SUCCESS_PREFIX
sim
Info
(
"script:"
SUCCESS_PREFIX
"%s"
SUCCESS_POSTFIX
", "
SUCCESS_PREFIX
"success"
SUCCESS_POSTFIX
,
script
->
fileName
);
simCloseTaosdConnect
(
script
);
simScriptSucced
++
;
simScriptPos
--
;
if
(
simScriptPos
==
-
1
)
{
sim
Print
(
"----------------------------------------------------------------------"
);
sim
Print
(
"Simulation Test Done, "
SUCCESS_PREFIX
"%d"
SUCCESS_POSTFIX
" Passed:
\n
"
,
simScriptSucced
);
sim
Info
(
"----------------------------------------------------------------------"
);
sim
Info
(
"Simulation Test Done, "
SUCCESS_PREFIX
"%d"
SUCCESS_POSTFIX
" Passed:
\n
"
,
simScriptSucced
);
exit
(
0
);
}
...
...
@@ -123,7 +123,7 @@ SScript *simProcessCallOver(SScript *script) {
return
simScriptList
[
simScriptPos
];
}
}
else
{
sim
Print
(
"script:%s, is stopped by main script"
,
script
->
fileName
);
sim
Info
(
"script:%s, is stopped by main script"
,
script
->
fileName
);
simFreeScript
(
script
);
return
NULL
;
}
...
...
@@ -143,7 +143,7 @@ void *simExecuteScript(void *inputScript) {
}
else
{
SCmdLine
*
line
=
&
script
->
lines
[
script
->
linePos
];
char
*
option
=
script
->
optionBuffer
+
line
->
optionOffset
;
sim
Trace
(
"script:%s, line:%d with option
\"
%s
\"
"
,
script
->
fileName
,
line
->
lineNum
,
option
);
sim
Debug
(
"script:%s, line:%d with option
\"
%s
\"
"
,
script
->
fileName
,
line
->
lineNum
,
option
);
SCommand
*
cmd
=
&
simCmdList
[
line
->
cmdno
];
int
ret
=
(
*
(
cmd
->
executeCmd
))(
script
,
option
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录