Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
595d2ce3
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
595d2ce3
编写于
4月 18, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: support variables like $data[0][1] and $data(db)[0] in tsim scripts
上级
7d8e418d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
92 addition
and
30 deletion
+92
-30
tests/script/tsim/db/alter_option.sim
tests/script/tsim/db/alter_option.sim
+1
-1
tests/script/tsim/db/basic6.sim
tests/script/tsim/db/basic6.sim
+0
-1
tests/script/tsim/user/basic1.sim
tests/script/tsim/user/basic1.sim
+19
-19
tests/tsim/inc/simInt.h
tests/tsim/inc/simInt.h
+2
-2
tests/tsim/src/simExe.c
tests/tsim/src/simExe.c
+70
-7
未找到文件。
tests/script/tsim/db/alter_option.sim
浏览文件 @
595d2ce3
...
...
@@ -72,7 +72,7 @@ print rows: $rows
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
print $data10 $data11 $data12 $data13 $data14 $data15 $data16 $data17 $data18 $data19
print ====> dataX_db
print $data
0_db $data1_db
$data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
print $data
(db)[0] $data(db)[1]
$data2_db $data3_db $data4_db $data5_db $data6_db $data7_db $data8_db $data9_db $data10_db $data11_db $data12_db $data13_db $data14_db $data15_db $data16_db $data17_db
if $rows != 3 then
return -1
...
...
tests/script/tsim/db/basic6.sim
浏览文件 @
595d2ce3
...
...
@@ -17,7 +17,6 @@ print =============== step1
# quorum presicion
sql create database $db vgroups 8 replica 1 days 2880 keep 3650 cache 32 blocks 12 minrows 80 maxrows 10000 wal 2 fsync 1000 comp 0 cachelast 2 precision 'us'
sql show databases
print $data0_1 $data1_1 $data2_1 $data3_1 $data4_1 $data5_1 $data6_1 $data7_1 $data8_1 $data9_1
print $data00 $data01 $data02 $data03 $data04 $data05 $data06 $data07 $data08 $data09
if $rows != 3 then
...
...
tests/script/tsim/user/basic1.sim
浏览文件 @
595d2ce3
...
...
@@ -9,9 +9,9 @@ if $rows != 1 then
return -1
endi
print $data
00 $data01 $data02
print $data
10 $data11 $data22
print $data
20 $data11 $data22
print $data
[0][0] $data[0][1] $data[0][2]
print $data
[1][0] $data[1][1] $data[1][2]
print $data
[2][0] $data[1][2] $data[2][2]
sql_error show accounts;
sql_error create account a pass "a"
...
...
@@ -25,10 +25,10 @@ if $rows != 2 then
return -1
endi
print $data
00 $data01 $data02
print $data
10 $data11 $data12
print $data
20 $data11 $data22
print $data
30 $data31 $data32
print $data
[0][0] $data[0][1] $data[0][2]
print $data
[1][0] $data[1][1] $data[1][2]
print $data
[2][0] $data[1][2] $data[2][2]
print $data
[3][0] $data[3][1] $data[3][2]
print =============== create user2
sql create user user2 PASS 'user2'
...
...
@@ -37,10 +37,10 @@ if $rows != 3 then
return -1
endi
print $data
00 $data01 $data02
print $data
10 $data11 $data12
print $data
20 $data11 $data22
print $data
30 $data31 $data32
print $data
[0][0] $data[0][1] $data[0][2]
print $data
[1][0] $data[1][1] $data[1][2]
print $data
[2][0] $data[1][2] $data[2][2]
print $data
[3][0] $data[3][1] $data[3][2]
print $data40 $data41 $data42
print =============== drop user1
...
...
@@ -50,10 +50,10 @@ if $rows != 2 then
return -1
endi
print $data
00 $data01 $data02
print $data
10 $data11 $data22
print $data
20 $data11 $data22
print $data
30 $data31 $data32
print $data
[0][0] $data[0][1] $data[0][2]
print $data
[1][0] $data[1][1] $data[1][2]
print $data
[2][0] $data[1][2] $data[2][2]
print $data
[3][0] $data[3][1] $data[3][2]
print =============== restart taosd
system sh/exec.sh -n dnode1 -s stop
...
...
@@ -66,9 +66,9 @@ if $rows != 2 then
return -1
endi
print $data
00 $data01 $data02
print $data
10 $data11 $data22
print $data
20 $data11 $data22
print $data
30 $data31 $data32
print $data
[0][0] $data[0][1] $data[0][2]
print $data
[1][0] $data[1][1] $data[1][2]
print $data
[2][0] $data[1][2] $data[2][2]
print $data
[3][0] $data[3][1] $data[3][2]
system sh/exec.sh -n dnode1 -s stop -x SIGINT
tests/tsim/inc/simInt.h
浏览文件 @
595d2ce3
...
...
@@ -34,8 +34,8 @@
#define MAX_FILE_NAME_LEN 256
#define MAX_ERROR_LEN 1024
#define MAX_QUERY_VALUE_LEN 40
#define MAX_QUERY_COL_NUM
2
0
#define MAX_QUERY_ROW_NUM
2
0
#define MAX_QUERY_COL_NUM
10
0
#define MAX_QUERY_ROW_NUM
10
0
#define MAX_SYSTEM_RESULT_LEN 2048
#define MAX_VAR_LEN 100
#define MAX_VAR_NAME_LEN 32
...
...
tests/tsim/src/simExe.c
浏览文件 @
595d2ce3
...
...
@@ -18,7 +18,7 @@
void
simLogSql
(
char
*
sql
,
bool
useSharp
)
{
static
TdFilePtr
pFile
=
NULL
;
char
filename
[
256
];
char
filename
[
256
];
sprintf
(
filename
,
"%s/sim.sql"
,
simScriptDir
);
if
(
pFile
==
NULL
)
{
// fp = fopen(filename, "w");
...
...
@@ -49,6 +49,41 @@ char *simParseHostName(char *varName) {
return
hostName
;
}
static
void
simFindFirstNum
(
const
char
*
begin
,
int32_t
beginLen
,
int32_t
*
num
)
{
if
(
beginLen
<=
5
)
{
*
num
=
0
;
}
else
{
*
num
=
atoi
(
begin
+
5
);
}
}
static
void
simFindSecondNum
(
const
char
*
begin
,
int32_t
beginLen
,
int32_t
*
num
)
{
const
char
*
number
=
strstr
(
begin
,
"]["
);
if
(
number
==
NULL
)
{
*
num
=
0
;
}
else
{
*
num
=
atoi
(
number
+
2
);
}
}
static
void
simFindFirstKeyVal
(
const
char
*
begin
,
int32_t
beginLen
,
char
*
key
,
int32_t
keyLen
)
{
key
[
0
]
=
0
;
for
(
int32_t
i
=
5
;
i
<
beginLen
&&
i
-
5
<
keyLen
;
++
i
)
{
if
(
begin
[
i
]
!=
0
&&
begin
[
i
]
!=
']'
&&
begin
[
i
]
!=
')'
)
{
key
[
i
-
5
]
=
begin
[
i
];
}
}
}
static
void
simFindSecondKeyNum
(
const
char
*
begin
,
int32_t
beginLen
,
int32_t
*
num
)
{
const
char
*
number
=
strstr
(
begin
,
")["
);
if
(
number
==
NULL
)
{
*
num
=
0
;
}
else
{
*
num
=
atoi
(
number
+
2
);
}
}
char
*
simGetVariable
(
SScript
*
script
,
char
*
varName
,
int32_t
varLen
)
{
if
(
strncmp
(
varName
,
"hostname"
,
8
)
==
0
)
{
return
simParseHostName
(
varName
);
...
...
@@ -66,13 +101,40 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
if
(
strncmp
(
varName
,
"system_content"
,
varLen
)
==
0
)
return
script
->
system_ret_content
;
// variable like data2_192.168.0.1
if
(
strncmp
(
varName
,
"data"
,
4
)
==
0
)
{
if
(
varLen
<
6
)
{
return
"null"
;
}
if
(
varName
[
5
]
==
'_'
)
{
int32_t
row
=
0
;
int32_t
col
=
0
;
char
keyVal
[
1024
]
=
{
0
};
int32_t
keyLen
=
1024
;
if
(
varName
[
4
]
==
'['
)
{
// $data[0][1]
simFindFirstNum
(
varName
,
varLen
,
&
row
);
simFindSecondNum
(
varName
,
varLen
,
&
col
);
if
(
row
<
0
||
row
>=
MAX_QUERY_ROW_NUM
)
{
return
"null"
;
}
if
(
col
<
0
||
col
>=
MAX_QUERY_COL_NUM
)
{
return
"null"
;
}
simDebug
(
"script:%s, data[%d][%d]=%s"
,
script
->
fileName
,
row
,
col
,
script
->
data
[
row
][
col
]);
return
script
->
data
[
row
][
col
];
}
else
if
(
varName
[
4
]
==
'('
)
{
// $data(db)[0]
simFindFirstKeyVal
(
varName
,
varLen
,
keyVal
,
keyLen
);
simFindSecondKeyNum
(
varName
,
varLen
,
&
col
);
for
(
int32_t
i
=
0
;
i
<
MAX_QUERY_ROW_NUM
;
++
i
)
{
if
(
strncmp
(
keyVal
,
script
->
data
[
i
][
0
],
keyLen
)
==
0
)
{
simDebug
(
"script:%s, keyName:%s, keyValue:%s"
,
script
->
fileName
,
script
->
data
[
i
][
0
],
script
->
data
[
i
][
col
]);
return
script
->
data
[
i
][
col
];
}
}
}
else
if
(
varName
[
5
]
==
'_'
)
{
// data2_db
int32_t
col
=
varName
[
4
]
-
'0'
;
if
(
col
<
0
||
col
>=
MAX_QUERY_COL_NUM
)
{
return
"null"
;
...
...
@@ -90,6 +152,7 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
}
return
"null"
;
}
else
if
(
varName
[
6
]
==
'_'
)
{
// data21_db
int32_t
col
=
(
varName
[
4
]
-
'0'
)
*
10
+
(
varName
[
5
]
-
'0'
);
if
(
col
<
0
||
col
>=
MAX_QUERY_COL_NUM
)
{
return
"null"
;
...
...
@@ -107,6 +170,7 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
}
return
"null"
;
}
else
{
// $data00
int32_t
row
=
varName
[
4
]
-
'0'
;
int32_t
col
=
varName
[
5
]
-
'0'
;
if
(
row
<
0
||
row
>=
MAX_QUERY_ROW_NUM
)
{
...
...
@@ -119,6 +183,8 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
simDebug
(
"script:%s, data[%d][%d]=%s"
,
script
->
fileName
,
row
,
col
,
script
->
data
[
row
][
col
]);
return
script
->
data
[
row
][
col
];
}
return
"null"
;
}
for
(
int32_t
i
=
0
;
i
<
script
->
varLen
;
++
i
)
{
...
...
@@ -127,9 +193,6 @@ char *simGetVariable(SScript *script, char *varName, int32_t varLen) {
continue
;
}
if
(
strncmp
(
varName
,
var
->
varName
,
varLen
)
==
0
)
{
// if (strlen(var->varValue) != 0)
// simDebug("script:%s, var:%s, value:%s", script->fileName,
// var->varName, var->varValue);
return
var
->
varValue
;
}
}
...
...
@@ -774,7 +837,7 @@ bool simExecuteSqlSlowCmd(SScript *script, char *rest) {
bool
simExecuteRestfulCmd
(
SScript
*
script
,
char
*
rest
)
{
TdFilePtr
pFile
=
NULL
;
char
filename
[
256
];
char
filename
[
256
];
sprintf
(
filename
,
"%s/tmp.sql"
,
simScriptDir
);
// fp = fopen(filename, "w");
pFile
=
taosOpenFile
(
filename
,
TD_FILE_CREATE
|
TD_FILE_WRITE
|
TD_FILE_TRUNC
|
TD_FILE_STREAM
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录