Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ad94dff0
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1187
Star
22018
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看板
提交
ad94dff0
编写于
1月 05, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
mionr changes
上级
11d6b02a
变更
32
隐藏空白更改
内联
并排
Showing
32 changed file
with
716 addition
and
716 deletion
+716
-716
include/common/tmsg.h
include/common/tmsg.h
+2
-2
source/client/src/clientMsgHandler.c
source/client/src/clientMsgHandler.c
+2
-2
source/dnode/mgmt/impl/test/bnode/dbnode.cpp
source/dnode/mgmt/impl/test/bnode/dbnode.cpp
+27
-27
source/dnode/mgmt/impl/test/db/db.cpp
source/dnode/mgmt/impl/test/db/db.cpp
+27
-27
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+28
-28
source/dnode/mgmt/impl/test/mnode/mnode.cpp
source/dnode/mgmt/impl/test/mnode/mnode.cpp
+41
-41
source/dnode/mgmt/impl/test/profile/profile.cpp
source/dnode/mgmt/impl/test/profile/profile.cpp
+29
-29
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
+27
-27
source/dnode/mgmt/impl/test/snode/dsnode.cpp
source/dnode/mgmt/impl/test/snode/dsnode.cpp
+27
-27
source/dnode/mgmt/impl/test/stb/stb.cpp
source/dnode/mgmt/impl/test/stb/stb.cpp
+16
-16
source/dnode/mgmt/impl/test/sut/inc/client.h
source/dnode/mgmt/impl/test/sut/inc/client.h
+1
-1
source/dnode/mgmt/impl/test/sut/inc/sut.h
source/dnode/mgmt/impl/test/sut/inc/sut.h
+3
-3
source/dnode/mgmt/impl/test/sut/src/client.cpp
source/dnode/mgmt/impl/test/sut/src/client.cpp
+5
-5
source/dnode/mgmt/impl/test/sut/src/sut.cpp
source/dnode/mgmt/impl/test/sut/src/sut.cpp
+12
-12
source/dnode/mgmt/impl/test/vgroup/vgroup.cpp
source/dnode/mgmt/impl/test/vgroup/vgroup.cpp
+9
-9
source/dnode/mnode/impl/src/mndAcct.c
source/dnode/mnode/impl/src/mndAcct.c
+6
-6
source/dnode/mnode/impl/src/mndBnode.c
source/dnode/mnode/impl/src/mndBnode.c
+41
-41
source/dnode/mnode/impl/src/mndQnode.c
source/dnode/mnode/impl/src/mndQnode.c
+41
-41
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+24
-24
source/dnode/mnode/impl/src/mndSnode.c
source/dnode/mnode/impl/src/mndSnode.c
+41
-41
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+31
-31
source/dnode/mnode/impl/test/acct/acct.cpp
source/dnode/mnode/impl/test/acct/acct.cpp
+14
-14
source/dnode/mnode/impl/test/bnode/bnode.cpp
source/dnode/mnode/impl/test/bnode/bnode.cpp
+55
-55
source/dnode/mnode/impl/test/qnode/qnode.cpp
source/dnode/mnode/impl/test/qnode/qnode.cpp
+55
-55
source/dnode/mnode/impl/test/show/show.cpp
source/dnode/mnode/impl/test/show/show.cpp
+17
-17
source/dnode/mnode/impl/test/snode/snode.cpp
source/dnode/mnode/impl/test/snode/snode.cpp
+55
-55
source/dnode/mnode/impl/test/trans/trans.cpp
source/dnode/mnode/impl/test/trans/trans.cpp
+8
-8
source/dnode/mnode/impl/test/user/user.cpp
source/dnode/mnode/impl/test/user/user.cpp
+59
-59
source/libs/parser/inc/astToMsg.h
source/libs/parser/inc/astToMsg.h
+1
-1
source/libs/parser/src/astToMsg.c
source/libs/parser/src/astToMsg.c
+2
-2
source/libs/parser/src/dCDAstProcess.c
source/libs/parser/src/dCDAstProcess.c
+1
-1
src/client/src/tscServer.c
src/client/src/tscServer.c
+9
-9
未找到文件。
include/common/tmsg.h
浏览文件 @
ad94dff0
...
...
@@ -506,7 +506,7 @@ typedef struct {
int64_t
qId
;
};
// query handle
int8_t
free
;
}
SRetrieveTable
Msg
;
}
SRetrieveTable
Req
;
typedef
struct
SRetrieveTableRsp
{
int64_t
useconds
;
...
...
@@ -808,7 +808,7 @@ typedef struct {
char
db
[
TSDB_DB_FNAME_LEN
];
int16_t
payloadLen
;
char
payload
[];
}
SShow
Msg
;
}
SShow
Req
;
typedef
struct
{
char
db
[
TSDB_DB_FNAME_LEN
];
...
...
source/client/src/clientMsgHandler.c
浏览文件 @
ad94dff0
...
...
@@ -87,14 +87,14 @@ SMsgSendInfo* buildMsgInfoImpl(SRequestObj *pRequest) {
if
(
pRequest
->
type
==
TDMT_MND_SHOW_RETRIEVE
||
pRequest
->
type
==
TDMT_VND_SHOW_TABLES_FETCH
)
{
if
(
pRequest
->
type
==
TDMT_MND_SHOW_RETRIEVE
)
{
SRetrieveTable
Msg
*
pRetrieveMsg
=
calloc
(
1
,
sizeof
(
SRetrieveTableMsg
));
SRetrieveTable
Req
*
pRetrieveMsg
=
calloc
(
1
,
sizeof
(
SRetrieveTableReq
));
if
(
pRetrieveMsg
==
NULL
)
{
return
NULL
;
}
pRetrieveMsg
->
showId
=
htobe64
(
pRequest
->
body
.
showInfo
.
execId
);
pMsgSendInfo
->
msgInfo
.
pData
=
pRetrieveMsg
;
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SRetrieveTable
Msg
);
pMsgSendInfo
->
msgInfo
.
len
=
sizeof
(
SRetrieveTable
Req
);
}
else
{
SVShowTablesFetchReq
*
pFetchMsg
=
calloc
(
1
,
sizeof
(
SVShowTablesFetchReq
));
if
(
pFetchMsg
==
NULL
)
{
...
...
source/dnode/mgmt/impl/test/bnode/dbnode.cpp
浏览文件 @
ad94dff0
...
...
@@ -32,9 +32,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_ID_INVALID
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_ID_INVALID
);
}
{
...
...
@@ -43,9 +43,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -54,9 +54,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
);
}
test
.
Restart
();
...
...
@@ -67,9 +67,9 @@ TEST_F(DndTestBnode, 01_Create_Bnode) {
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
);
}
}
...
...
@@ -80,9 +80,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_ID_INVALID
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_ID_INVALID
);
}
{
...
...
@@ -91,9 +91,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -102,9 +102,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
);
}
test
.
Restart
();
...
...
@@ -115,9 +115,9 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SDDropBnodeReq
*
pReq
=
(
SDDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
);
}
{
...
...
@@ -126,8 +126,8 @@ TEST_F(DndTestBnode, 01_Drop_Bnode) {
SDCreateBnodeReq
*
pReq
=
(
SDCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
\ No newline at end of file
source/dnode/mgmt/impl/test/db/db.cpp
浏览文件 @
ad94dff0
...
...
@@ -26,7 +26,7 @@ class DndTestDb : public ::testing::Test {
Testbase
DndTestDb
::
test
;
TEST_F
(
DndTestDb
,
01
_ShowDb
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
18
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
"name"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
...
...
@@ -47,7 +47,7 @@ TEST_F(DndTestDb, 01_ShowDb) {
CHECK_SCHEMA
(
16
,
TSDB_DATA_TYPE_BINARY
,
3
+
VARSTR_HEADER_SIZE
,
"precision"
);
CHECK_SCHEMA
(
17
,
TSDB_DATA_TYPE_TINYINT
,
1
,
"update"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
...
...
@@ -77,15 +77,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
18
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckTimestamp
();
...
...
@@ -106,14 +106,14 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
CheckBinary
(
"ms"
,
3
);
// precision
CheckInt8
(
0
);
// update
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_VGROUP
,
"1.d1"
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_VGROUP
,
"1.d1"
);
CHECK_META
(
"show vgroups"
,
4
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"vgId"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_INT
,
4
,
"tables"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"v1_dnode"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_BINARY
,
9
+
VARSTR_HEADER_SIZE
,
"v1_status"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt32
(
2
);
CheckInt32
(
3
);
...
...
@@ -138,13 +138,13 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
pReq
->
quorum
=
2
;
pReq
->
cacheLastRow
=
1
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckTimestamp
();
...
...
@@ -168,10 +168,10 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
// restart
test
.
Restart
();
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
18
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
...
...
@@ -199,15 +199,15 @@ TEST_F(DndTestDb, 02_Create_Alter_Drop_Db) {
SDropDbMsg
*
pReq
=
(
SDropDbMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
db
,
"1.d1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
18
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
...
...
@@ -237,15 +237,15 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DB
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DB
,
""
);
CHECK_META
(
"show databases"
,
18
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"d2"
,
TSDB_DB_NAME_LEN
-
1
);
...
...
@@ -256,7 +256,7 @@ TEST_F(DndTestDb, 03_Create_Use_Restart_Use_Db) {
strcpy
(
pReq
->
db
,
"1.d2"
);
pReq
->
vgVersion
=
htonl
(
-
1
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_USE_DB
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_USE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
...
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
ad94dff0
...
...
@@ -51,7 +51,7 @@ TestServer DndTestDnode::server4;
TestServer
DndTestDnode
::
server5
;
TEST_F
(
DndTestDnode
,
01
_ShowDnode
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
...
...
@@ -62,7 +62,7 @@ TEST_F(DndTestDnode, 01_ShowDnode) {
CHECK_SCHEMA
(
5
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
6
,
TSDB_DATA_TYPE_BINARY
,
24
+
VARSTR_HEADER_SIZE
,
"offline_reason"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
...
...
@@ -81,9 +81,9 @@ TEST_F(DndTestDnode, 02_ConfigDnode) {
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
config
,
"ddebugflag 131"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CONFIG_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CONFIG_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
TEST_F
(
DndTestDnode
,
03
_Create_Drop_Restart_Dnode
)
{
...
...
@@ -94,16 +94,16 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9042
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
...
...
@@ -127,14 +127,14 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
SDropDnodeMsg
*
pReq
=
(
SDropDnodeMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
...
...
@@ -152,9 +152,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9043
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -164,9 +164,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9044
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -176,15 +176,15 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9045
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
4
);
CheckInt16
(
1
);
...
...
@@ -225,9 +225,9 @@ TEST_F(DndTestDnode, 03_Create_Drop_Restart_Dnode) {
server5
.
Restart
();
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
CHECK_META
(
"show dnodes"
,
7
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
4
);
CheckInt16
(
1
);
...
...
source/dnode/mgmt/impl/test/mnode/mnode.cpp
浏览文件 @
ad94dff0
...
...
@@ -51,7 +51,7 @@ TestServer DndTestMnode::server4;
TestServer
DndTestMnode
::
server5
;
TEST_F
(
DndTestMnode
,
01
_ShowDnode
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_MNODE
,
""
);
CHECK_META
(
"show mnodes"
,
5
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
...
...
@@ -60,7 +60,7 @@ TEST_F(DndTestMnode, 01_ShowDnode) {
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"role_time"
);
CHECK_SCHEMA
(
4
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
...
...
@@ -77,9 +77,9 @@ TEST_F(DndTestMnode, 02_Create_Mnode_Invalid_Id) {
SMCreateMnodeMsg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_MNODE_ALREADY_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_MNODE_ALREADY_EXIST
);
}
}
...
...
@@ -90,9 +90,9 @@ TEST_F(DndTestMnode, 03_Create_Mnode_Invalid_Id) {
SMCreateMnodeMsg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
}
...
...
@@ -105,13 +105,13 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9062
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
...
...
@@ -122,12 +122,12 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
SMCreateMnodeMsg
*
pReq
=
(
SMCreateMnodeMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
...
...
@@ -149,12 +149,12 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
SMDropMnodeMsg
*
pReq
=
(
SMDropMnodeMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_MNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_MNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
...
...
@@ -170,14 +170,14 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// SDropDnodeMsg* pReq = (SDropDnodeMsg*)rpcMallocCont(contLen);
// pReq->dnodeId = htonl(2);
// SRpcMsg* p
Msg = test.SendMsg
(TDMT_MND_DROP_DNODE, pReq, contLen);
// ASSERT_NE(p
Msg
, nullptr);
// ASSERT_EQ(p
Msg
->code, 0);
// SRpcMsg* p
Rsp = test.SendReq
(TDMT_MND_DROP_DNODE, pReq, contLen);
// ASSERT_NE(p
Rsp
, nullptr);
// ASSERT_EQ(p
Rsp
->code, 0);
// }
// test.SendShowMeta
Msg
(TSDB_MGMT_TABLE_DNODE, "");
// test.SendShowMeta
Req
(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieve
Msg
();
// test.SendShowRetrieve
Req
();
// EXPECT_EQ(test.GetShowRows(), 1);
// CheckInt16(1);
...
...
@@ -194,9 +194,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9063");
// SRpcMsg* p
Msg = test.SendMsg
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(p
Msg
, nullptr);
// ASSERT_EQ(p
Msg
->code, 0);
// SRpcMsg* p
Rsp = test.SendReq
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(p
Rsp
, nullptr);
// ASSERT_EQ(p
Rsp
->code, 0);
// }
// {
...
...
@@ -205,9 +205,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9064");
// SRpcMsg* p
Msg = test.SendMsg
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(p
Msg
, nullptr);
// ASSERT_EQ(p
Msg
->code, 0);
// SRpcMsg* p
Rsp = test.SendReq
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(p
Rsp
, nullptr);
// ASSERT_EQ(p
Rsp
->code, 0);
// }
// {
...
...
@@ -216,15 +216,15 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
// strcpy(pReq->ep, "localhost:9065");
// SRpcMsg* p
Msg = test.SendMsg
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(p
Msg
, nullptr);
// ASSERT_EQ(p
Msg
->code, 0);
// SRpcMsg* p
Rsp = test.SendReq
(TDMT_MND_CREATE_DNODE, pReq, contLen);
// ASSERT_NE(p
Rsp
, nullptr);
// ASSERT_EQ(p
Rsp
->code, 0);
// }
// taosMsleep(1300);
// test.SendShowMeta
Msg
(TSDB_MGMT_TABLE_DNODE, "");
// test.SendShowMeta
Req
(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieve
Msg
();
// test.SendShowRetrieve
Req
();
// EXPECT_EQ(test.GetShowRows(), 4);
// CheckInt16(1);
...
...
@@ -265,9 +265,9 @@ TEST_F(DndTestMnode, 04_Create_Mnode) {
// server5.Restart();
// taosMsleep(1300);
// test.SendShowMeta
Msg
(TSDB_MGMT_TABLE_DNODE, "");
// test.SendShowMeta
Req
(TSDB_MGMT_TABLE_DNODE, "");
// CHECK_META("show dnodes", 7);
// test.SendShowRetrieve
Msg
();
// test.SendShowRetrieve
Req
();
// EXPECT_EQ(test.GetShowRows(), 4);
// CheckInt16(1);
...
...
source/dnode/mgmt/impl/test/profile/profile.cpp
浏览文件 @
ad94dff0
...
...
@@ -35,7 +35,7 @@ TEST_F(DndTestProfile, 01_ConnectMsg) {
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
...
@@ -67,14 +67,14 @@ TEST_F(DndTestProfile, 02_ConnectMsg_InvalidDB) {
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
db
,
"invalid_db"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_DB
);
ASSERT_EQ
(
p
Msg
->
contLen
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_DB
);
ASSERT_EQ
(
p
Rsp
->
contLen
,
0
);
}
TEST_F
(
DndTestProfile
,
03
_ConnectMsg_Show
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_CONNS
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_CONNS
,
""
);
CHECK_META
(
"show connections"
,
7
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"connId"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"user"
);
...
...
@@ -84,7 +84,7 @@ TEST_F(DndTestProfile, 03_ConnectMsg_Show) {
CHECK_SCHEMA
(
5
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"login_time"
);
CHECK_SCHEMA
(
6
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"last_access"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt32
(
1
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
...
...
@@ -105,7 +105,7 @@ TEST_F(DndTestProfile, 04_HeartBeatMsg) {
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
...
@@ -138,9 +138,9 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
SKillConnMsg
*
pReq
=
(
SKillConnMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
connId
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -153,10 +153,10 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_CONNECTION
);
ASSERT_EQ
(
p
Msg
->
contLen
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_CONNECTION
);
ASSERT_EQ
(
p
Rsp
->
contLen
,
0
);
}
{
...
...
@@ -167,7 +167,7 @@ TEST_F(DndTestProfile, 05_KillConnMsg) {
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
...
@@ -198,9 +198,9 @@ TEST_F(DndTestProfile, 06_KillConnMsg_InvalidConn) {
SKillConnMsg
*
pReq
=
(
SKillConnMsg
*
)
rpcMallocCont
(
contLen
);
pReq
->
connId
=
htonl
(
2345
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_KILL_CONN
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
}
TEST_F
(
DndTestProfile
,
07
_KillQueryMsg
)
{
...
...
@@ -211,10 +211,10 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
pReq
->
connId
=
htonl
(
connId
);
pReq
->
queryId
=
htonl
(
1234
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_KILL_QUERY
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
ASSERT_EQ
(
p
Msg
->
contLen
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_KILL_QUERY
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
ASSERT_EQ
(
p
Rsp
->
contLen
,
0
);
}
{
...
...
@@ -227,7 +227,7 @@ TEST_F(DndTestProfile, 07_KillQueryMsg) {
pReq
->
numOfStreams
=
htonl
(
0
);
strcpy
(
pReq
->
app
,
"dnode_test_profile"
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_HEARTBEAT
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
...
@@ -261,13 +261,13 @@ TEST_F(DndTestProfile, 08_KillQueryMsg_InvalidConn) {
pReq
->
connId
=
htonl
(
2345
);
pReq
->
queryId
=
htonl
(
1234
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_KILL_QUERY
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_KILL_QUERY
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_CONN_ID
);
}
TEST_F
(
DndTestProfile
,
09
_KillQueryMsg
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_QUERIES
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_QUERIES
,
""
);
CHECK_META
(
"show queries"
,
14
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"queryId"
);
...
...
@@ -285,6 +285,6 @@ TEST_F(DndTestProfile, 09_KillQueryMsg) {
CHECK_SCHEMA
(
12
,
TSDB_DATA_TYPE_BINARY
,
TSDB_SHOW_SUBQUERY_LEN
+
VARSTR_HEADER_SIZE
,
"sub_query_info"
);
CHECK_SCHEMA
(
13
,
TSDB_DATA_TYPE_BINARY
,
TSDB_SHOW_SQL_LEN
+
VARSTR_HEADER_SIZE
,
"sql"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
source/dnode/mgmt/impl/test/qnode/dqnode.cpp
浏览文件 @
ad94dff0
...
...
@@ -32,9 +32,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_ID_INVALID
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_ID_INVALID
);
}
{
...
...
@@ -43,9 +43,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -54,9 +54,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
}
test
.
Restart
();
...
...
@@ -67,9 +67,9 @@ TEST_F(DndTestQnode, 01_Create_Qnode) {
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
);
}
}
...
...
@@ -80,9 +80,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_ID_INVALID
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_ID_INVALID
);
}
{
...
...
@@ -91,9 +91,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -102,9 +102,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
);
}
test
.
Restart
();
...
...
@@ -115,9 +115,9 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
SDDropQnodeReq
*
pReq
=
(
SDDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
);
}
{
...
...
@@ -126,8 +126,8 @@ TEST_F(DndTestQnode, 01_Drop_Qnode) {
SDCreateQnodeReq
*
pReq
=
(
SDCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
\ No newline at end of file
source/dnode/mgmt/impl/test/snode/dsnode.cpp
浏览文件 @
ad94dff0
...
...
@@ -32,9 +32,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_ID_INVALID
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_ID_INVALID
);
}
{
...
...
@@ -43,9 +43,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -54,9 +54,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
);
}
test
.
Restart
();
...
...
@@ -67,9 +67,9 @@ TEST_F(DndTestSnode, 01_Create_Snode) {
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
);
}
}
...
...
@@ -80,9 +80,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_ID_INVALID
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_ID_INVALID
);
}
{
...
...
@@ -91,9 +91,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -102,9 +102,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
);
}
test
.
Restart
();
...
...
@@ -115,9 +115,9 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SDDropSnodeReq
*
pReq
=
(
SDDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
);
}
{
...
...
@@ -126,8 +126,8 @@ TEST_F(DndTestSnode, 01_Drop_Snode) {
SDCreateSnodeReq
*
pReq
=
(
SDCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
\ No newline at end of file
source/dnode/mgmt/impl/test/stb/stb.cpp
浏览文件 @
ad94dff0
...
...
@@ -51,9 +51,9 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
pReq
->
cacheLastRow
=
0
;
pReq
->
ignoreExist
=
1
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -101,12 +101,12 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
strcpy
(
pSchema
->
name
,
"tag3"
);
}
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_STB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
CHECK_META
(
"show stables"
,
4
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_TABLE_NAME_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
...
...
@@ -114,7 +114,7 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_INT
,
4
,
"columns"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_INT
,
4
,
"tags"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
CheckTimestamp
();
...
...
@@ -128,7 +128,7 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
STableInfoMsg
*
pReq
=
(
STableInfoMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
tableFname
,
"1.d1.stb"
);
SRpcMsg
*
pMsg
=
test
.
Send
Msg
(
TDMT_MND_STB_META
,
pReq
,
contLen
);
SRpcMsg
*
pMsg
=
test
.
Send
Req
(
TDMT_MND_STB_META
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
...
...
@@ -203,9 +203,9 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
// restart
test
.
Restart
();
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
CHECK_META
(
"show stables"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"stb"
,
TSDB_TABLE_NAME_LEN
);
...
...
@@ -219,13 +219,13 @@ TEST_F(DndTestStb, 01_Create_Show_Meta_Drop_Restart_Stb) {
SDropStbMsg
*
pReq
=
(
SDropStbMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
name
,
"1.d1.stb"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_STB
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_STB
,
"1.d1"
);
CHECK_META
(
"show stables"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
source/dnode/mgmt/impl/test/sut/inc/client.h
浏览文件 @
ad94dff0
...
...
@@ -21,7 +21,7 @@ class TestClient {
bool
Init
(
const
char
*
user
,
const
char
*
pass
,
const
char
*
fqdn
,
uint16_t
port
);
void
Cleanup
();
SRpcMsg
*
Send
Msg
(
SRpcMsg
*
pMsg
);
SRpcMsg
*
Send
Req
(
SRpcMsg
*
pReq
);
void
SetRpcRsp
(
SRpcMsg
*
pRsp
);
tsem_t
*
GetSem
();
...
...
source/dnode/mgmt/impl/test/sut/inc/sut.h
浏览文件 @
ad94dff0
...
...
@@ -39,7 +39,7 @@ class Testbase {
void
Restart
();
void
ServerStop
();
void
ServerStart
();
SRpcMsg
*
Send
Msg
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
);
SRpcMsg
*
Send
Req
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
);
private:
void
InitLog
(
const
char
*
path
);
...
...
@@ -50,8 +50,8 @@ class Testbase {
int32_t
connId
;
public:
void
SendShowMeta
Msg
(
int8_t
showType
,
const
char
*
db
);
void
SendShowRetrieve
Msg
();
void
SendShowMeta
Req
(
int8_t
showType
,
const
char
*
db
);
void
SendShowRetrieve
Req
();
STableMetaMsg
*
GetShowMeta
();
SRetrieveTableRsp
*
GetRetrieveRsp
();
...
...
source/dnode/mgmt/impl/test/sut/src/client.cpp
浏览文件 @
ad94dff0
...
...
@@ -15,10 +15,10 @@
#include "sut.h"
static
void
processClientRsp
(
void
*
parent
,
SRpcMsg
*
p
Msg
,
SEpSet
*
pEpSet
)
{
static
void
processClientRsp
(
void
*
parent
,
SRpcMsg
*
p
Rsp
,
SEpSet
*
pEpSet
)
{
TestClient
*
client
=
(
TestClient
*
)
parent
;
client
->
SetRpcRsp
(
p
Msg
);
uInfo
(
"response:%s from dnode, code:0x%x"
,
TMSG_INFO
(
p
Msg
->
msgType
),
pMsg
->
code
);
client
->
SetRpcRsp
(
p
Rsp
);
uInfo
(
"response:%s from dnode, code:0x%x"
,
TMSG_INFO
(
p
Rsp
->
msgType
),
pRsp
->
code
);
tsem_post
(
client
->
GetSem
());
}
...
...
@@ -59,14 +59,14 @@ void TestClient::Cleanup() {
rpcClose
(
clientRpc
);
}
SRpcMsg
*
TestClient
::
Send
Msg
(
SRpcMsg
*
pMsg
)
{
SRpcMsg
*
TestClient
::
Send
Req
(
SRpcMsg
*
pReq
)
{
SEpSet
epSet
=
{
0
};
epSet
.
inUse
=
0
;
epSet
.
numOfEps
=
1
;
epSet
.
port
[
0
]
=
port
;
memcpy
(
epSet
.
fqdn
[
0
],
fqdn
,
TSDB_FQDN_LEN
);
rpcSendRequest
(
clientRpc
,
&
epSet
,
p
Msg
,
NULL
);
rpcSendRequest
(
clientRpc
,
&
epSet
,
p
Req
,
NULL
);
tsem_wait
(
&
sem
);
return
pRsp
;
...
...
source/dnode/mgmt/impl/test/sut/src/sut.cpp
浏览文件 @
ad94dff0
...
...
@@ -64,23 +64,23 @@ void Testbase::ServerStop() { server.Stop(); }
void
Testbase
::
ServerStart
()
{
server
.
DoStart
();
}
SRpcMsg
*
Testbase
::
Send
Msg
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
{
SRpcMsg
*
Testbase
::
Send
Req
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
{
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pCont
;
rpcMsg
.
contLen
=
contLen
;
rpcMsg
.
msgType
=
msgType
;
return
client
.
Send
Msg
(
&
rpcMsg
);
return
client
.
Send
Req
(
&
rpcMsg
);
}
void
Testbase
::
SendShowMeta
Msg
(
int8_t
showType
,
const
char
*
db
)
{
int32_t
contLen
=
sizeof
(
SShow
Msg
);
SShow
Msg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
contLen
);
void
Testbase
::
SendShowMeta
Req
(
int8_t
showType
,
const
char
*
db
)
{
int32_t
contLen
=
sizeof
(
SShow
Req
);
SShow
Req
*
pShow
=
(
SShowReq
*
)
rpcMallocCont
(
contLen
);
pShow
->
type
=
showType
;
strcpy
(
pShow
->
db
,
db
);
SRpcMsg
*
p
Msg
=
SendMsg
(
TDMT_MND_SHOW
,
pShow
,
contLen
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
p
Msg
->
pCont
;
SRpcMsg
*
p
Rsp
=
SendReq
(
TDMT_MND_SHOW
,
pShow
,
contLen
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
p
Rsp
->
pCont
;
ASSERT
(
pShowRsp
!=
nullptr
);
pShowRsp
->
showId
=
htobe64
(
pShowRsp
->
showId
);
...
...
@@ -121,15 +121,15 @@ int32_t Testbase::GetMetaNum() { return pMeta->numOfColumns; }
const
char
*
Testbase
::
GetMetaTbName
()
{
return
pMeta
->
tbFname
;
}
void
Testbase
::
SendShowRetrieve
Msg
()
{
int32_t
contLen
=
sizeof
(
SRetrieveTable
Msg
);
void
Testbase
::
SendShowRetrieve
Req
()
{
int32_t
contLen
=
sizeof
(
SRetrieveTable
Req
);
SRetrieveTable
Msg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
contLen
);
SRetrieveTable
Req
*
pRetrieve
=
(
SRetrieveTableReq
*
)
rpcMallocCont
(
contLen
);
pRetrieve
->
showId
=
htobe64
(
showId
);
pRetrieve
->
free
=
0
;
SRpcMsg
*
p
Msg
=
SendMsg
(
TDMT_MND_SHOW_RETRIEVE
,
pRetrieve
,
contLen
);
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
p
Msg
->
pCont
;
SRpcMsg
*
p
Rsp
=
SendReq
(
TDMT_MND_SHOW_RETRIEVE
,
pRetrieve
,
contLen
);
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
p
Rsp
->
pCont
;
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
pRetrieveRsp
->
useconds
=
htobe64
(
pRetrieveRsp
->
useconds
);
pRetrieveRsp
->
compLen
=
htonl
(
pRetrieveRsp
->
compLen
);
...
...
source/dnode/mgmt/impl/test/vgroup/vgroup.cpp
浏览文件 @
ad94dff0
...
...
@@ -60,9 +60,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
pReplica
->
port
=
htons
(
9150
);
}
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_CREATE_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_CREATE_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
...
...
@@ -100,9 +100,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
pReplica
->
port
=
htons
(
9150
);
}
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_ALTER_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_ALTER_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
...
...
@@ -121,9 +121,9 @@ TEST_F(DndTestVgroup, 01_Create_Restart_Drop_Vnode) {
rpcMsg
.
contLen
=
sizeof
(
SDropVnodeMsg
);
rpcMsg
.
msgType
=
TDMT_DND_DROP_VNODE
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_DND_DROP_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_DND_DROP_VNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
}
source/dnode/mnode/impl/src/mndAcct.c
浏览文件 @
ad94dff0
...
...
@@ -26,9 +26,9 @@ static SSdbRow *mndAcctActionDecode(SSdbRaw *pRaw);
static
int32_t
mndAcctActionInsert
(
SSdb
*
pSdb
,
SAcctObj
*
pAcct
);
static
int32_t
mndAcctActionDelete
(
SSdb
*
pSdb
,
SAcctObj
*
pAcct
);
static
int32_t
mndAcctActionUpdate
(
SSdb
*
pSdb
,
SAcctObj
*
pOld
,
SAcctObj
*
pNew
);
static
int32_t
mndProcessCreateAcctReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessAlterAcctReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropAcctReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateAcctReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessAlterAcctReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropAcctReq
(
SMnodeMsg
*
p
Req
);
int32_t
mndInitAcct
(
SMnode
*
pMnode
)
{
SSdbTable
table
=
{.
sdbType
=
SDB_ACCT
,
...
...
@@ -185,19 +185,19 @@ static int32_t mndAcctActionUpdate(SSdb *pSdb, SAcctObj *pOld, SAcctObj *pNew) {
return
0
;
}
static
int32_t
mndProcessCreateAcctReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessCreateAcctReq
(
SMnodeMsg
*
p
Req
)
{
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
}
static
int32_t
mndProcessAlterAcctReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessAlterAcctReq
(
SMnodeMsg
*
p
Req
)
{
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
}
static
int32_t
mndProcessDropAcctReq
(
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndProcessDropAcctReq
(
SMnodeMsg
*
p
Req
)
{
terrno
=
TSDB_CODE_MND_MSG_NOT_PROCESSED
;
mError
(
"failed to process create acct request since %s"
,
terrstr
());
return
-
1
;
...
...
source/dnode/mnode/impl/src/mndBnode.c
浏览文件 @
ad94dff0
...
...
@@ -27,12 +27,12 @@ static SSdbRow *mndBnodeActionDecode(SSdbRaw *pRaw);
static
int32_t
mndBnodeActionInsert
(
SSdb
*
pSdb
,
SBnodeObj
*
pObj
);
static
int32_t
mndBnodeActionDelete
(
SSdb
*
pSdb
,
SBnodeObj
*
pObj
);
static
int32_t
mndBnodeActionUpdate
(
SSdb
*
pSdb
,
SBnodeObj
*
pOld
,
SBnodeObj
*
pNew
);
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateBnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropBnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndGetBnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveBnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessCreateBnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndProcessDropBnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndGetBnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveBnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextBnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitBnode
(
SMnode
*
pMnode
)
{
...
...
@@ -185,22 +185,22 @@ static int32_t mndSetCreateBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) {
}
static
int32_t
mndSetCreateBnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
SDCreateBnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDCreateBnodeReq
));
if
(
p
Msg
==
NULL
)
{
SDCreateBnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDCreateBnodeReq
));
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDCreateBnodeReq
);
action
.
msgType
=
TDMT_DND_CREATE_BNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_BNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
}
...
...
@@ -208,29 +208,29 @@ static int32_t mndSetCreateBnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
}
static
int32_t
mndSetCreateBnodeUndoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
SDDropBnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropBnodeReq
));
if
(
p
Msg
==
NULL
)
{
SDDropBnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropBnodeReq
));
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropBnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_BNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
;
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
}
return
0
;
}
static
int32_t
mndCreateBnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SDnodeObj
*
pDnode
,
SMCreateBnodeReq
*
pCreate
)
{
static
int32_t
mndCreateBnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SDnodeObj
*
pDnode
,
SMCreateBnodeReq
*
pCreate
)
{
int32_t
code
=
-
1
;
SBnodeObj
bnodeObj
=
{
0
};
...
...
@@ -238,7 +238,7 @@ static int32_t mndCreateBnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
bnodeObj
.
createdTime
=
taosGetTimestampMs
();
bnodeObj
.
updateTime
=
bnodeObj
.
createdTime
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_BNODE_OVER
;
mDebug
(
"trans:%d, used to create bnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
...
...
@@ -256,9 +256,9 @@ CREATE_BNODE_OVER:
return
code
;
}
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMCreateBnodeReq
*
pCreate
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessCreateBnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMCreateBnodeReq
*
pCreate
=
p
Req
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
...
...
@@ -282,7 +282,7 @@ static int32_t mndProcessCreateBnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mndCreateBnode
(
pMnode
,
p
Msg
,
pDnode
,
pCreate
);
int32_t
code
=
mndCreateBnode
(
pMnode
,
p
Req
,
pDnode
,
pCreate
);
mndReleaseDnode
(
pMnode
,
pDnode
);
if
(
code
!=
0
)
{
...
...
@@ -310,32 +310,32 @@ static int32_t mndSetDropBnodeCommitLogs(STrans *pTrans, SBnodeObj *pObj) {
}
static
int32_t
mndSetDropBnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SBnodeObj
*
pObj
)
{
SDDropBnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropBnodeReq
));
if
(
p
Msg
==
NULL
)
{
SDDropBnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropBnodeReq
));
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropBnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_BNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_BNODE_NOT_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
}
return
0
;
}
static
int32_t
mndDropBnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SBnodeObj
*
pObj
)
{
static
int32_t
mndDropBnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SBnodeObj
*
pObj
)
{
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_BNODE_OVER
;
mDebug
(
"trans:%d, used to drop bnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
...
...
@@ -351,9 +351,9 @@ DROP_BNODE_OVER:
return
code
;
}
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMDropBnodeReq
*
pDrop
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessDropBnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMDropBnodeReq
*
pDrop
=
p
Req
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"bnode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
...
@@ -370,7 +370,7 @@ static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mndDropBnode
(
pMnode
,
p
Msg
,
pObj
);
int32_t
code
=
mndDropBnode
(
pMnode
,
p
Req
,
pObj
);
if
(
code
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
mError
(
"bnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
...
...
@@ -381,18 +381,18 @@ static int32_t mndProcessDropBnodeReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessCreateBnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
mndTransProcessRsp
(
p
Msg
);
static
int32_t
mndProcessCreateBnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Rsp
);
return
0
;
}
static
int32_t
mndProcessDropBnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
mndTransProcessRsp
(
p
Msg
);
static
int32_t
mndProcessDropBnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Rsp
);
return
0
;
}
static
int32_t
mndGetBnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndGetBnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
...
...
@@ -431,8 +431,8 @@ static int32_t mndGetBnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
}
static
int32_t
mndRetrieveBnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndRetrieveBnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
...
...
source/dnode/mnode/impl/src/mndQnode.c
浏览文件 @
ad94dff0
...
...
@@ -27,12 +27,12 @@ static SSdbRow *mndQnodeActionDecode(SSdbRaw *pRaw);
static
int32_t
mndQnodeActionInsert
(
SSdb
*
pSdb
,
SQnodeObj
*
pObj
);
static
int32_t
mndQnodeActionDelete
(
SSdb
*
pSdb
,
SQnodeObj
*
pObj
);
static
int32_t
mndQnodeActionUpdate
(
SSdb
*
pSdb
,
SQnodeObj
*
pOld
,
SQnodeObj
*
pNew
);
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateQnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropQnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndGetQnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveQnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessCreateQnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndProcessDropQnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndGetQnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveQnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextQnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitQnode
(
SMnode
*
pMnode
)
{
...
...
@@ -185,22 +185,22 @@ static int32_t mndSetCreateQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
}
static
int32_t
mndSetCreateQnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
SDCreateQnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDCreateQnodeReq
));
if
(
p
Msg
==
NULL
)
{
SDCreateQnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDCreateQnodeReq
));
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDCreateQnodeReq
);
action
.
msgType
=
TDMT_DND_CREATE_QNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
}
...
...
@@ -208,29 +208,29 @@ static int32_t mndSetCreateQnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
}
static
int32_t
mndSetCreateQnodeUndoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
SDDropQnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropQnodeReq
));
if
(
p
Msg
==
NULL
)
{
SDDropQnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropQnodeReq
));
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropQnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_QNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
;
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
}
return
0
;
}
static
int32_t
mndCreateQnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SDnodeObj
*
pDnode
,
SMCreateQnodeReq
*
pCreate
)
{
static
int32_t
mndCreateQnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SDnodeObj
*
pDnode
,
SMCreateQnodeReq
*
pCreate
)
{
int32_t
code
=
-
1
;
SQnodeObj
qnodeObj
=
{
0
};
...
...
@@ -238,7 +238,7 @@ static int32_t mndCreateQnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
qnodeObj
.
createdTime
=
taosGetTimestampMs
();
qnodeObj
.
updateTime
=
qnodeObj
.
createdTime
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_QNODE_OVER
;
mDebug
(
"trans:%d, used to create qnode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
...
...
@@ -256,9 +256,9 @@ CREATE_QNODE_OVER:
return
code
;
}
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMCreateQnodeReq
*
pCreate
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessCreateQnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMCreateQnodeReq
*
pCreate
=
p
Req
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
...
...
@@ -282,7 +282,7 @@ static int32_t mndProcessCreateQnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mndCreateQnode
(
pMnode
,
p
Msg
,
pDnode
,
pCreate
);
int32_t
code
=
mndCreateQnode
(
pMnode
,
p
Req
,
pDnode
,
pCreate
);
mndReleaseDnode
(
pMnode
,
pDnode
);
if
(
code
!=
0
)
{
...
...
@@ -310,32 +310,32 @@ static int32_t mndSetDropQnodeCommitLogs(STrans *pTrans, SQnodeObj *pObj) {
}
static
int32_t
mndSetDropQnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SQnodeObj
*
pObj
)
{
SDDropQnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropQnodeReq
));
if
(
p
Msg
==
NULL
)
{
SDDropQnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropQnodeReq
));
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropQnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_QNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_QNODE_NOT_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
}
return
0
;
}
static
int32_t
mndDropQnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SQnodeObj
*
pObj
)
{
static
int32_t
mndDropQnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SQnodeObj
*
pObj
)
{
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_QNODE_OVER
;
mDebug
(
"trans:%d, used to drop qnode:%d"
,
pTrans
->
id
,
pObj
->
id
);
...
...
@@ -351,9 +351,9 @@ DROP_QNODE_OVER:
return
code
;
}
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMDropQnodeReq
*
pDrop
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessDropQnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMDropQnodeReq
*
pDrop
=
p
Req
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"qnode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
...
@@ -370,7 +370,7 @@ static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mndDropQnode
(
pMnode
,
p
Msg
,
pObj
);
int32_t
code
=
mndDropQnode
(
pMnode
,
p
Req
,
pObj
);
if
(
code
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
mError
(
"qnode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
...
...
@@ -381,18 +381,18 @@ static int32_t mndProcessDropQnodeReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessCreateQnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
mndTransProcessRsp
(
p
Msg
);
static
int32_t
mndProcessCreateQnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Rsp
);
return
0
;
}
static
int32_t
mndProcessDropQnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
mndTransProcessRsp
(
p
Msg
);
static
int32_t
mndProcessDropQnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Rsp
);
return
0
;
}
static
int32_t
mndGetQnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndGetQnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
...
...
@@ -431,8 +431,8 @@ static int32_t mndGetQnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
}
static
int32_t
mndRetrieveQnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndRetrieveQnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
ad94dff0
...
...
@@ -18,12 +18,12 @@
#define SHOW_STEP_SIZE 100
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SShow
Msg
*
pMsg
);
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SShow
Req
*
pReq
);
static
void
mndFreeShowObj
(
SShowObj
*
pShow
);
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int64_t
showId
);
static
void
mndReleaseShowObj
(
SShowObj
*
pShow
,
bool
forceRemove
);
static
int32_t
mndProcessShowReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessRetrieveReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessShowReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessRetrieveReq
(
SMnodeMsg
*
p
Req
);
static
bool
mndCheckRetrieveFinished
(
SShowObj
*
pShow
);
int32_t
mndInitShow
(
SMnode
*
pMnode
)
{
...
...
@@ -49,20 +49,20 @@ void mndCleanupShow(SMnode *pMnode) {
}
}
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SShow
Msg
*
pMsg
)
{
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SShow
Req
*
pReq
)
{
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
int64_t
showId
=
atomic_add_fetch_64
(
&
pMgmt
->
showId
,
1
);
if
(
showId
==
0
)
atomic_add_fetch_64
(
&
pMgmt
->
showId
,
1
);
int32_t
size
=
sizeof
(
SShowObj
)
+
p
Msg
->
payloadLen
;
int32_t
size
=
sizeof
(
SShowObj
)
+
p
Req
->
payloadLen
;
SShowObj
showObj
=
{
0
};
showObj
.
id
=
showId
;
showObj
.
pMnode
=
pMnode
;
showObj
.
type
=
p
Msg
->
type
;
showObj
.
payloadLen
=
p
Msg
->
payloadLen
;
memcpy
(
showObj
.
db
,
p
Msg
->
db
,
TSDB_DB_FNAME_LEN
);
memcpy
(
showObj
.
payload
,
p
Msg
->
payload
,
pMsg
->
payloadLen
);
showObj
.
type
=
p
Req
->
type
;
showObj
.
payloadLen
=
p
Req
->
payloadLen
;
memcpy
(
showObj
.
db
,
p
Req
->
db
,
TSDB_DB_FNAME_LEN
);
memcpy
(
showObj
.
payload
,
p
Req
->
payload
,
pReq
->
payloadLen
);
int32_t
keepTime
=
pMnode
->
cfg
.
shellActivityTimer
*
6
*
1000
;
SShowObj
*
pShow
=
taosCachePut
(
pMgmt
->
cache
,
&
showId
,
sizeof
(
int64_t
),
&
showObj
,
size
,
keepTime
);
...
...
@@ -115,12 +115,12 @@ static void mndReleaseShowObj(SShowObj *pShow, bool forceRemove) {
taosCacheRelease
(
pMgmt
->
cache
,
(
void
**
)(
&
pShow
),
forceRemove
);
}
static
int32_t
mndProcessShowReq
(
SMnodeMsg
*
p
MnodeMsg
)
{
SMnode
*
pMnode
=
p
MnodeMsg
->
pMnode
;
static
int32_t
mndProcessShowReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
SShow
Msg
*
pMsg
=
pMnodeMsg
->
rpcMsg
.
pCont
;
int8_t
type
=
p
Msg
->
type
;
int16_t
payloadLen
=
htonl
(
p
Msg
->
payloadLen
);
SShow
Req
*
pShowReq
=
pReq
->
rpcMsg
.
pCont
;
int8_t
type
=
p
ShowReq
->
type
;
int16_t
payloadLen
=
htonl
(
p
ShowReq
->
payloadLen
);
if
(
type
<=
TSDB_MGMT_TABLE_START
||
type
>=
TSDB_MGMT_TABLE_MAX
)
{
terrno
=
TSDB_CODE_MND_INVALID_MSG_TYPE
;
...
...
@@ -135,7 +135,7 @@ static int32_t mndProcessShowReq(SMnodeMsg *pMnodeMsg) {
return
-
1
;
}
SShowObj
*
pShow
=
mndCreateShowObj
(
pMnode
,
p
Msg
);
SShowObj
*
pShow
=
mndCreateShowObj
(
pMnode
,
p
ShowReq
);
if
(
pShow
==
NULL
)
{
mError
(
"failed to process show-meta msg:%s since %s"
,
mndShowStr
(
type
),
terrstr
());
return
-
1
;
...
...
@@ -151,13 +151,13 @@ static int32_t mndProcessShowReq(SMnodeMsg *pMnodeMsg) {
return
-
1
;
}
int32_t
code
=
(
*
metaFp
)(
p
MnodeMsg
,
pShow
,
&
pRsp
->
tableMeta
);
int32_t
code
=
(
*
metaFp
)(
p
Req
,
pShow
,
&
pRsp
->
tableMeta
);
mDebug
(
"show:0x%"
PRIx64
", get meta finished, numOfRows:%d cols:%d type:%s, result:%s"
,
pShow
->
id
,
pShow
->
numOfRows
,
pShow
->
numOfColumns
,
mndShowStr
(
type
),
tstrerror
(
code
));
if
(
code
==
TSDB_CODE_SUCCESS
)
{
p
MnodeMsg
->
contLen
=
sizeof
(
SShowRsp
)
+
sizeof
(
SSchema
)
*
pShow
->
numOfColumns
;
p
MnodeMsg
->
pCont
=
pRsp
;
p
Req
->
contLen
=
sizeof
(
SShowRsp
)
+
sizeof
(
SSchema
)
*
pShow
->
numOfColumns
;
p
Req
->
pCont
=
pRsp
;
pRsp
->
showId
=
htobe64
(
pShow
->
id
);
mndReleaseShowObj
(
pShow
,
false
);
return
TSDB_CODE_SUCCESS
;
...
...
@@ -168,14 +168,14 @@ static int32_t mndProcessShowReq(SMnodeMsg *pMnodeMsg) {
}
}
static
int32_t
mndProcessRetrieveReq
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndProcessRetrieveReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SShowMgmt
*
pMgmt
=
&
pMnode
->
showMgmt
;
int32_t
rowsToRead
=
0
;
int32_t
size
=
0
;
int32_t
rowsRead
=
0
;
SRetrieveTable
Msg
*
pRetrieve
=
pMsg
->
rpcMsg
.
pCont
;
SRetrieveTable
Req
*
pRetrieve
=
pReq
->
rpcMsg
.
pCont
;
int64_t
showId
=
htobe64
(
pRetrieve
->
showId
);
SShowObj
*
pShow
=
mndAcquireShowObj
(
pMnode
,
showId
);
...
...
@@ -227,7 +227,7 @@ static int32_t mndProcessRetrieveReq(SMnodeMsg *pMsg) {
// if free flag is set, client wants to clean the resources
if
((
pRetrieve
->
free
&
TSDB_QUERY_TYPE_FREE_RESOURCE
)
!=
TSDB_QUERY_TYPE_FREE_RESOURCE
)
{
rowsRead
=
(
*
retrieveFp
)(
p
Msg
,
pShow
,
pRsp
->
data
,
rowsToRead
);
rowsRead
=
(
*
retrieveFp
)(
p
Req
,
pShow
,
pRsp
->
data
,
rowsToRead
);
}
mDebug
(
"show:0x%"
PRIx64
", stop retrieve data, rowsRead:%d rowsToRead:%d"
,
pShow
->
id
,
rowsRead
,
rowsToRead
);
...
...
@@ -235,8 +235,8 @@ static int32_t mndProcessRetrieveReq(SMnodeMsg *pMsg) {
pRsp
->
numOfRows
=
htonl
(
rowsRead
);
pRsp
->
precision
=
TSDB_TIME_PRECISION_MILLI
;
// millisecond time precision
p
Msg
->
pCont
=
pRsp
;
p
Msg
->
contLen
=
size
;
p
Req
->
pCont
=
pRsp
;
p
Req
->
contLen
=
size
;
if
(
rowsRead
==
0
||
rowsToRead
==
0
||
(
rowsRead
==
rowsToRead
&&
pShow
->
numOfRows
==
pShow
->
numOfReads
))
{
pRsp
->
completed
=
1
;
...
...
source/dnode/mnode/impl/src/mndSnode.c
浏览文件 @
ad94dff0
...
...
@@ -27,12 +27,12 @@ static SSdbRow *mndSnodeActionDecode(SSdbRaw *pRaw);
static
int32_t
mndSnodeActionInsert
(
SSdb
*
pSdb
,
SSnodeObj
*
pObj
);
static
int32_t
mndSnodeActionDelete
(
SSdb
*
pSdb
,
SSnodeObj
*
pObj
);
static
int32_t
mndSnodeActionUpdate
(
SSdb
*
pSdb
,
SSnodeObj
*
pOld
,
SSnodeObj
*
pNew
);
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateSnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropSnodeRsp
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndGetSnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveSnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessCreateSnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndProcessDropSnodeRsp
(
SMnodeMsg
*
p
Rsp
);
static
int32_t
mndGetSnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveSnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextSnode
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitSnode
(
SMnode
*
pMnode
)
{
...
...
@@ -185,22 +185,22 @@ static int32_t mndSetCreateSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) {
}
static
int32_t
mndSetCreateSnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
SDCreateSnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDCreateSnodeReq
));
if
(
p
Msg
==
NULL
)
{
SDCreateSnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDCreateSnodeReq
));
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDCreateSnodeReq
);
action
.
msgType
=
TDMT_DND_CREATE_SNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_SNODE_ALREADY_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
}
...
...
@@ -208,29 +208,29 @@ static int32_t mndSetCreateSnodeRedoActions(STrans *pTrans, SDnodeObj *pDnode, S
}
static
int32_t
mndSetCreateSnodeUndoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
SDDropSnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropSnodeReq
));
if
(
p
Msg
==
NULL
)
{
SDDropSnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropSnodeReq
));
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropSnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_SNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
;
if
(
mndTransAppendUndoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
}
return
0
;
}
static
int32_t
mndCreateSnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SDnodeObj
*
pDnode
,
SMCreateSnodeReq
*
pCreate
)
{
static
int32_t
mndCreateSnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SDnodeObj
*
pDnode
,
SMCreateSnodeReq
*
pCreate
)
{
int32_t
code
=
-
1
;
SSnodeObj
snodeObj
=
{
0
};
...
...
@@ -238,7 +238,7 @@ static int32_t mndCreateSnode(SMnode *pMnode, SMnodeMsg *pMsg, SDnodeObj *pDnode
snodeObj
.
createdTime
=
taosGetTimestampMs
();
snodeObj
.
updateTime
=
snodeObj
.
createdTime
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
CREATE_SNODE_OVER
;
mDebug
(
"trans:%d, used to create snode:%d"
,
pTrans
->
id
,
pCreate
->
dnodeId
);
...
...
@@ -257,9 +257,9 @@ CREATE_SNODE_OVER:
return
code
;
}
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMCreateSnodeReq
*
pCreate
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessCreateSnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMCreateSnodeReq
*
pCreate
=
p
Req
->
rpcMsg
.
pCont
;
pCreate
->
dnodeId
=
htonl
(
pCreate
->
dnodeId
);
...
...
@@ -283,7 +283,7 @@ static int32_t mndProcessCreateSnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mndCreateSnode
(
pMnode
,
p
Msg
,
pDnode
,
pCreate
);
int32_t
code
=
mndCreateSnode
(
pMnode
,
p
Req
,
pDnode
,
pCreate
);
mndReleaseDnode
(
pMnode
,
pDnode
);
if
(
code
!=
0
)
{
...
...
@@ -311,32 +311,32 @@ static int32_t mndSetDropSnodeCommitLogs(STrans *pTrans, SSnodeObj *pObj) {
}
static
int32_t
mndSetDropSnodeRedoActions
(
STrans
*
pTrans
,
SDnodeObj
*
pDnode
,
SSnodeObj
*
pObj
)
{
SDDropSnodeReq
*
p
Msg
=
malloc
(
sizeof
(
SDDropSnodeReq
));
if
(
p
Msg
==
NULL
)
{
SDDropSnodeReq
*
p
Req
=
malloc
(
sizeof
(
SDDropSnodeReq
));
if
(
p
Req
==
NULL
)
{
terrno
=
TSDB_CODE_OUT_OF_MEMORY
;
return
-
1
;
}
p
Msg
->
dnodeId
=
htonl
(
pDnode
->
id
);
p
Req
->
dnodeId
=
htonl
(
pDnode
->
id
);
STransAction
action
=
{
0
};
action
.
epSet
=
mndGetDnodeEpset
(
pDnode
);
action
.
pCont
=
p
Msg
;
action
.
pCont
=
p
Req
;
action
.
contLen
=
sizeof
(
SDDropSnodeReq
);
action
.
msgType
=
TDMT_DND_DROP_SNODE
;
action
.
acceptableCode
=
TSDB_CODE_DND_SNODE_NOT_DEPLOYED
;
if
(
mndTransAppendRedoAction
(
pTrans
,
&
action
)
!=
0
)
{
free
(
p
Msg
);
free
(
p
Req
);
return
-
1
;
}
return
0
;
}
static
int32_t
mndDropSnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SSnodeObj
*
pObj
)
{
static
int32_t
mndDropSnode
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SSnodeObj
*
pObj
)
{
int32_t
code
=
-
1
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_RETRY
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
goto
DROP_SNODE_OVER
;
mDebug
(
"trans:%d, used to drop snode:%d"
,
pTrans
->
id
,
pObj
->
id
);
...
...
@@ -353,9 +353,9 @@ DROP_SNODE_OVER:
return
code
;
}
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SMDropSnodeReq
*
pDrop
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessDropSnodeReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SMDropSnodeReq
*
pDrop
=
p
Req
->
rpcMsg
.
pCont
;
pDrop
->
dnodeId
=
htonl
(
pDrop
->
dnodeId
);
mDebug
(
"snode:%d, start to drop"
,
pDrop
->
dnodeId
);
...
...
@@ -372,7 +372,7 @@ static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mndDropSnode
(
pMnode
,
p
Msg
,
pObj
);
int32_t
code
=
mndDropSnode
(
pMnode
,
p
Req
,
pObj
);
if
(
code
!=
0
)
{
sdbRelease
(
pMnode
->
pSdb
,
pObj
);
mError
(
"snode:%d, failed to drop since %s"
,
pMnode
->
dnodeId
,
terrstr
());
...
...
@@ -383,18 +383,18 @@ static int32_t mndProcessDropSnodeReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndProcessCreateSnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
mndTransProcessRsp
(
p
Msg
);
static
int32_t
mndProcessCreateSnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Rsp
);
return
0
;
}
static
int32_t
mndProcessDropSnodeRsp
(
SMnodeMsg
*
p
Msg
)
{
mndTransProcessRsp
(
p
Msg
);
static
int32_t
mndProcessDropSnodeRsp
(
SMnodeMsg
*
p
Rsp
)
{
mndTransProcessRsp
(
p
Rsp
);
return
0
;
}
static
int32_t
mndGetSnodeMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndGetSnodeMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
...
...
@@ -433,8 +433,8 @@ static int32_t mndGetSnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
return
0
;
}
static
int32_t
mndRetrieveSnodes
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndRetrieveSnodes
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
int32_t
cols
=
0
;
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
ad94dff0
...
...
@@ -28,12 +28,12 @@ static SSdbRow *mndUserActionDecode(SSdbRaw *pRaw);
static
int32_t
mndUserActionInsert
(
SSdb
*
pSdb
,
SUserObj
*
pUser
);
static
int32_t
mndUserActionDelete
(
SSdb
*
pSdb
,
SUserObj
*
pUser
);
static
int32_t
mndUserActionUpdate
(
SSdb
*
pSdb
,
SUserObj
*
pOld
,
SUserObj
*
pNew
);
static
int32_t
mndCreateUser
(
SMnode
*
pMnode
,
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessCreateUserReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessAlterUserReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndProcessDropUserReq
(
SMnodeMsg
*
p
Msg
);
static
int32_t
mndGetUserMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveUsers
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
int32_t
mndCreateUser
(
SMnode
*
pMnode
,
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessCreateUserReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessAlterUserReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndProcessDropUserReq
(
SMnodeMsg
*
p
Req
);
static
int32_t
mndGetUserMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
);
static
int32_t
mndRetrieveUsers
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
);
static
void
mndCancelGetNextUser
(
SMnode
*
pMnode
,
void
*
pIter
);
int32_t
mndInitUser
(
SMnode
*
pMnode
)
{
...
...
@@ -212,7 +212,7 @@ void mndReleaseUser(SMnode *pMnode, SUserObj *pUser) {
sdbRelease
(
pSdb
,
pUser
);
}
static
int32_t
mndCreateUser
(
SMnode
*
pMnode
,
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
p
Msg
)
{
static
int32_t
mndCreateUser
(
SMnode
*
pMnode
,
char
*
acct
,
char
*
user
,
char
*
pass
,
SMnodeMsg
*
p
Req
)
{
SUserObj
userObj
=
{
0
};
tstrncpy
(
userObj
.
user
,
user
,
TSDB_USER_LEN
);
tstrncpy
(
userObj
.
acct
,
acct
,
TSDB_USER_LEN
);
...
...
@@ -221,7 +221,7 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
userObj
.
updateTime
=
userObj
.
createdTime
;
userObj
.
superUser
=
0
;
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"user:%s, failed to create since %s"
,
user
,
terrstr
());
return
-
1
;
...
...
@@ -246,9 +246,9 @@ static int32_t mndCreateUser(SMnode *pMnode, char *acct, char *user, char *pass,
return
0
;
}
static
int32_t
mndProcessCreateUserReq
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SCreateUserReq
*
pCreate
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessCreateUserReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SCreateUserReq
*
pCreate
=
p
Req
->
rpcMsg
.
pCont
;
mDebug
(
"user:%s, start to create"
,
pCreate
->
user
);
...
...
@@ -272,14 +272,14 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) {
return
-
1
;
}
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pOperUser
==
NULL
)
{
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
mError
(
"user:%s, failed to create since %s"
,
pCreate
->
user
,
terrstr
());
return
-
1
;
}
int32_t
code
=
mndCreateUser
(
pMnode
,
pOperUser
->
acct
,
pCreate
->
user
,
pCreate
->
pass
,
p
Msg
);
int32_t
code
=
mndCreateUser
(
pMnode
,
pOperUser
->
acct
,
pCreate
->
user
,
pCreate
->
pass
,
p
Req
);
mndReleaseUser
(
pMnode
,
pOperUser
);
if
(
code
!=
0
)
{
...
...
@@ -290,8 +290,8 @@ static int32_t mndProcessCreateUserReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndUpdateUser
(
SMnode
*
pMnode
,
SUserObj
*
pOld
,
SUserObj
*
pNew
,
SMnodeMsg
*
p
Msg
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
static
int32_t
mndUpdateUser
(
SMnode
*
pMnode
,
SUserObj
*
pOld
,
SUserObj
*
pNew
,
SMnodeMsg
*
p
Req
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"user:%s, failed to update since %s"
,
pOld
->
user
,
terrstr
());
return
-
1
;
...
...
@@ -316,9 +316,9 @@ static int32_t mndUpdateUser(SMnode *pMnode, SUserObj *pOld, SUserObj *pNew, SMn
return
0
;
}
static
int32_t
mndProcessAlterUserReq
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SAlterUserReq
*
pAlter
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessAlterUserReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SAlterUserReq
*
pAlter
=
p
Req
->
rpcMsg
.
pCont
;
mDebug
(
"user:%s, start to alter"
,
pAlter
->
user
);
...
...
@@ -341,7 +341,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
return
-
1
;
}
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pOperUser
==
NULL
)
{
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
...
...
@@ -355,7 +355,7 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
taosEncryptPass
((
uint8_t
*
)
pAlter
->
pass
,
strlen
(
pAlter
->
pass
),
pUser
->
pass
);
newUser
.
updateTime
=
taosGetTimestampMs
();
int32_t
code
=
mndUpdateUser
(
pMnode
,
pUser
,
&
newUser
,
p
Msg
);
int32_t
code
=
mndUpdateUser
(
pMnode
,
pUser
,
&
newUser
,
p
Req
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pUser
);
...
...
@@ -367,8 +367,8 @@ static int32_t mndProcessAlterUserReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndDropUser
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Msg
,
SUserObj
*
pUser
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Msg
->
rpcMsg
);
static
int32_t
mndDropUser
(
SMnode
*
pMnode
,
SMnodeMsg
*
p
Req
,
SUserObj
*
pUser
)
{
STrans
*
pTrans
=
mndTransCreate
(
pMnode
,
TRN_POLICY_ROLLBACK
,
&
p
Req
->
rpcMsg
);
if
(
pTrans
==
NULL
)
{
mError
(
"user:%s, failed to drop since %s"
,
pUser
->
user
,
terrstr
());
return
-
1
;
...
...
@@ -393,9 +393,9 @@ static int32_t mndDropUser(SMnode *pMnode, SMnodeMsg *pMsg, SUserObj *pUser) {
return
0
;
}
static
int32_t
mndProcessDropUserReq
(
SMnodeMsg
*
p
Msg
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
SDropUserReq
*
pDrop
=
p
Msg
->
rpcMsg
.
pCont
;
static
int32_t
mndProcessDropUserReq
(
SMnodeMsg
*
p
Req
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SDropUserReq
*
pDrop
=
p
Req
->
rpcMsg
.
pCont
;
mDebug
(
"user:%s, start to drop"
,
pDrop
->
user
);
...
...
@@ -412,7 +412,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
return
-
1
;
}
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Msg
->
user
);
SUserObj
*
pOperUser
=
mndAcquireUser
(
pMnode
,
p
Req
->
user
);
if
(
pOperUser
==
NULL
)
{
mndReleaseUser
(
pMnode
,
pUser
);
terrno
=
TSDB_CODE_MND_NO_USER_FROM_CONN
;
...
...
@@ -420,7 +420,7 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
return
-
1
;
}
int32_t
code
=
mndDropUser
(
pMnode
,
p
Msg
,
pUser
);
int32_t
code
=
mndDropUser
(
pMnode
,
p
Req
,
pUser
);
mndReleaseUser
(
pMnode
,
pOperUser
);
mndReleaseUser
(
pMnode
,
pUser
);
...
...
@@ -432,8 +432,8 @@ static int32_t mndProcessDropUserReq(SMnodeMsg *pMsg) {
return
TSDB_CODE_MND_ACTION_IN_PROGRESS
;
}
static
int32_t
mndGetUserMeta
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndGetUserMeta
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
STableMetaMsg
*
pMeta
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
cols
=
0
;
...
...
@@ -478,8 +478,8 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
return
0
;
}
static
int32_t
mndRetrieveUsers
(
SMnodeMsg
*
p
Msg
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Msg
->
pMnode
;
static
int32_t
mndRetrieveUsers
(
SMnodeMsg
*
p
Req
,
SShowObj
*
pShow
,
char
*
data
,
int32_t
rows
)
{
SMnode
*
pMnode
=
p
Req
->
pMnode
;
SSdb
*
pSdb
=
pMnode
->
pSdb
;
int32_t
numOfRows
=
0
;
SUserObj
*
pUser
=
NULL
;
...
...
source/dnode/mnode/impl/test/acct/acct.cpp
浏览文件 @
ad94dff0
...
...
@@ -30,9 +30,9 @@ TEST_F(MndTestAcct, 01_Create_Acct) {
SCreateAcctReq
*
pReq
=
(
SCreateAcctReq
*
)
rpcMallocCont
(
contLen
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
TEST_F
(
MndTestAcct
,
02
_Alter_Acct
)
{
...
...
@@ -40,9 +40,9 @@ TEST_F(MndTestAcct, 02_Alter_Acct) {
SAlterAcctReq
*
pReq
=
(
SAlterAcctReq
*
)
rpcMallocCont
(
contLen
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
TEST_F
(
MndTestAcct
,
03
_Drop_Acct
)
{
...
...
@@ -50,18 +50,18 @@ TEST_F(MndTestAcct, 03_Drop_Acct) {
SDropAcctReq
*
pReq
=
(
SDropAcctReq
*
)
rpcMallocCont
(
contLen
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_ACCT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
TEST_F
(
MndTestAcct
,
04
_Show_Acct
)
{
int32_t
contLen
=
sizeof
(
SShow
Msg
);
int32_t
contLen
=
sizeof
(
SShow
Req
);
SShow
Msg
*
pReq
=
(
SShowMsg
*
)
rpcMallocCont
(
contLen
);
SShow
Req
*
pReq
=
(
SShowReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
type
=
TSDB_MGMT_TABLE_ACCT
;
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
}
\ No newline at end of file
source/dnode/mnode/impl/test/bnode/bnode.cpp
浏览文件 @
ad94dff0
...
...
@@ -39,14 +39,14 @@ Testbase MndTestBnode::test;
TestServer
MndTestBnode
::
server2
;
TEST_F
(
MndTestBnode
,
01
_Show_Bnode
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_BNODE
,
""
);
CHECK_META
(
"show bnodes"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
...
...
@@ -57,9 +57,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
{
...
...
@@ -68,13 +68,13 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_BNODE
,
""
);
CHECK_META
(
"show bnodes"
,
3
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
...
...
@@ -88,9 +88,9 @@ TEST_F(MndTestBnode, 02_Create_Bnode) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_BNODE_ALREADY_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_BNODE_ALREADY_EXIST
);
}
}
...
...
@@ -102,13 +102,13 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9019
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
...
...
@@ -118,12 +118,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
...
...
@@ -140,12 +140,12 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_BNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
...
...
@@ -159,9 +159,9 @@ TEST_F(MndTestBnode, 03_Drop_Bnode) {
SMDropBnodeReq
*
pReq
=
(
SMDropBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_BNODE_NOT_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_BNODE_NOT_EXIST
);
}
}
...
...
@@ -174,9 +174,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
{
...
...
@@ -187,9 +187,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
{
...
...
@@ -200,9 +200,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
{
...
...
@@ -219,9 +219,9 @@ TEST_F(MndTestBnode, 03_Create_Bnode_Rollback) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
}
...
...
@@ -238,9 +238,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
{
...
...
@@ -251,9 +251,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
{
...
...
@@ -264,9 +264,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
{
...
...
@@ -283,9 +283,9 @@ TEST_F(MndTestBnode, 04_Drop_Bnode_Rollback) {
SMCreateBnodeReq
*
pReq
=
(
SMCreateBnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_BNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
}
...
...
source/dnode/mnode/impl/test/qnode/qnode.cpp
浏览文件 @
ad94dff0
...
...
@@ -39,14 +39,14 @@ Testbase MndTestQnode::test;
TestServer
MndTestQnode
::
server2
;
TEST_F
(
MndTestQnode
,
01
_Show_Qnode
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
...
...
@@ -57,9 +57,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
{
...
...
@@ -68,13 +68,13 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_QNODE
,
""
);
CHECK_META
(
"show qnodes"
,
3
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
...
...
@@ -88,9 +88,9 @@ TEST_F(MndTestQnode, 02_Create_Qnode) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_QNODE_ALREADY_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_QNODE_ALREADY_EXIST
);
}
}
...
...
@@ -102,13 +102,13 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9015
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
...
...
@@ -118,12 +118,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
...
...
@@ -140,12 +140,12 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_QNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
...
...
@@ -159,9 +159,9 @@ TEST_F(MndTestQnode, 03_Drop_Qnode) {
SMDropQnodeReq
*
pReq
=
(
SMDropQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_QNODE_NOT_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_QNODE_NOT_EXIST
);
}
}
...
...
@@ -174,9 +174,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
{
...
...
@@ -187,9 +187,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
{
...
...
@@ -200,9 +200,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
{
...
...
@@ -219,9 +219,9 @@ TEST_F(MndTestQnode, 03_Create_Qnode_Rollback) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
}
...
...
@@ -238,9 +238,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
{
...
...
@@ -251,9 +251,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
{
...
...
@@ -264,9 +264,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
{
...
...
@@ -283,9 +283,9 @@ TEST_F(MndTestQnode, 04_Drop_Qnode_Rollback) {
SMCreateQnodeReq
*
pReq
=
(
SMCreateQnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_QNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
}
...
...
source/dnode/mnode/impl/test/show/show.cpp
浏览文件 @
ad94dff0
...
...
@@ -26,27 +26,27 @@ class MndTestShow : public ::testing::Test {
Testbase
MndTestShow
::
test
;
TEST_F
(
MndTestShow
,
01
_ShowMsg_InvalidMsgMax
)
{
int32_t
contLen
=
sizeof
(
SShow
Msg
);
int32_t
contLen
=
sizeof
(
SShow
Req
);
SShow
Msg
*
pReq
=
(
SShowMsg
*
)
rpcMallocCont
(
contLen
);
SShow
Req
*
pReq
=
(
SShowReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
type
=
TSDB_MGMT_TABLE_MAX
;
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
}
TEST_F
(
MndTestShow
,
02
_ShowMsg_InvalidMsgStart
)
{
int32_t
contLen
=
sizeof
(
SShow
Msg
);
int32_t
contLen
=
sizeof
(
SShow
Req
);
SShow
Msg
*
pReq
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
SShow
Req
*
pReq
=
(
SShowReq
*
)
rpcMallocCont
(
sizeof
(
SShowReq
));
pReq
->
type
=
TSDB_MGMT_TABLE_START
;
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_SHOW
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_MSG_TYPE
);
}
TEST_F
(
MndTestShow
,
03
_ShowMsg_Conn
)
{
...
...
@@ -57,11 +57,11 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
strcpy
(
pReq
->
app
,
"mnode_test_show"
);
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CONNECT
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_CONNS
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_CONNS
,
""
);
STableMetaMsg
*
pMeta
=
test
.
GetShowMeta
();
EXPECT_STREQ
(
pMeta
->
tbFname
,
"show connections"
);
...
...
@@ -75,7 +75,7 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
EXPECT_EQ
(
pMeta
->
tuid
,
0
);
EXPECT_EQ
(
pMeta
->
suid
,
0
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
SRetrieveTableRsp
*
pRetrieveRsp
=
test
.
GetRetrieveRsp
();
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
1
);
...
...
@@ -87,13 +87,13 @@ TEST_F(MndTestShow, 03_ShowMsg_Conn) {
}
TEST_F
(
MndTestShow
,
04
_ShowMsg_Cluster
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_CLUSTER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_CLUSTER
,
""
);
CHECK_META
(
"show cluster"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BIGINT
,
8
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_CLUSTER_ID_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
IgnoreInt64
();
...
...
source/dnode/mnode/impl/test/snode/snode.cpp
浏览文件 @
ad94dff0
...
...
@@ -39,14 +39,14 @@ Testbase MndTestSnode::test;
TestServer
MndTestSnode
::
server2
;
TEST_F
(
MndTestSnode
,
01
_Show_Snode
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_SNODE
,
""
);
CHECK_META
(
"show snodes"
,
3
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CHECK_SCHEMA
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"endpoint"
);
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
0
);
}
...
...
@@ -57,9 +57,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_DNODE_NOT_EXIST
);
}
{
...
...
@@ -68,13 +68,13 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_SNODE
,
""
);
CHECK_META
(
"show snodes"
,
3
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
...
...
@@ -88,9 +88,9 @@ TEST_F(MndTestSnode, 02_Create_Snode) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
1
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_SNODE_ALREADY_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_SNODE_ALREADY_EXIST
);
}
}
...
...
@@ -102,13 +102,13 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
strcpy
(
pReq
->
fqdn
,
"localhost"
);
pReq
->
port
=
htonl
(
9017
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
taosMsleep
(
1300
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_DNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
...
...
@@ -118,12 +118,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckInt16
(
1
);
...
...
@@ -140,12 +140,12 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_SNODE
,
""
);
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckInt16
(
1
);
...
...
@@ -159,9 +159,9 @@ TEST_F(MndTestSnode, 03_Drop_Snode) {
SMDropSnodeReq
*
pReq
=
(
SMDropSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_SNODE_NOT_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_SNODE_NOT_EXIST
);
}
}
...
...
@@ -174,9 +174,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
{
...
...
@@ -187,9 +187,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
{
...
...
@@ -200,9 +200,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_CREATING
);
}
{
...
...
@@ -219,9 +219,9 @@ TEST_F(MndTestSnode, 03_Create_Snode_Rollback) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
}
...
...
@@ -238,9 +238,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_RPC_NETWORK_UNAVAIL
);
}
{
...
...
@@ -251,9 +251,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
{
...
...
@@ -264,9 +264,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
pReq
->
dnodeId
=
htonl
(
2
);
server2
.
Stop
();
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_SDB_OBJ_DROPPING
);
}
{
...
...
@@ -283,9 +283,9 @@ TEST_F(MndTestSnode, 04_Drop_Snode_Rollback) {
SMCreateSnodeReq
*
pReq
=
(
SMCreateSnodeReq
*
)
rpcMallocCont
(
contLen
);
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
if
(
p
Msg
->
code
==
0
)
break
;
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_SNODE
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
if
(
p
Rsp
->
code
==
0
)
break
;
taosMsleep
(
1000
);
}
...
...
source/dnode/mnode/impl/test/trans/trans.cpp
浏览文件 @
ad94dff0
...
...
@@ -58,21 +58,21 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
KillThenRestartServer
();
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
...
...
@@ -83,4 +83,4 @@ TEST_F(MndTestTrans, 01_Create_User_Crash) {
CheckTimestamp
();
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
\ No newline at end of file
}
source/dnode/mnode/impl/test/user/user.cpp
浏览文件 @
ad94dff0
...
...
@@ -26,7 +26,7 @@ class MndTestUser : public ::testing::Test {
Testbase
MndTestUser
::
test
;
TEST_F
(
MndTestUser
,
01
_Show_User
)
{
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
CHECK_SCHEMA
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
...
...
@@ -34,7 +34,7 @@ TEST_F(MndTestUser, 01_Show_User) {
CHECK_SCHEMA
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create_time"
);
CHECK_SCHEMA
(
3
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"account"
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
...
...
@@ -51,9 +51,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
{
...
...
@@ -63,9 +63,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
}
{
...
...
@@ -75,9 +75,9 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
pReq
->
user
,
"root"
);
strcpy
(
pReq
->
pass
,
"1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_USER_ALREADY_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_USER_ALREADY_EXIST
);
}
{
...
...
@@ -87,15 +87,15 @@ TEST_F(MndTestUser, 02_Create_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
...
...
@@ -107,9 +107,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
{
...
...
@@ -119,9 +119,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
}
{
...
...
@@ -131,9 +131,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
pReq
->
user
,
"u4"
);
strcpy
(
pReq
->
pass
,
"1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
}
{
...
...
@@ -143,9 +143,9 @@ TEST_F(MndTestUser, 03_Alter_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
}
...
...
@@ -156,9 +156,9 @@ TEST_F(MndTestUser, 04_Drop_User) {
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
""
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
{
...
...
@@ -167,9 +167,9 @@ TEST_F(MndTestUser, 04_Drop_User) {
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u4"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
}
{
...
...
@@ -178,15 +178,15 @@ TEST_F(MndTestUser, 04_Drop_User) {
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
...
...
@@ -198,9 +198,9 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
{
...
...
@@ -210,15 +210,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
strcpy
(
pReq
->
user
,
"u2"
);
strcpy
(
pReq
->
pass
,
"p2"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
3
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
...
...
@@ -241,15 +241,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p2"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
3
);
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
...
...
@@ -271,15 +271,15 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
SDropUserReq
*
pReq
=
(
SDropUserReq
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
SRpcMsg
*
p
Msg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Msg
,
nullptr
);
ASSERT_EQ
(
p
Msg
->
code
,
0
);
SRpcMsg
*
p
Rsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
p
Rsp
,
nullptr
);
ASSERT_EQ
(
p
Rsp
->
code
,
0
);
}
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
...
...
@@ -294,10 +294,10 @@ TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
// restart
test
.
Restart
();
test
.
SendShowMeta
Msg
(
TSDB_MGMT_TABLE_USER
,
""
);
test
.
SendShowMeta
Req
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieve
Msg
();
test
.
SendShowRetrieve
Req
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
...
...
source/libs/parser/inc/astToMsg.h
浏览文件 @
ad94dff0
...
...
@@ -8,7 +8,7 @@
SCreateUserReq
*
buildUserManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateAcctReq
*
buildAcctManipulationMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SDropUserReq
*
buildDropUserMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
outputLen
,
int64_t
id
,
char
*
msgBuf
,
int32_t
msgLen
);
SShow
Msg
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseBasicCtx
*
pParseCtx
,
char
*
msgBuf
,
int32_t
msgLen
);
SShow
Req
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseBasicCtx
*
pParseCtx
,
char
*
msgBuf
,
int32_t
msgLen
);
SCreateDbMsg
*
buildCreateDbMsg
(
SCreateDbInfo
*
pCreateDbInfo
,
SParseBasicCtx
*
pCtx
,
SMsgBuf
*
pMsgBuf
);
SCreateStbMsg
*
buildCreateTableMsg
(
SCreateTableSql
*
pCreateTableSql
,
int32_t
*
len
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
SDropStbMsg
*
buildDropStableMsg
(
SSqlInfo
*
pInfo
,
int32_t
*
len
,
SParseBasicCtx
*
pParseCtx
,
SMsgBuf
*
pMsgBuf
);
...
...
source/libs/parser/src/astToMsg.c
浏览文件 @
ad94dff0
...
...
@@ -85,8 +85,8 @@ SDropUserReq* buildDropUserMsg(SSqlInfo* pInfo, int32_t *msgLen, int64_t id, cha
return
pMsg
;
}
SShow
Msg
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseBasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SShow
Msg
*
pShowMsg
=
calloc
(
1
,
sizeof
(
SShowMsg
));
SShow
Req
*
buildShowMsg
(
SShowInfo
*
pShowInfo
,
SParseBasicCtx
*
pCtx
,
char
*
msgBuf
,
int32_t
msgLen
)
{
SShow
Req
*
pShowMsg
=
calloc
(
1
,
sizeof
(
SShowReq
));
pShowMsg
->
type
=
pShowInfo
->
showType
;
if
(
pShowInfo
->
showType
!=
TSDB_MGMT_TABLE_VNODES
)
{
...
...
source/libs/parser/src/dCDAstProcess.c
浏览文件 @
ad94dff0
...
...
@@ -109,7 +109,7 @@ static int32_t setShowInfo(SShowInfo* pShowInfo, SParseBasicCtx* pCtx, void** ou
*
pEpSet
=
pCtx
->
mgmtEpSet
;
*
output
=
buildShowMsg
(
pShowInfo
,
pCtx
,
pMsgBuf
->
buf
,
pMsgBuf
->
len
);
*
outputLen
=
sizeof
(
SShow
Msg
)
/* + htons(pShowMsg->payloadLen)*/
;
*
outputLen
=
sizeof
(
SShow
Req
)
/* + htons(pShowMsg->payloadLen)*/
;
}
return
TSDB_CODE_SUCCESS
;
...
...
src/client/src/tscServer.c
浏览文件 @
ad94dff0
...
...
@@ -603,7 +603,7 @@ int tscBuildAndSendRequest(SSqlObj *pSql, SQueryInfo* pQueryInfo) {
}
int
tscBuildFetchMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SRetrieveTable
Msg
*
pRetrieveMsg
=
(
SRetrieveTableMsg
*
)
pSql
->
cmd
.
payload
;
SRetrieveTable
Req
*
pRetrieveMsg
=
(
SRetrieveTableReq
*
)
pSql
->
cmd
.
payload
;
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
&
pSql
->
cmd
);
...
...
@@ -638,10 +638,10 @@ int tscBuildFetchMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pSql
->
res
.
qId
);
}
pSql
->
cmd
.
payloadLen
=
sizeof
(
SRetrieveTable
Msg
);
pSql
->
cmd
.
payloadLen
=
sizeof
(
SRetrieveTable
Req
);
pSql
->
cmd
.
msgType
=
TDMT_VND_FETCH
;
pRetrieveMsg
->
header
.
contLen
=
htonl
(
sizeof
(
SRetrieveTable
Msg
));
pRetrieveMsg
->
header
.
contLen
=
htonl
(
sizeof
(
SRetrieveTable
Req
));
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1420,7 +1420,7 @@ int32_t tscBuildSyncDbReplicaMsg(SSqlObj* pSql, SSqlInfo *pInfo) {
int32_t
tscBuildShowMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
msgType
=
TDMT_MND_SHOW
;
pCmd
->
payloadLen
=
sizeof
(
SShow
Msg
)
+
100
;
pCmd
->
payloadLen
=
sizeof
(
SShow
Req
)
+
100
;
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
...
...
@@ -1428,13 +1428,13 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
SShowInfo
*
pShowInfo
=
&
pInfo
->
pMiscInfo
->
showOpt
;
SShow
Msg
*
pShowMsg
=
(
SShowMsg
*
)
pCmd
->
payload
;
SShow
Req
*
pShowMsg
=
(
SShowReq
*
)
pCmd
->
payload
;
STableMetaInfo
*
pTableMetaInfo
=
tscGetTableMetaInfoFromCmd
(
pCmd
,
0
);
if
(
pShowInfo
->
showType
==
TSDB_MGMT_TABLE_FUNCTION
)
{
pShowMsg
->
type
=
pShowInfo
->
showType
;
pShowMsg
->
payloadLen
=
0
;
pCmd
->
payloadLen
=
sizeof
(
SShow
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SShow
Req
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1463,7 +1463,7 @@ int32_t tscBuildShowMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
pShowMsg
->
payloadLen
=
htons
(
pEpAddr
->
n
);
}
pCmd
->
payloadLen
=
sizeof
(
SShow
Msg
)
+
htons
(
pShowMsg
->
payloadLen
);
pCmd
->
payloadLen
=
sizeof
(
SShow
Req
)
+
htons
(
pShowMsg
->
payloadLen
);
return
TSDB_CODE_SUCCESS
;
}
...
...
@@ -1742,7 +1742,7 @@ int tscBuildCompactMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
int
tscBuildRetrieveFromMgmtMsg
(
SSqlObj
*
pSql
,
SSqlInfo
*
pInfo
)
{
SSqlCmd
*
pCmd
=
&
pSql
->
cmd
;
pCmd
->
msgType
=
TDMT_MND_SHOW_RETRIEVE
;
pCmd
->
payloadLen
=
sizeof
(
SRetrieveTable
Msg
);
pCmd
->
payloadLen
=
sizeof
(
SRetrieveTable
Req
);
if
(
TSDB_CODE_SUCCESS
!=
tscAllocPayload
(
pCmd
,
pCmd
->
payloadLen
))
{
tscError
(
"0x%"
PRIx64
" failed to malloc for query msg"
,
pSql
->
self
);
...
...
@@ -1750,7 +1750,7 @@ int tscBuildRetrieveFromMgmtMsg(SSqlObj *pSql, SSqlInfo *pInfo) {
}
SQueryInfo
*
pQueryInfo
=
tscGetQueryInfo
(
pCmd
);
SRetrieveTable
Msg
*
pRetrieveMsg
=
(
SRetrieveTableMsg
*
)
pCmd
->
payload
;
SRetrieveTable
Req
*
pRetrieveMsg
=
(
SRetrieveTableReq
*
)
pCmd
->
payload
;
pRetrieveMsg
->
qId
=
htobe64
(
pSql
->
res
.
qId
);
pRetrieveMsg
->
free
=
htons
(
pQueryInfo
->
type
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录