Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
9320f30d
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
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看板
提交
9320f30d
编写于
1月 07, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test for create mnode
上级
971e68ab
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
129 addition
and
3 deletion
+129
-3
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+4
-2
source/dnode/mnode/impl/test/mnode/mnode.cpp
source/dnode/mnode/impl/test/mnode/mnode.cpp
+125
-1
未找到文件。
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
9320f30d
...
...
@@ -320,6 +320,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SDAlterMnodeReq
);
action
.
msgType
=
TDMT_DND_ALTER_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pReq
);
...
...
@@ -344,6 +345,7 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SDCreateMnodeReq
);
action
.
msgType
=
TDMT_DND_CREATE_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pReq
);
return
-
1
;
...
...
@@ -475,6 +477,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SDAlterMnodeReq
);
action
.
msgType
=
TDMT_DND_ALTER_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_MNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pReq
);
...
...
@@ -502,6 +505,7 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
action
.
pCont
=
pReq
;
action
.
contLen
=
sizeof
(
SDDropMnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_MNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
pReq
);
return
-
1
;
...
...
@@ -547,12 +551,10 @@ static int32_t mndProcessDropMnodeReq(SMnodeMsg *pReq) {
SMnodeObj
*
pObj
=
mndAcquireMnode
(
pMnode
,
pDrop
->
dnodeId
);
if
(
pObj
==
NULL
)
{
mError
(
"mnode:%d, not exist"
,
pDrop
->
dnodeId
);
terrno
=
TSDB_CODE_MND_DNODE_NOT_EXIST
;
return
-
1
;
}
int32_t
code
=
mndDropMnode
(
pMnode
,
pReq
,
pObj
);
if
(
code
!=
0
)
{
mError
(
"mnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
return
-
1
;
...
...
source/dnode/mnode/impl/test/mnode/mnode.cpp
浏览文件 @
9320f30d
...
...
@@ -161,6 +161,130 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_DND_MNODE_NOT_DEPLOYED
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_MNODE_NOT_EXIST
);
}
}
TEST_F
(
MndTestMnode
,
03
_Create_Mnode_Rollback
)
{
{
// send message first, then dnode2 crash, result is returned, and rollback is started
int32_t
contLen
=
sizeof
(
SMCreateMnodeReq
);
SMCreateMnodeReq
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
{
// continue send message, mnode is creating
int32_t
contLen
=
sizeof
(
SMCreateMnodeReq
);
SMCreateMnodeReq
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
{
// continue send message, mnode is creating
int32_t
contLen
=
sizeof
(
SMDropMnodeReq
);
SMDropMnodeReq
*
pReq
=
(
SMDropMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
{
// server start, wait until the rollback finished
server2
.
DoStart
();
taosMsleep
(
1000
);
int32_t
retry
=
0
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateMnodeReq
);
SMCreateMnodeReq
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
pRsp
->
code
==
TSDB_CODE_MND_MNODE_ALREADY_EXIST
)
break
;
taosMsleep
(
1000
);
}
ASSERT_NE
(
retry
,
retryMax
);
}
}
TEST_F
(
MndTestMnode
,
04
_Drop_Mnode_Rollback
)
{
{
// send message first, then dnode2 crash, result is returned, and rollback is started
int32_t
contLen
=
sizeof
(
SMDropMnodeReq
);
SMDropMnodeReq
*
pReq
=
(
SMDropMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
{
// continue send message, mnode is dropping
int32_t
contLen
=
sizeof
(
SMCreateMnodeReq
);
SMCreateMnodeReq
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
{
// continue send message, mnode is dropping
int32_t
contLen
=
sizeof
(
SMDropMnodeReq
);
SMDropMnodeReq
*
pReq
=
(
SMDropMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
{
// server start, wait until the rollback finished
server2
.
DoStart
();
taosMsleep
(
1000
);
int32_t
retry
=
0
;
int32_t
retryMax
=
20
;
for
(
retry
=
0
;
retry
<
retryMax
;
retry
++
)
{
int32_t
contLen
=
sizeof
(
SMCreateMnodeReq
);
SMCreateMnodeReq
*
pReq
=
(
SMCreateMnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
if
(
pRsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
}
ASSERT_NE
(
retry
,
retryMax
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录