Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
05e46d99
TDengine
项目概览
taosdata
/
TDengine
大约 1 年 前同步成功
通知
1184
Star
22015
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
05e46d99
编写于
1月 18, 2022
作者:
S
Shengliang Guan
提交者:
GitHub
1月 18, 2022
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9871 from taosdata/feature/dnode3
add stb test
上级
17a26c47
d8a815e1
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
191 addition
and
241 deletion
+191
-241
source/dnode/mgmt/impl/test/CMakeLists.txt
source/dnode/mgmt/impl/test/CMakeLists.txt
+0
-1
source/dnode/mgmt/impl/test/stb/CMakeLists.txt
source/dnode/mgmt/impl/test/stb/CMakeLists.txt
+0
-11
source/dnode/mgmt/impl/test/stb/dstb.cpp
source/dnode/mgmt/impl/test/stb/dstb.cpp
+0
-139
source/dnode/mgmt/impl/test/vnode/vnode.cpp
source/dnode/mgmt/impl/test/vnode/vnode.cpp
+191
-90
未找到文件。
source/dnode/mgmt/impl/test/CMakeLists.txt
浏览文件 @
05e46d99
...
...
@@ -5,5 +5,4 @@ add_subdirectory(bnode)
add_subdirectory
(
snode
)
add_subdirectory
(
mnode
)
add_subdirectory
(
vnode
)
add_subdirectory
(
stb
)
add_subdirectory
(
sut
)
source/dnode/mgmt/impl/test/stb/CMakeLists.txt
已删除
100644 → 0
浏览文件 @
17a26c47
aux_source_directory
(
. DSTB_SRC
)
add_executable
(
dnode_test_stb
${
DSTB_SRC
}
)
target_link_libraries
(
dnode_test_stb
PUBLIC sut
)
add_test
(
NAME dnode_test_stb
COMMAND dnode_test_stb
)
source/dnode/mgmt/impl/test/stb/dstb.cpp
已删除
100644 → 0
浏览文件 @
17a26c47
/**
* @file db.cpp
* @author slguan (slguan@taosdata.com)
* @brief DNODE module vnode tests
* @version 0.1
* @date 2021-12-20
*
* @copyright Copyright (c) 2021
*
*/
#include "sut.h"
class
DndTestVnode
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/dnode_test_stb"
,
9116
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
};
Testbase
DndTestVnode
::
test
;
TEST_F
(
DndTestVnode
,
01
_Create_Restart_Drop_Vnode
)
{
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SCreateVnodeReq
);
SCreateVnodeReq
*
pReq
=
(
SCreateVnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
vgId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
db
,
"1.d1"
);
pReq
->
dbUid
=
htobe64
(
9527
);
pReq
->
vgVersion
=
htonl
(
1
);
pReq
->
cacheBlockSize
=
htonl
(
16
);
pReq
->
totalBlocks
=
htonl
(
10
);
pReq
->
daysPerFile
=
htonl
(
10
);
pReq
->
daysToKeep0
=
htonl
(
3650
);
pReq
->
daysToKeep1
=
htonl
(
3650
);
pReq
->
daysToKeep2
=
htonl
(
3650
);
pReq
->
minRows
=
htonl
(
100
);
pReq
->
minRows
=
htonl
(
4096
);
pReq
->
commitTime
=
htonl
(
3600
);
pReq
->
fsyncPeriod
=
htonl
(
3000
);
pReq
->
walLevel
=
1
;
pReq
->
precision
=
0
;
pReq
->
compression
=
2
;
pReq
->
replica
=
1
;
pReq
->
quorum
=
1
;
pReq
->
update
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
selfIndex
=
0
;
for
(
int
r
=
0
;
r
<
pReq
->
replica
;
++
r
)
{
SReplica
*
pReplica
=
&
pReq
->
replicas
[
r
];
pReplica
->
id
=
htonl
(
1
);
pReplica
->
port
=
htons
(
9527
);
}
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_CREATE_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
i
==
0
)
{
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
Restart
();
}
else
{
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED
);
}
}
}
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SAlterVnodeReq
);
SAlterVnodeReq
*
pReq
=
(
SAlterVnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
vgId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
db
,
"1.d1"
);
pReq
->
dbUid
=
htobe64
(
9527
);
pReq
->
vgVersion
=
htonl
(
2
);
pReq
->
cacheBlockSize
=
htonl
(
16
);
pReq
->
totalBlocks
=
htonl
(
10
);
pReq
->
daysPerFile
=
htonl
(
10
);
pReq
->
daysToKeep0
=
htonl
(
3650
);
pReq
->
daysToKeep1
=
htonl
(
3650
);
pReq
->
daysToKeep2
=
htonl
(
3650
);
pReq
->
minRows
=
htonl
(
100
);
pReq
->
minRows
=
htonl
(
4096
);
pReq
->
commitTime
=
htonl
(
3600
);
pReq
->
fsyncPeriod
=
htonl
(
3000
);
pReq
->
walLevel
=
1
;
pReq
->
precision
=
0
;
pReq
->
compression
=
2
;
pReq
->
replica
=
1
;
pReq
->
quorum
=
1
;
pReq
->
update
=
0
;
pReq
->
cacheLastRow
=
0
;
pReq
->
selfIndex
=
0
;
for
(
int
r
=
0
;
r
<
pReq
->
replica
;
++
r
)
{
SReplica
*
pReplica
=
&
pReq
->
replicas
[
r
];
pReplica
->
id
=
htonl
(
1
);
pReplica
->
port
=
htons
(
9527
);
}
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_ALTER_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SDropVnodeReq
);
SDropVnodeReq
*
pReq
=
(
SDropVnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
vgId
=
htonl
(
2
);
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
db
,
"1.d1"
);
pReq
->
dbUid
=
htobe64
(
9527
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SDropVnodeReq
);
rpcMsg
.
msgType
=
TDMT_DND_DROP_VNODE
;
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_DND_DROP_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
i
==
0
)
{
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
Restart
();
}
else
{
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_VNODE_NOT_DEPLOYED
);
}
}
}
}
source/dnode/mgmt/impl/test/vnode/vnode.cpp
浏览文件 @
05e46d99
...
...
@@ -25,8 +25,7 @@ class DndTestVnode : public ::testing::Test {
Testbase
DndTestVnode
::
test
;
TEST_F
(
DndTestVnode
,
01
_Create_Restart_Drop_Vnode
)
{
{
TEST_F
(
DndTestVnode
,
01
_Create_Vnode
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SCreateVnodeReq
);
...
...
@@ -69,9 +68,9 @@ TEST_F(DndTestVnode, 01_Create_Restart_Drop_Vnode) {
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_VNODE_ALREADY_DEPLOYED
);
}
}
}
}
{
TEST_F
(
DndTestVnode
,
02
_ALTER_Vnode
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SAlterVnodeReq
);
...
...
@@ -109,9 +108,112 @@ TEST_F(DndTestVnode, 01_Create_Restart_Drop_Vnode) {
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
}
TEST_F
(
DndTestVnode
,
03
_Create_Stb
)
{
for
(
int
i
=
0
;
i
<
1
;
++
i
)
{
SVCreateTbReq
req
=
{
0
};
req
.
ver
=
0
;
req
.
name
=
(
char
*
)
"stb1"
;
req
.
ttl
=
0
;
req
.
keep
=
0
;
req
.
type
=
TD_SUPER_TABLE
;
SSchema
schemas
[
5
]
=
{
0
};
{
SSchema
*
pSchema
=
&
schemas
[
0
];
pSchema
->
bytes
=
htonl
(
8
);
pSchema
->
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
->
name
,
"ts"
);
}
{
SSchema
*
pSchema
=
&
schemas
[
1
];
pSchema
->
bytes
=
htonl
(
4
);
pSchema
->
type
=
TSDB_DATA_TYPE_INT
;
strcpy
(
pSchema
->
name
,
"col1"
);
}
{
SSchema
*
pSchema
=
&
schemas
[
2
];
pSchema
->
bytes
=
htonl
(
2
);
pSchema
->
type
=
TSDB_DATA_TYPE_TINYINT
;
strcpy
(
pSchema
->
name
,
"tag1"
);
}
{
SSchema
*
pSchema
=
&
schemas
[
3
];
pSchema
->
bytes
=
htonl
(
8
);
pSchema
->
type
=
TSDB_DATA_TYPE_BIGINT
;
strcpy
(
pSchema
->
name
,
"tag2"
);
}
{
SSchema
*
pSchema
=
&
schemas
[
4
];
pSchema
->
bytes
=
htonl
(
16
);
pSchema
->
type
=
TSDB_DATA_TYPE_BINARY
;
strcpy
(
pSchema
->
name
,
"tag3"
);
}
req
.
stbCfg
.
suid
=
9527
;
req
.
stbCfg
.
nCols
=
2
;
req
.
stbCfg
.
pSchema
=
&
schemas
[
0
];
req
.
stbCfg
.
nTagCols
=
3
;
req
.
stbCfg
.
pTagSchema
=
&
schemas
[
2
];
int32_t
bsize
=
tSerializeSVCreateTbReq
(
NULL
,
&
req
);
void
*
buf
=
rpcMallocCont
(
sizeof
(
SMsgHead
)
+
bsize
);
SMsgHead
*
pMsgHead
=
(
SMsgHead
*
)
buf
;
pMsgHead
->
contLen
=
htonl
(
sizeof
(
SMsgHead
)
+
bsize
);
pMsgHead
->
vgId
=
htonl
(
2
);
void
*
pBuf
=
POINTER_SHIFT
(
buf
,
sizeof
(
SMsgHead
));
tSerializeSVCreateTbReq
(
&
pBuf
,
&
req
);
int32_t
contLen
=
sizeof
(
SMsgHead
)
+
bsize
;
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_VND_CREATE_STB
,
buf
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
i
==
0
)
{
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
Restart
();
}
else
{
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_TDB_TABLE_ALREADY_EXIST
);
}
}
}
TEST_F
(
DndTestVnode
,
04
_ALTER_Stb
)
{
#if 0
{
for (int i = 0; i < 3; ++i) {
SRpcMsg* pRsp = test.SendReq(TDMT_VND_ALTER_STB, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
ASSERT_EQ(pRsp->code, 0);
}
}
#endif
}
TEST_F
(
DndTestVnode
,
05
_DROP_Stb
)
{
#if 0
{
for (int i = 0; i < 3; ++i) {
SRpcMsg* pRsp = test.SendReq(TDMT_VND_DROP_STB, pReq, contLen);
ASSERT_NE(pRsp, nullptr);
if (i == 0) {
ASSERT_EQ(pRsp->code, 0);
test.Restart();
} else {
ASSERT_EQ(pRsp->code, TSDB_CODE_TDB_INVALID_TABLE_ID);
}
}
}
#endif
}
TEST_F
(
DndTestVnode
,
06
_DROP_Vnode
)
{
for
(
int
i
=
0
;
i
<
3
;
++
i
)
{
int32_t
contLen
=
sizeof
(
SDropVnodeReq
);
...
...
@@ -135,5 +237,4 @@ TEST_F(DndTestVnode, 01_Create_Restart_Drop_Vnode) {
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_VNODE_NOT_DEPLOYED
);
}
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录