Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
442a8461
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
442a8461
编写于
12月 12, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 dnode mange in dnode module
上级
890c4ec8
变更
19
隐藏空白更改
内联
并排
Showing
19 changed file
with
490 addition
and
38 deletion
+490
-38
include/common/taosmsg.h
include/common/taosmsg.h
+2
-2
source/dnode/mgmt/impl/inc/dndInt.h
source/dnode/mgmt/impl/inc/dndInt.h
+2
-1
source/dnode/mgmt/impl/src/dndDnode.c
source/dnode/mgmt/impl/src/dndDnode.c
+20
-9
source/dnode/mgmt/impl/src/dnode.c
source/dnode/mgmt/impl/src/dnode.c
+2
-2
source/dnode/mgmt/impl/test/cluster/cluster.cpp
source/dnode/mgmt/impl/test/cluster/cluster.cpp
+1
-1
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+440
-0
source/dnode/mgmt/impl/test/profile/profile.cpp
source/dnode/mgmt/impl/test/profile/profile.cpp
+3
-3
source/dnode/mgmt/impl/test/show/show.cpp
source/dnode/mgmt/impl/test/show/show.cpp
+1
-1
source/dnode/mgmt/impl/test/sut/deploy.cpp
source/dnode/mgmt/impl/test/sut/deploy.cpp
+4
-5
source/dnode/mgmt/impl/test/sut/deploy.h
source/dnode/mgmt/impl/test/sut/deploy.h
+1
-1
source/dnode/mgmt/impl/test/user/user.cpp
source/dnode/mgmt/impl/test/user/user.cpp
+3
-2
source/dnode/mnode/impl/src/mndCluster.c
source/dnode/mnode/impl/src/mndCluster.c
+1
-1
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+1
-1
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+3
-3
source/dnode/mnode/impl/src/mndFunc.c
source/dnode/mnode/impl/src/mndFunc.c
+1
-1
source/dnode/mnode/impl/src/mndMnode.c
source/dnode/mnode/impl/src/mndMnode.c
+1
-1
source/dnode/mnode/impl/src/mndStb.c
source/dnode/mnode/impl/src/mndStb.c
+1
-1
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+1
-1
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+2
-2
未找到文件。
include/common/taosmsg.h
浏览文件 @
442a8461
...
...
@@ -695,7 +695,7 @@ typedef struct SStatusMsg {
int32_t
sver
;
int32_t
dnodeId
;
int32_t
clusterId
;
uint32_t
rebootTime
;
// time stamp for last reboot
int64_t
rebootTime
;
// time stamp for last reboot
int16_t
numOfCores
;
int16_t
numOfSupportMnodes
;
int16_t
numOfSupportVnodes
;
...
...
@@ -803,7 +803,7 @@ typedef struct {
}
SVgroupsMsg
,
SVgroupsInfo
;
typedef
struct
{
char
t
able
Fname
[
TSDB_TABLE_FNAME_LEN
];
// table id
char
t
b
Fname
[
TSDB_TABLE_FNAME_LEN
];
// table id
char
stbFname
[
TSDB_TABLE_FNAME_LEN
];
int32_t
numOfTags
;
int32_t
numOfColumns
;
...
...
source/dnode/mgmt/impl/inc/dndInt.h
浏览文件 @
442a8461
...
...
@@ -58,7 +58,8 @@ typedef struct {
int32_t
dnodeId
;
int32_t
dropped
;
int32_t
clusterId
;
uint32_t
rebootTime
;
int64_t
rebootTime
;
int8_t
statusSent
;
SEpSet
mnodeEpSet
;
char
*
file
;
SHashObj
*
dnodeHash
;
...
...
source/dnode/mgmt/impl/src/dndDnode.c
浏览文件 @
442a8461
...
...
@@ -349,7 +349,7 @@ static void dndSendStatusMsg(SDnode *pDnode) {
pStatus
->
sver
=
htonl
(
pDnode
->
opt
.
sver
);
pStatus
->
dnodeId
=
htonl
(
pMgmt
->
dnodeId
);
pStatus
->
clusterId
=
htonl
(
pMgmt
->
clusterId
);
pStatus
->
rebootTime
=
hto
nl
(
pMgmt
->
rebootTime
);
pStatus
->
rebootTime
=
hto
be64
(
pMgmt
->
rebootTime
);
pStatus
->
numOfCores
=
htons
(
pDnode
->
opt
.
numOfCores
);
pStatus
->
numOfSupportMnodes
=
htons
(
pDnode
->
opt
.
numOfCores
);
pStatus
->
numOfSupportVnodes
=
htons
(
pDnode
->
opt
.
numOfCores
);
...
...
@@ -370,6 +370,7 @@ static void dndSendStatusMsg(SDnode *pDnode) {
contLen
=
sizeof
(
SStatusMsg
)
+
pStatus
->
vnodeLoads
.
num
*
sizeof
(
SVnodeLoad
);
SRpcMsg
rpcMsg
=
{.
pCont
=
pStatus
,
.
contLen
=
contLen
,
.
msgType
=
TSDB_MSG_TYPE_STATUS
};
pMgmt
->
statusSent
=
1
;
dndSendMsgToMnode
(
pDnode
,
&
rpcMsg
);
}
...
...
@@ -382,7 +383,7 @@ static void dndUpdateDnodeCfg(SDnode *pDnode, SDnodeCfg *pCfg) {
pMgmt
->
dnodeId
=
pCfg
->
dnodeId
;
pMgmt
->
clusterId
=
pCfg
->
clusterId
;
pMgmt
->
dropped
=
pCfg
->
dropped
;
(
void
)
dndWriteDnodes
(
pDnode
);
dndWriteDnodes
(
pDnode
);
taosWUnLockLatch
(
&
pMgmt
->
latch
);
}
}
...
...
@@ -408,11 +409,16 @@ static void dndUpdateDnodeEps(SDnode *pDnode, SDnodeEps *pDnodeEps) {
}
static
void
dndProcessStatusRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
if
(
pEpSet
&&
pEpSet
->
numOfEps
>
0
)
{
dndUpdateMnodeEpSet
(
pDnode
,
pEpSet
);
}
if
(
pMsg
->
code
!=
TSDB_CODE_SUCCESS
)
return
;
if
(
pMsg
->
code
!=
TSDB_CODE_SUCCESS
)
{
pMgmt
->
statusSent
=
0
;
return
;
}
SStatusRsp
*
pRsp
=
pMsg
->
pCont
;
SDnodeCfg
*
pCfg
=
&
pRsp
->
dnodeCfg
;
...
...
@@ -420,7 +426,10 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
pCfg
->
clusterId
=
htonl
(
pCfg
->
clusterId
);
dndUpdateDnodeCfg
(
pDnode
,
pCfg
);
if
(
pCfg
->
dropped
)
return
;
if
(
pCfg
->
dropped
)
{
pMgmt
->
statusSent
=
0
;
return
;
}
SDnodeEps
*
pDnodeEps
=
&
pRsp
->
dnodeEps
;
pDnodeEps
->
num
=
htonl
(
pDnodeEps
->
num
);
...
...
@@ -430,6 +439,7 @@ static void dndProcessStatusRsp(SDnode *pDnode, SRpcMsg *pMsg, SEpSet *pEpSet) {
}
dndUpdateDnodeEps
(
pDnode
,
pDnodeEps
);
pMgmt
->
statusSent
=
0
;
}
static
void
dndProcessAuthRsp
(
SDnode
*
pDnode
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
assert
(
1
);
}
...
...
@@ -460,16 +470,17 @@ static void dndProcessStartupReq(SDnode *pDnode, SRpcMsg *pMsg) {
}
static
void
*
dnodeThreadRoutine
(
void
*
param
)
{
SDnode
*
pDnode
=
param
;
int32_t
ms
=
pDnode
->
opt
.
statusInterval
*
1000
;
SDnode
*
pDnode
=
param
;
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
int32_t
ms
=
pDnode
->
opt
.
statusInterval
*
1000
;
while
(
true
)
{
taosMsleep
(
ms
);
pthread_testcancel
();
if
(
dndGetStat
(
pDnode
)
==
DND_STAT_RUNNING
)
{
if
(
dndGetStat
(
pDnode
)
==
DND_STAT_RUNNING
&&
!
pMgmt
->
statusSent
)
{
dndSendStatusMsg
(
pDnode
);
}
taosMsleep
(
ms
);
}
}
...
...
@@ -477,7 +488,7 @@ int32_t dndInitDnode(SDnode *pDnode) {
SDnodeMgmt
*
pMgmt
=
&
pDnode
->
dmgmt
;
pMgmt
->
dnodeId
=
0
;
pMgmt
->
rebootTime
=
taosGetTimestamp
Sec
();
pMgmt
->
rebootTime
=
taosGetTimestamp
Ms
();
pMgmt
->
dropped
=
0
;
pMgmt
->
clusterId
=
0
;
...
...
source/dnode/mgmt/impl/src/dnode.c
浏览文件 @
442a8461
...
...
@@ -61,15 +61,15 @@ static int32_t dndCheckRunning(char *dataDir) {
FileFd
fd
=
taosOpenFileCreateWriteTrunc
(
filepath
);
if
(
fd
<
0
)
{
dError
(
"failed to lock file:%s since %s, quit"
,
filepath
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
dError
(
"failed to lock file:%s since %s, quit"
,
filepath
,
terrstr
());
return
-
1
;
}
int32_t
ret
=
taosLockFile
(
fd
);
if
(
ret
!=
0
)
{
dError
(
"failed to lock file:%s since %s, quit"
,
filepath
,
strerror
(
errno
));
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
dError
(
"failed to lock file:%s since %s, quit"
,
filepath
,
terrstr
());
taosCloseFile
(
fd
);
return
-
1
;
}
...
...
source/dnode/mgmt/impl/test/cluster/cluster.cpp
浏览文件 @
442a8461
...
...
@@ -80,7 +80,7 @@ TEST_F(DndTestCluster, ShowCluster) {
EXPECT_NE
(
pRsp
->
showId
,
0
);
EXPECT_EQ
(
pMeta
->
contLen
,
0
);
EXPECT_STREQ
(
pMeta
->
t
able
Fname
,
"show cluster"
);
EXPECT_STREQ
(
pMeta
->
t
b
Fname
,
"show cluster"
);
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
precision
,
0
);
EXPECT_EQ
(
pMeta
->
tableType
,
0
);
...
...
source/dnode/mgmt/impl/test/dnode/dnode.cpp
0 → 100644
浏览文件 @
442a8461
/*
* Copyright (c) 2019 TAOS Data, Inc. <jhtao@taosdata.com>
*
* This program is free software: you can use, redistribute, and/or modify
* it under the terms of the GNU Affero General Public License, version 3
* or later ("AGPL"), as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "deploy.h"
class
DndTestDnode
:
public
::
testing
::
Test
{
protected:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
static
SServer
*
CreateServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
)
{
SServer
*
pServer
=
createServer
(
path
,
fqdn
,
port
,
firstEp
);
ASSERT
(
pServer
);
return
pServer
;
}
static
void
SetUpTestSuite
()
{
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:9521"
;
pServer1
=
CreateServer
(
"/tmp/dndTestDnode1"
,
fqdn
,
9521
,
firstEp
);
pServer2
=
CreateServer
(
"/tmp/dndTestDnode2"
,
fqdn
,
9522
,
firstEp
);
pServer3
=
CreateServer
(
"/tmp/dndTestDnode3"
,
fqdn
,
9523
,
firstEp
);
pServer4
=
CreateServer
(
"/tmp/dndTestDnode4"
,
fqdn
,
9524
,
firstEp
);
pServer5
=
CreateServer
(
"/tmp/dndTestDnode5"
,
fqdn
,
9525
,
firstEp
);
pClient
=
createClient
(
"root"
,
"taosdata"
,
fqdn
,
9521
);
}
static
void
TearDownTestSuite
()
{
dropServer
(
pServer1
);
dropServer
(
pServer2
);
dropServer
(
pServer3
);
dropServer
(
pServer4
);
dropServer
(
pServer5
);
dropClient
(
pClient
);
}
static
SServer
*
pServer1
;
static
SServer
*
pServer2
;
static
SServer
*
pServer3
;
static
SServer
*
pServer4
;
static
SServer
*
pServer5
;
static
SClient
*
pClient
;
void
CheckShowMsg
(
int8_t
msgType
)
{
}
};
SServer
*
DndTestDnode
::
pServer1
;
SServer
*
DndTestDnode
::
pServer2
;
SServer
*
DndTestDnode
::
pServer3
;
SServer
*
DndTestDnode
::
pServer4
;
SServer
*
DndTestDnode
::
pServer5
;
SClient
*
DndTestDnode
::
pClient
;
TEST_F
(
DndTestDnode
,
ShowDnode
)
{
int32_t
showId
=
0
;
//--- meta ---
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
pShow
->
type
=
TSDB_MGMT_TABLE_DNODE
;
strcpy
(
pShow
->
db
,
""
);
SRpcMsg
showRpcMsg
=
{
0
};
showRpcMsg
.
pCont
=
pShow
;
showRpcMsg
.
contLen
=
sizeof
(
SShowMsg
);
showRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW
;
sendMsg
(
pClient
,
&
showRpcMsg
);
ASSERT_NE
(
pClient
->
pRsp
,
nullptr
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pClient
->
pRsp
->
pCont
;
ASSERT_NE
(
pShowRsp
,
nullptr
);
pShowRsp
->
showId
=
htonl
(
pShowRsp
->
showId
);
STableMetaMsg
*
pMeta
=
&
pShowRsp
->
tableMeta
;
pMeta
->
numOfTags
=
htons
(
pMeta
->
numOfTags
);
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
pMeta
->
sversion
=
htons
(
pMeta
->
sversion
);
pMeta
->
tversion
=
htons
(
pMeta
->
tversion
);
pMeta
->
tuid
=
htobe64
(
pMeta
->
tuid
);
pMeta
->
suid
=
htobe64
(
pMeta
->
suid
);
showId
=
pShowRsp
->
showId
;
EXPECT_NE
(
pShowRsp
->
showId
,
0
);
EXPECT_STREQ
(
pMeta
->
tbFname
,
"show dnodes"
);
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
7
);
EXPECT_EQ
(
pMeta
->
precision
,
0
);
EXPECT_EQ
(
pMeta
->
tableType
,
0
);
EXPECT_EQ
(
pMeta
->
update
,
0
);
EXPECT_EQ
(
pMeta
->
sversion
,
0
);
EXPECT_EQ
(
pMeta
->
tversion
,
0
);
EXPECT_EQ
(
pMeta
->
tuid
,
0
);
EXPECT_EQ
(
pMeta
->
suid
,
0
);
SSchema
*
pSchema
=
NULL
;
pSchema
=
&
pMeta
->
pSchema
[
0
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_SMALLINT
);
EXPECT_EQ
(
pSchema
->
bytes
,
2
);
EXPECT_STREQ
(
pSchema
->
name
,
"id"
);
pSchema
=
&
pMeta
->
pSchema
[
1
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"end point"
);
pSchema
=
&
pMeta
->
pSchema
[
2
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_SMALLINT
);
EXPECT_EQ
(
pSchema
->
bytes
,
2
);
EXPECT_STREQ
(
pSchema
->
name
,
"vnodes"
);
pSchema
=
&
pMeta
->
pSchema
[
3
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_SMALLINT
);
EXPECT_EQ
(
pSchema
->
bytes
,
2
);
EXPECT_STREQ
(
pSchema
->
name
,
"max vnodes"
);
pSchema
=
&
pMeta
->
pSchema
[
4
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
10
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"status"
);
pSchema
=
&
pMeta
->
pSchema
[
5
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_TIMESTAMP
);
EXPECT_EQ
(
pSchema
->
bytes
,
8
);
EXPECT_STREQ
(
pSchema
->
name
,
"create time"
);
pSchema
=
&
pMeta
->
pSchema
[
6
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"offline reason"
);
//--- retrieve ---
SRetrieveTableMsg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
pRetrieve
->
showId
=
htonl
(
showId
);
pRetrieve
->
free
=
0
;
SRpcMsg
retrieveRpcMsg
=
{
0
};
retrieveRpcMsg
.
pCont
=
pRetrieve
;
retrieveRpcMsg
.
contLen
=
sizeof
(
SRetrieveTableMsg
);
retrieveRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW_RETRIEVE
;
sendMsg
(
pClient
,
&
retrieveRpcMsg
);
ASSERT_NE
(
pClient
->
pRsp
,
nullptr
);
ASSERT_EQ
(
pClient
->
pRsp
->
code
,
0
);
SRetrieveTableRsp
*
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
pClient
->
pRsp
->
pCont
;
ASSERT_NE
(
pRetrieveRsp
,
nullptr
);
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
pRetrieveRsp
->
offset
=
htobe64
(
pRetrieveRsp
->
offset
);
pRetrieveRsp
->
useconds
=
htobe64
(
pRetrieveRsp
->
useconds
);
pRetrieveRsp
->
compLen
=
htonl
(
pRetrieveRsp
->
compLen
);
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
1
);
EXPECT_EQ
(
pRetrieveRsp
->
offset
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
useconds
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
completed
,
1
);
EXPECT_EQ
(
pRetrieveRsp
->
precision
,
TSDB_TIME_PRECISION_MILLI
);
EXPECT_EQ
(
pRetrieveRsp
->
compressed
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
reserved
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
compLen
,
0
);
char
*
pData
=
pRetrieveRsp
->
data
;
int32_t
pos
=
0
;
char
*
strVal
=
NULL
;
int64_t
int64Val
=
0
;
int16_t
int16Val
=
0
;
//--- name ---
{
int16Val
=
*
((
int16_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int16_t
);
EXPECT_EQ
(
int16Val
,
1
);
}
// //--- privilege ---
// {
// pos += sizeof(VarDataLenT);
// strVal = (char*)(pData + pos);
// pos += 10;
// EXPECT_STREQ(strVal, "super");
// pos += sizeof(VarDataLenT);
// strVal = (char*)(pData + pos);
// pos += 10;
// EXPECT_STREQ(strVal, "writable");
// }
// //--- create_time ---
// {
// int64Val = *((int64_t*)(pData + pos));
// pos += sizeof(int64_t);
// EXPECT_GT(int64Val, 0);
// int64Val = *((int64_t*)(pData + pos));
// pos += sizeof(int64_t);
// EXPECT_GT(int64Val, 0);
// }
// //--- account ---
// {
// pos += sizeof(VarDataLenT);
// strVal = (char*)(pData + pos);
// pos += TSDB_USER_LEN;
// EXPECT_STREQ(strVal, "root");
// pos += sizeof(VarDataLenT);
// strVal = (char*)(pData + pos);
// pos += TSDB_USER_LEN;
// EXPECT_STREQ(strVal, "root");
// }
}
#if 0
TEST_F(DndTestDnode, CreateUser_01) {
ASSERT_NE(pClient, nullptr);
//--- create user ---
SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(sizeof(SCreateUserMsg));
strcpy(pReq->user, "u1");
strcpy(pReq->pass, "p1");
SRpcMsg rpcMsg = {0};
rpcMsg.pCont = pReq;
rpcMsg.contLen = sizeof(SCreateUserMsg);
rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_USER;
sendMsg(pClient, &rpcMsg);
SRpcMsg* pMsg = pClient->pRsp;
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
//--- meta ---
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
pShow->type = TSDB_MGMT_TABLE_USER;
SRpcMsg showRpcMsg = {0};
showRpcMsg.pCont = pShow;
showRpcMsg.contLen = sizeof(SShowMsg);
showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
sendMsg(pClient, &showRpcMsg);
SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont;
STableMetaMsg* pMeta = &pShowRsp->tableMeta;
pMeta->numOfColumns = htons(pMeta->numOfColumns);
EXPECT_EQ(pMeta->numOfColumns, 4);
//--- retrieve ---
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
pRetrieve->showId = pShowRsp->showId;
SRpcMsg retrieveRpcMsg = {0};
retrieveRpcMsg.pCont = pRetrieve;
retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg);
retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
sendMsg(pClient, &retrieveRpcMsg);
SRetrieveTableRsp* pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
EXPECT_EQ(pRetrieveRsp->numOfRows, 3);
char* pData = pRetrieveRsp->data;
int32_t pos = 0;
char* strVal = NULL;
//--- name ---
{
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "u1");
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "root");
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "_root");
}
}
TEST_F(DndTestDnode, AlterUser_01) {
ASSERT_NE(pClient, nullptr);
//--- drop user ---
SAlterUserMsg* pReq = (SAlterUserMsg*)rpcMallocCont(sizeof(SAlterUserMsg));
strcpy(pReq->user, "u1");
strcpy(pReq->pass, "p2");
SRpcMsg rpcMsg = {0};
rpcMsg.pCont = pReq;
rpcMsg.contLen = sizeof(SAlterUserMsg);
rpcMsg.msgType = TSDB_MSG_TYPE_ALTER_USER;
sendMsg(pClient, &rpcMsg);
SRpcMsg* pMsg = pClient->pRsp;
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
//--- meta ---
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
pShow->type = TSDB_MGMT_TABLE_USER;
SRpcMsg showRpcMsg = {0};
showRpcMsg.pCont = pShow;
showRpcMsg.contLen = sizeof(SShowMsg);
showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
sendMsg(pClient, &showRpcMsg);
SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont;
STableMetaMsg* pMeta = &pShowRsp->tableMeta;
pMeta->numOfColumns = htons(pMeta->numOfColumns);
EXPECT_EQ(pMeta->numOfColumns, 4);
//--- retrieve ---
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
pRetrieve->showId = pShowRsp->showId;
SRpcMsg retrieveRpcMsg = {0};
retrieveRpcMsg.pCont = pRetrieve;
retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg);
retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
sendMsg(pClient, &retrieveRpcMsg);
SRetrieveTableRsp* pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
EXPECT_EQ(pRetrieveRsp->numOfRows, 3);
char* pData = pRetrieveRsp->data;
int32_t pos = 0;
char* strVal = NULL;
//--- name ---
{
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "u1");
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "root");
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "_root");
}
}
TEST_F(DndTestDnode, DropUser_01) {
ASSERT_NE(pClient, nullptr);
//--- drop user ---
SDropUserMsg* pReq = (SDropUserMsg*)rpcMallocCont(sizeof(SDropUserMsg));
strcpy(pReq->user, "u1");
SRpcMsg rpcMsg = {0};
rpcMsg.pCont = pReq;
rpcMsg.contLen = sizeof(SDropUserMsg);
rpcMsg.msgType = TSDB_MSG_TYPE_DROP_USER;
sendMsg(pClient, &rpcMsg);
SRpcMsg* pMsg = pClient->pRsp;
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
//--- meta ---
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
pShow->type = TSDB_MGMT_TABLE_USER;
SRpcMsg showRpcMsg = {0};
showRpcMsg.pCont = pShow;
showRpcMsg.contLen = sizeof(SShowMsg);
showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
sendMsg(pClient, &showRpcMsg);
SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont;
STableMetaMsg* pMeta = &pShowRsp->tableMeta;
pMeta->numOfColumns = htons(pMeta->numOfColumns);
EXPECT_EQ(pMeta->numOfColumns, 4);
//--- retrieve ---
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
pRetrieve->showId = pShowRsp->showId;
SRpcMsg retrieveRpcMsg = {0};
retrieveRpcMsg.pCont = pRetrieve;
retrieveRpcMsg.contLen = sizeof(SRetrieveTableMsg);
retrieveRpcMsg.msgType = TSDB_MSG_TYPE_SHOW_RETRIEVE;
sendMsg(pClient, &retrieveRpcMsg);
SRetrieveTableRsp* pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
pRetrieveRsp->numOfRows = htonl(pRetrieveRsp->numOfRows);
EXPECT_EQ(pRetrieveRsp->numOfRows, 2);
char* pData = pRetrieveRsp->data;
int32_t pos = 0;
char* strVal = NULL;
//--- name ---
{
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "root");
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "_root");
}
}
#endif
\ No newline at end of file
source/dnode/mgmt/impl/test/profile/profile.cpp
浏览文件 @
442a8461
...
...
@@ -139,7 +139,7 @@ TEST_F(DndTestProfile, SConnectMsg_03) {
EXPECT_NE
(
pRsp
->
showId
,
0
);
EXPECT_EQ
(
pMeta
->
contLen
,
0
);
EXPECT_STREQ
(
pMeta
->
t
able
Fname
,
""
);
EXPECT_STREQ
(
pMeta
->
t
b
Fname
,
""
);
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
precision
,
0
);
EXPECT_EQ
(
pMeta
->
tableType
,
0
);
...
...
@@ -480,7 +480,7 @@ TEST_F(DndTestProfile, SKillQueryMsg_03) {
EXPECT_NE
(
pRsp
->
showId
,
0
);
EXPECT_EQ
(
pMeta
->
contLen
,
0
);
EXPECT_STREQ
(
pMeta
->
t
able
Fname
,
""
);
EXPECT_STREQ
(
pMeta
->
t
b
Fname
,
""
);
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
precision
,
0
);
EXPECT_EQ
(
pMeta
->
tableType
,
0
);
...
...
@@ -667,7 +667,7 @@ TEST_F(DndTestProfile, SKillStreamMsg_03) {
EXPECT_NE
(
pRsp
->
showId
,
0
);
EXPECT_EQ
(
pMeta
->
contLen
,
0
);
EXPECT_STREQ
(
pMeta
->
t
able
Fname
,
""
);
EXPECT_STREQ
(
pMeta
->
t
b
Fname
,
""
);
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
precision
,
0
);
EXPECT_EQ
(
pMeta
->
tableType
,
0
);
...
...
source/dnode/mgmt/impl/test/show/show.cpp
浏览文件 @
442a8461
...
...
@@ -141,7 +141,7 @@ TEST_F(DndTestShow, SShowMsg_04) {
EXPECT_NE
(
pRsp
->
showId
,
0
);
EXPECT_EQ
(
pMeta
->
contLen
,
0
);
EXPECT_STREQ
(
pMeta
->
t
able
Fname
,
""
);
EXPECT_STREQ
(
pMeta
->
t
b
Fname
,
""
);
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
precision
,
0
);
EXPECT_EQ
(
pMeta
->
tableType
,
0
);
...
...
source/dnode/mgmt/impl/test/sut/deploy.cpp
浏览文件 @
442a8461
...
...
@@ -50,7 +50,7 @@ void* runServer(void* param) {
}
}
void
initOption
(
SDnodeOpt
*
pOption
,
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
)
{
void
initOption
(
SDnodeOpt
*
pOption
,
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
)
{
pOption
->
sver
=
1
;
pOption
->
numOfCores
=
1
;
pOption
->
numOfSupportMnodes
=
1
;
...
...
@@ -65,16 +65,16 @@ void initOption(SDnodeOpt* pOption, const char* path, const char* fqdn, uint16_t
strcpy
(
pOption
->
dataDir
,
path
);
snprintf
(
pOption
->
localEp
,
TSDB_EP_LEN
,
"%s:%u"
,
fqdn
,
port
);
snprintf
(
pOption
->
localFqdn
,
TSDB_FQDN_LEN
,
"%s"
,
fqdn
);
snprintf
(
pOption
->
firstEp
,
TSDB_EP_LEN
,
"%s
:%u"
,
fqdn
,
port
);
snprintf
(
pOption
->
firstEp
,
TSDB_EP_LEN
,
"%s
"
,
firstEp
);
}
SServer
*
createServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
)
{
SServer
*
createServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
)
{
taosRemoveDir
(
path
);
taosMkDir
(
path
);
initLog
(
path
);
SDnodeOpt
option
=
{
0
};
initOption
(
&
option
,
path
,
fqdn
,
port
);
initOption
(
&
option
,
path
,
fqdn
,
port
,
firstEp
);
SDnode
*
pDnode
=
dndInit
(
&
option
);
ASSERT
(
pDnode
);
...
...
@@ -98,7 +98,6 @@ void dropServer(SServer* pServer) {
void
processClientRsp
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SClient
*
pClient
=
(
SClient
*
)
parent
;
pClient
->
pRsp
=
pMsg
;
// taosMsleep(1000000);
tsem_post
(
&
pClient
->
sem
);
}
...
...
source/dnode/mgmt/impl/test/sut/deploy.h
浏览文件 @
442a8461
...
...
@@ -39,7 +39,7 @@ typedef struct {
tsem_t
sem
;
}
SClient
;
SServer
*
createServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
);
SServer
*
createServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
);
void
dropServer
(
SServer
*
pServer
);
SClient
*
createClient
(
const
char
*
user
,
const
char
*
pass
,
const
char
*
fqdn
,
uint16_t
port
);
void
dropClient
(
SClient
*
pClient
);
...
...
source/dnode/mgmt/impl/test/user/user.cpp
浏览文件 @
442a8461
...
...
@@ -26,8 +26,9 @@ class DndTestUser : public ::testing::Test {
const
char
*
path
=
"/tmp/dndTestUser"
;
const
char
*
fqdn
=
"localhost"
;
uint16_t
port
=
9524
;
const
char
*
firstEp
=
"localhost:9524"
;
pServer
=
createServer
(
path
,
fqdn
,
port
);
pServer
=
createServer
(
path
,
fqdn
,
port
,
firstEp
);
ASSERT
(
pServer
);
pClient
=
createClient
(
user
,
pass
,
fqdn
,
port
);
}
...
...
@@ -79,7 +80,7 @@ TEST_F(DndTestUser, ShowUser) {
EXPECT_NE(pShowRsp->showId, 0);
EXPECT_EQ(pMeta->contLen, 0);
EXPECT_STREQ(pMeta->t
able
Fname, "show users");
EXPECT_STREQ(pMeta->t
b
Fname, "show users");
EXPECT_EQ(pMeta->numOfTags, 0);
EXPECT_EQ(pMeta->precision, 0);
EXPECT_EQ(pMeta->tableType, 0);
...
...
source/dnode/mnode/impl/src/mndCluster.c
浏览文件 @
442a8461
...
...
@@ -159,7 +159,7 @@ static int32_t mndGetClusterMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
cols
++
;
pMeta
->
numOfColumns
=
htons
(
cols
);
strcpy
(
pMeta
->
t
ableFname
,
"show cluster"
);
strcpy
(
pMeta
->
t
bFname
,
mndShowStr
(
pShow
->
type
)
);
pShow
->
numOfColumns
=
cols
;
pShow
->
offset
[
0
]
=
0
;
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
442a8461
...
...
@@ -767,7 +767,7 @@ static int32_t mndGetDbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pMe
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_DB
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
t
able
Fname
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
t
b
Fname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
442a8461
...
...
@@ -281,7 +281,7 @@ static void mndParseStatusMsg(SStatusMsg *pStatus) {
pStatus
->
sver
=
htonl
(
pStatus
->
sver
);
pStatus
->
dnodeId
=
htonl
(
pStatus
->
dnodeId
);
pStatus
->
clusterId
=
htonl
(
pStatus
->
clusterId
);
pStatus
->
rebootTime
=
hto
nl
(
pStatus
->
rebootTime
);
pStatus
->
rebootTime
=
hto
be64
(
pStatus
->
rebootTime
);
pStatus
->
numOfCores
=
htons
(
pStatus
->
numOfCores
);
pStatus
->
numOfSupportMnodes
=
htons
(
pStatus
->
numOfSupportMnodes
);
pStatus
->
numOfSupportVnodes
=
htons
(
pStatus
->
numOfSupportVnodes
);
...
...
@@ -604,7 +604,7 @@ static int32_t mndGetConfigMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
pShow
->
numOfRows
=
TSDB_CONFIG_NUMBER
;
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
t
able
Fname
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
t
b
Fname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
...
...
@@ -711,7 +711,7 @@ static int32_t mndGetDnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_DNODE
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
t
able
Fname
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
t
b
Fname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndFunc.c
浏览文件 @
442a8461
...
...
@@ -429,7 +429,7 @@ static int32_t mndGetFuncMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_FUNC
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
t
able
Fname
,
"show funcs"
);
strcpy
(
pMeta
->
t
b
Fname
,
"show funcs"
);
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndMnode.c
浏览文件 @
442a8461
...
...
@@ -405,7 +405,7 @@ static int32_t mndGetMnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_MNODE
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
t
able
Fname
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
t
b
Fname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndStb.c
浏览文件 @
442a8461
...
...
@@ -600,7 +600,7 @@ static int32_t mndGetStbMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *pM
}
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
t
able
Fname
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
t
b
Fname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
442a8461
...
...
@@ -489,7 +489,7 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
pShow
->
numOfRows
=
sdbGetSize
(
pSdb
,
SDB_USER
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
t
able
Fname
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
t
b
Fname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
442a8461
...
...
@@ -238,7 +238,7 @@ static int32_t mndGetVgroupMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
}
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
t
able
Fname
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
t
b
Fname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
...
...
@@ -337,7 +337,7 @@ static int32_t mndGetVnodeMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *
pShow
->
replica
=
dnodeId
;
pShow
->
numOfRows
=
mndGetVnodesNum
(
pMnode
,
dnodeId
);
pShow
->
rowSize
=
pShow
->
offset
[
cols
-
1
]
+
pShow
->
bytes
[
cols
-
1
];
strcpy
(
pMeta
->
t
able
Fname
,
mndShowStr
(
pShow
->
type
));
strcpy
(
pMeta
->
t
b
Fname
,
mndShowStr
(
pShow
->
type
));
return
0
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录