Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
2ad2efdf
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
2ad2efdf
编写于
12月 15, 2021
作者:
H
Hongze Cheng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
more
上级
cb5c12f1
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
91 addition
and
65 deletion
+91
-65
source/dnode/vnode/impl/test/vnodeApiTests.cpp
source/dnode/vnode/impl/test/vnodeApiTests.cpp
+91
-65
未找到文件。
source/dnode/vnode/impl/test/vnodeApiTests.cpp
浏览文件 @
2ad2efdf
...
...
@@ -71,89 +71,115 @@ static SKVRow vtCreateBasicTag() {
return
pTag
;
}
TEST
(
vnodeApiTest
,
vnode_simple_create_table_test
)
{
vnodeDestroy
(
"vnode1"
);
static
void
vtBuildCreateStbReq
(
tb_uid_t
suid
,
char
*
tbname
,
SRpcMsg
**
ppMsg
)
{
SRpcMsg
*
pMsg
;
STSchema
*
pSchema
;
STSchema
*
pTagSchema
;
int
zs
;
void
*
pBuf
;
GTEST_ASSERT_GE
(
vnodeInit
(
2
),
0
);
pSchema
=
vtCreateBasicSchema
();
pTagSchema
=
vtCreateBasicTagSchema
();
// Create and open a vnode
SVnode
*
pVnode
=
vnodeOpen
(
"vnode1"
,
NULL
);
ASSERT_NE
(
pVnode
,
nullptr
);
SVnodeReq
vCreateSTbReq
=
VNODE_INIT_CREATE_STB_REQ
(
tbname
,
UINT32_MAX
,
UINT32_MAX
,
suid
,
pSchema
,
pTagSchema
);
tb_uid_t
suid
=
1638166374163
;
{
// Create a super table
STSchema
*
pSchema
=
vtCreateBasicSchema
();
STSchema
*
pTagSchema
=
vtCreateBasicTagSchema
();
char
tbname
[
128
]
=
"st"
;
zs
=
vnodeBuildReq
(
NULL
,
&
vCreateSTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
)
+
zs
);
pMsg
->
msgType
=
TSDB_MSG_TYPE_CREATE_TABLE
;
pMsg
->
contLen
=
zs
;
pMsg
->
pCont
=
POINTER_SHIFT
(
pMsg
,
sizeof
(
SRpcMsg
));
pBuf
=
pMsg
->
pCont
;
vnodeBuildReq
(
&
pBuf
,
&
vCreateSTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
META_CLEAR_TB_CFG
(
&
vCreateSTbReq
);
SArray
*
pMsgs
=
(
SArray
*
)
taosArrayInit
(
1
,
sizeof
(
SRpcMsg
*
)
);
SVnodeReq
vCreateSTbReq
=
VNODE_INIT_CREATE_STB_REQ
(
tbname
,
UINT32_MAX
,
UINT32_MAX
,
suid
,
pSchema
,
pTagSchema
);
tdFreeSchema
(
pSchema
);
tdFreeSchema
(
pTagSchema
);
int
zs
=
vnodeBuildReq
(
NULL
,
&
vCreateSTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
SRpcMsg
*
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
)
+
zs
);
pMsg
->
msgType
=
TSDB_MSG_TYPE_CREATE_TABLE
;
pMsg
->
contLen
=
zs
;
pMsg
->
pCont
=
POINTER_SHIFT
(
pMsg
,
sizeof
(
SRpcMsg
));
*
ppMsg
=
pMsg
;
}
static
void
vtBuildCreateCtbReq
(
tb_uid_t
suid
,
char
*
tbname
,
SRpcMsg
**
ppMsg
)
{
SRpcMsg
*
pMsg
;
int
tz
;
SKVRow
pTag
;
void
*
pBuf
=
pMsg
->
pCont
;
pTag
=
vtCreateBasicTag
();
SVnodeReq
vCreateCTbReq
=
VNODE_INIT_CREATE_CTB_REQ
(
tbname
,
UINT32_MAX
,
UINT32_MAX
,
suid
,
pTag
);
vnodeBuildReq
(
&
pBuf
,
&
vCreateSTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
META_CLEAR_TB_CFG
(
&
vCreateSTbReq
);
tz
=
vnodeBuildReq
(
NULL
,
&
vCreateCTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
)
+
tz
);
pMsg
->
msgType
=
TSDB_MSG_TYPE_CREATE_TABLE
;
pMsg
->
contLen
=
tz
;
pMsg
->
pCont
=
POINTER_SHIFT
(
pMsg
,
sizeof
(
*
pMsg
));
void
*
pBuf
=
pMsg
->
pCont
;
taosArrayPush
(
pMsgs
,
&
(
pMsg
));
vnodeBuildReq
(
&
pBuf
,
&
vCreateCTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
META_CLEAR_TB_CFG
(
&
vCreateCTbReq
);
free
(
pTag
);
vnodeProcessWMsgs
(
pVnode
,
pMsgs
);
*
ppMsg
=
pMsg
;
}
static
void
vtClearMsgBatch
(
SArray
*
pMsgArr
)
{
SRpcMsg
*
pMsg
;
for
(
size_t
i
=
0
;
i
<
taosArrayGetSize
(
pMsgArr
);
i
++
)
{
pMsg
=
*
(
SRpcMsg
**
)
taosArrayGet
(
pMsgArr
,
i
);
free
(
pMsg
);
taosArrayDestroy
(
pMsgs
);
tdFreeSchema
(
pSchema
);
tdFreeSchema
(
pTagSchema
);
}
{
// Create some child tables
int
ntables
=
1000000
;
int
batch
=
10
;
for
(
int
i
=
0
;
i
<
ntables
/
batch
;
i
++
)
{
SArray
*
pMsgs
=
(
SArray
*
)
taosArrayInit
(
batch
,
sizeof
(
SRpcMsg
*
));
for
(
int
j
=
0
;
j
<
batch
;
j
++
)
{
SKVRow
pTag
=
vtCreateBasicTag
();
char
tbname
[
128
];
sprintf
(
tbname
,
"tb%d"
,
i
*
batch
+
j
);
SVnodeReq
vCreateCTbReq
=
VNODE_INIT_CREATE_CTB_REQ
(
tbname
,
UINT32_MAX
,
UINT32_MAX
,
suid
,
pTag
);
int
tz
=
vnodeBuildReq
(
NULL
,
&
vCreateCTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
SRpcMsg
*
pMsg
=
(
SRpcMsg
*
)
malloc
(
sizeof
(
SRpcMsg
)
+
tz
);
pMsg
->
msgType
=
TSDB_MSG_TYPE_CREATE_TABLE
;
pMsg
->
contLen
=
tz
;
pMsg
->
pCont
=
POINTER_SHIFT
(
pMsg
,
sizeof
(
*
pMsg
));
void
*
pBuf
=
pMsg
->
pCont
;
vnodeBuildReq
(
&
pBuf
,
&
vCreateCTbReq
,
TSDB_MSG_TYPE_CREATE_TABLE
);
META_CLEAR_TB_CFG
(
&
vCreateCTbReq
);
free
(
pTag
);
taosArrayPush
(
pMsgs
,
&
(
pMsg
));
}
vnodeProcessWMsgs
(
pVnode
,
pMsgs
);
for
(
int
j
=
0
;
j
<
batch
;
j
++
)
{
SRpcMsg
*
pMsg
=
*
(
SRpcMsg
**
)
taosArrayPop
(
pMsgs
);
free
(
pMsg
);
}
taosArrayDestroy
(
pMsgs
);
// std::cout << "the " << i << "th batch is created" << std::endl;
taosArrayClear
(
pMsgArr
);
}
TEST
(
vnodeApiTest
,
vnode_simple_create_table_test
)
{
tb_uid_t
suid
=
1638166374163
;
SRpcMsg
*
pMsg
;
SArray
*
pMsgArr
=
NULL
;
SVnode
*
pVnode
;
int
rcode
;
int
ntables
=
1000000
;
int
batch
=
10
;
char
tbname
[
128
];
pMsgArr
=
(
SArray
*
)
taosArrayInit
(
batch
,
sizeof
(
pMsg
));
vnodeDestroy
(
"vnode1"
);
GTEST_ASSERT_GE
(
vnodeInit
(
2
),
0
);
// CREATE AND OPEN A VNODE
pVnode
=
vnodeOpen
(
"vnode1"
,
NULL
);
ASSERT_NE
(
pVnode
,
nullptr
);
// CREATE A SUPER TABLE
sprintf
(
tbname
,
"st"
);
vtBuildCreateStbReq
(
suid
,
tbname
,
&
pMsg
);
taosArrayPush
(
pMsgArr
,
&
pMsg
);
rcode
=
vnodeProcessWMsgs
(
pVnode
,
pMsgArr
);
ASSERT_EQ
(
rcode
,
0
);
vtClearMsgBatch
(
pMsgArr
);
// CREATE A LOT OF CHILD TABLES
for
(
int
i
=
0
;
i
<
ntables
/
batch
;
i
++
)
{
// Build request batch
for
(
int
j
=
0
;
j
<
batch
;
j
++
)
{
sprintf
(
tbname
,
"ct%d"
,
i
*
batch
+
j
+
1
);
vtBuildCreateCtbReq
(
suid
,
tbname
,
&
pMsg
);
taosArrayPush
(
pMsgArr
,
&
pMsg
);
}
// Process request batch
rcode
=
vnodeProcessWMsgs
(
pVnode
,
pMsgArr
);
ASSERT_EQ
(
rcode
,
0
);
// Clear request batch
vtClearMsgBatch
(
pMsgArr
);
}
// C
lose the vnode
// C
LOSE THE VNODE
vnodeClose
(
pVnode
);
vnodeClear
();
taosArrayDestroy
(
pMsgArr
);
}
TEST
(
vnodeApiTest
,
vnode_simple_insert_test
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录