Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
971e68ab
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看板
提交
971e68ab
编写于
1月 07, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test cases for create mnode
上级
79f5088f
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
38 addition
and
203 deletion
+38
-203
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+17
-47
source/dnode/mnode/impl/test/mnode/mnode.cpp
source/dnode/mnode/impl/test/mnode/mnode.cpp
+21
-156
未找到文件。
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
971e68ab
...
...
@@ -354,38 +354,22 @@ static int32_t mndSetCreateMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDno
}
static
int32_t
mndCreateMnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pReq
,
SDnodeObj
*
pDnode
,
SMCreateMnodeReq
*
pCreate
)
{
int32_t
code
=
-
1
;
SMnodeObj
mnodeObj
=
{
0
};
mnodeObj
.
id
=
pDnode
->
id
;
mnodeObj
.
createdTime
=
taosGetTimestampMs
();
mnodeObj
.
updateTime
=
mnodeObj
.
createdTime
;
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"mnode:%d, failed to create since %s"
,
pCreate
->
dnodeId
,
terrstr
());
goto
CREATE_MNODE_OVER
;
}
mDebug
(
"trans:%d, used to create mnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
if
(
pTrans
==
NULL
)
goto
CREATE_MNODE_OVER
;
if
(
mndSetCreateMnodeRedoLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_MNODE_OVER
;
}
if
(
mndSetCreateMnodeCommitLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set commit log since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_MNODE_OVER
;
}
mDebug
(
"trans:%d, used to create mnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
if
(
mndSetCreateMnodeRedoLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
CREATE_MNODE_OVER
;
if
(
mndSetCreateMnodeCommitLogs
(
pMnode
,
pTrans
,
&
mnodeObj
)
!=
0
)
goto
CREATE_MNODE_OVER
;
if
(
mndSetCreateMnodeRedoActions
(
pMnode
,
pTrans
,
pDnode
,
&
mnodeObj
)
!=
0
)
goto
CREATE_MNODE_OVER
;
if
(
mndSetCreateMnodeRedoActions
(
pMnode
,
pTrans
,
pDnode
,
&
mnodeObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_MNODE_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
goto
CREATE_MNODE_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
CREATE_MNODE_OVER
;
code
=
0
;
...
...
@@ -408,6 +392,9 @@ static int32_t mndProcessCreateMnodeReq(SMnodeMsg *pReq) {
mError
(
"mnode:%d, mnode already exist"
,
pObj
->
id
);
terrno
=
TSDB_CODE_MND_MNODE_ALREADY_EXIST
;
return
-
1
;
}
else
if
(
terrno
!=
TSDB_CODE_MND_MNODE_NOT_EXIST
)
{
mError
(
"qnode:%d, failed to create mnode since %s"
,
pCreate
->
dnodeId
,
terrstr
());
return
-
1
;
}
SDnodeObj
*
pDnode
=
mndAcquireDnode
(
pMnode
,
pCreate
->
dnodeId
);
...
...
@@ -526,33 +513,16 @@ static int32_t mndSetDropMnodeRedoActions(SMnode *pMnode, STrans *pTrans, SDnode
static
int32_t
mndDropMnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
pReq
,
SMnodeObj
*
pObj
)
{
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
pReq
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"mnode:%d, failed to drop since %s"
,
pObj
->
id
,
terrstr
());
goto
DROP_MNODE_OVER
;
}
if
(
pTrans
==
NULL
)
goto
DROP_MNODE_OVER
;
mDebug
(
"trans:%d, used to drop mnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
if
(
mndSetDropMnodeRedoLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo log since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_MNODE_OVER
;
}
if
(
mndSetDropMnodeCommitLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set commit log since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_MNODE_OVER
;
}
if
(
mndSetDropMnodeRedoActions
(
pMnode
,
pTrans
,
pObj
->
pDnode
,
pObj
)
!=
0
)
{
mError
(
"trans:%d, failed to set redo actions since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_MNODE_OVER
;
}
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
{
mError
(
"trans:%d, failed to prepare since %s"
,
pTrans
->
id
,
terrstr
());
goto
DROP_MNODE_OVER
;
}
if
(
mndSetDropMnodeRedoLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
DROP_MNODE_OVER
;
if
(
mndSetDropMnodeCommitLogs
(
pMnode
,
pTrans
,
pObj
)
!=
0
)
goto
DROP_MNODE_OVER
;
if
(
mndSetDropMnodeRedoActions
(
pMnode
,
pTrans
,
pObj
->
pDnode
,
pObj
)
!=
0
)
goto
DROP_MNODE_OVER
;
if
(
mndTransPrepare
(
pMnode
,
pTrans
)
!=
0
)
goto
DROP_MNODE_OVER
;
code
=
0
;
...
...
source/dnode/mnode/impl/test/mnode/mnode.cpp
浏览文件 @
971e68ab
...
...
@@ -18,37 +18,25 @@ class MndTestMnode : public ::testing::Test {
public:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_mnode1"
,
90
31
);
test
.
Init
(
"/tmp/mnode_test_mnode1"
,
90
28
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:90
31
"
;
const
char
*
firstEp
=
"localhost:90
28
"
;
server2
.
Start
(
"/tmp/mnode_test_mnode2"
,
fqdn
,
9032
,
firstEp
);
server3
.
Start
(
"/tmp/mnode_test_mnode3"
,
fqdn
,
9033
,
firstEp
);
server4
.
Start
(
"/tmp/mnode_test_mnode4"
,
fqdn
,
9034
,
firstEp
);
server5
.
Start
(
"/tmp/mnode_test_mnode5"
,
fqdn
,
9035
,
firstEp
);
server2
.
Start
(
"/tmp/mnode_test_mnode2"
,
fqdn
,
9029
,
firstEp
);
taosMsleep
(
300
);
}
static
void
TearDownTestSuite
()
{
server2
.
Stop
();
server3
.
Stop
();
server4
.
Stop
();
server5
.
Stop
();
test
.
Cleanup
();
}
static
Testbase
test
;
static
TestServer
server2
;
static
TestServer
server3
;
static
TestServer
server4
;
static
TestServer
server5
;
};
Testbase
MndTestMnode
::
test
;
TestServer
MndTestMnode
::
server2
;
TestServer
MndTestMnode
::
server3
;
TestServer
MndTestMnode
::
server4
;
TestServer
MndTestMnode
::
server5
;
TEST_F
(
MndTestMnode
,
01
_ShowDnode
)
{
test
.
SendShowMetaReq
(
TSDB_MGMT_TABLE_MNODE
,
""
);
...
...
@@ -64,7 +52,7 @@ TEST_F(MndTestMnode, 01_ShowDnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
31
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
28
"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckInt64
(
0
);
CheckTimestamp
();
...
...
@@ -103,7 +91,7 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
SCreateDnodeReq
*
pReq
=
(
SCreateDnodeReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
90
32
);
pReq
->
port
=
htonl
(
90
29
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
...
...
@@ -132,8 +120,8 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:90
31
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
32
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
28
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
29
"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckBinary
(
"slave"
,
12
);
CheckInt64
(
0
);
...
...
@@ -158,144 +146,21 @@ TEST_F(MndTestMnode, 04_Create_Mnode) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:90
31
"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:90
28
"
,
TSDB_EP_LEN
);
CheckBinary
(
"master"
,
12
);
CheckInt64
(
0
);
CheckTimestamp
();
}
{
// drop mnode
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_DND_MNODE_NOT_DEPLOYED
);
}
}
\ No newline at end of file
// {
// int32_t contLen = sizeof(SDropDnodeReq);
// SDropDnodeReq* pReq = (SDropDnodeReq*)rpcMallocCont(contLen);
// pReq->dnodeId = htonl(2);
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_DROP_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
// ASSERT_EQ(pRsp->code, 0);
// }
// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieveReq();
// EXPECT_EQ(test.GetShowRows(), 1);
// CheckInt16(1);
// CheckBinary("localhost:9031", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(1);
// CheckBinary("ready", 10);
// CheckTimestamp();
// CheckBinary("", 24);
// {
// int32_t contLen = sizeof(SCreateDnodeReq);
// SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9033");
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
// ASSERT_EQ(pRsp->code, 0);
// }
// {
// int32_t contLen = sizeof(SCreateDnodeReq);
// SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9034");
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
// ASSERT_EQ(pRsp->code, 0);
// }
// {
// int32_t contLen = sizeof(SCreateDnodeReq);
// SCreateDnodeReq* pReq = (SCreateDnodeReq*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9035");
// SRpcMsg* pRsp = test.SendReq(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(pRsp, nullptr);
// ASSERT_EQ(pRsp->code, 0);
// }
// taosMsleep(1300);
// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieveReq();
// EXPECT_EQ(test.GetShowRows(), 4);
// CheckInt16(1);
// CheckInt16(3);
// CheckInt16(4);
// CheckInt16(5);
// CheckBinary("localhost:9031", TSDB_EP_LEN);
// CheckBinary("localhost:9033", TSDB_EP_LEN);
// CheckBinary("localhost:9034", TSDB_EP_LEN);
// CheckBinary("localhost:9035", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// // restart
// uInfo("stop all server");
// test.Restart();
// server2.Restart();
// server3.Restart();
// server4.Restart();
// server5.Restart();
// taosMsleep(1300);
// test.SendShowMetaReq(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieveReq();
// EXPECT_EQ(test.GetShowRows(), 4);
// CheckInt16(1);
// CheckInt16(3);
// CheckInt16(4);
// CheckInt16(5);
// CheckBinary("localhost:9031", TSDB_EP_LEN);
// CheckBinary("localhost:9033", TSDB_EP_LEN);
// CheckBinary("localhost:9034", TSDB_EP_LEN);
// CheckBinary("localhost:9035", TSDB_EP_LEN);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(0);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckInt16(1);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckBinary("ready", 10);
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckTimestamp();
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// CheckBinary("", 24);
// }
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录