Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
6be27877
T
TDengine
项目概览
taosdata
/
TDengine
接近 2 年 前同步成功
通知
1192
Star
22018
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看板
提交
6be27877
编写于
12月 12, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 refact dnode test
上级
6941b148
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
174 addition
and
241 deletion
+174
-241
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+166
-239
source/dnode/mgmt/impl/test/sut/deploy.cpp
source/dnode/mgmt/impl/test/sut/deploy.cpp
+0
-1
source/dnode/mgmt/impl/test/sut/deploy.h
source/dnode/mgmt/impl/test/sut/deploy.h
+3
-0
source/dnode/mnode/impl/src/mndDnode.c
source/dnode/mnode/impl/src/mndDnode.c
+5
-1
未找到文件。
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
6be27877
...
@@ -16,10 +16,7 @@
...
@@ -16,10 +16,7 @@
#include "deploy.h"
#include "deploy.h"
class
DndTestDnode
:
public
::
testing
::
Test
{
class
DndTestDnode
:
public
::
testing
::
Test
{
protected:
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
static
SServer
*
CreateServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
)
{
static
SServer
*
CreateServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
)
{
SServer
*
pServer
=
createServer
(
path
,
fqdn
,
port
,
firstEp
);
SServer
*
pServer
=
createServer
(
path
,
fqdn
,
port
,
firstEp
);
ASSERT
(
pServer
);
ASSERT
(
pServer
);
...
@@ -27,14 +24,17 @@ class DndTestDnode : public ::testing::Test {
...
@@ -27,14 +24,17 @@ class DndTestDnode : public ::testing::Test {
}
}
static
void
SetUpTestSuite
()
{
static
void
SetUpTestSuite
()
{
initLog
(
"/tmp/dndTestDnode1"
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:9521"
;
const
char
*
firstEp
=
"localhost:9521"
;
pServer1
=
CreateServer
(
"/tmp/dndTestDnode1"
,
fqdn
,
9521
,
firstEp
);
pServer1
=
CreateServer
(
"/tmp/dndTestDnode1"
,
fqdn
,
9521
,
firstEp
);
pServer2
=
CreateServer
(
"/tmp/dndTestDnode2"
,
fqdn
,
9522
,
firstEp
);
pServer2
=
CreateServer
(
"/tmp/dndTestDnode2"
,
fqdn
,
9522
,
firstEp
);
pServer3
=
CreateServer
(
"/tmp/dndTestDnode3"
,
fqdn
,
9523
,
firstEp
);
//
pServer3 = CreateServer("/tmp/dndTestDnode3", fqdn, 9523, firstEp);
pServer4
=
CreateServer
(
"/tmp/dndTestDnode4"
,
fqdn
,
9524
,
firstEp
);
//
pServer4 = CreateServer("/tmp/dndTestDnode4", fqdn, 9524, firstEp);
pServer5
=
CreateServer
(
"/tmp/dndTestDnode5"
,
fqdn
,
9525
,
firstEp
);
//
pServer5 = CreateServer("/tmp/dndTestDnode5", fqdn, 9525, firstEp);
pClient
=
createClient
(
"root"
,
"taosdata"
,
fqdn
,
9521
);
pClient
=
createClient
(
"root"
,
"taosdata"
,
fqdn
,
9521
);
taosMsleep
(
300
);
}
}
static
void
TearDownTestSuite
()
{
static
void
TearDownTestSuite
()
{
...
@@ -53,9 +53,127 @@ class DndTestDnode : public ::testing::Test {
...
@@ -53,9 +53,127 @@ class DndTestDnode : public ::testing::Test {
static
SServer
*
pServer5
;
static
SServer
*
pServer5
;
static
SClient
*
pClient
;
static
SClient
*
pClient
;
void
CheckShowMsg
(
int8_t
msgType
)
{
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
void
SendTheCheckShowMetaMsg
(
int8_t
showType
,
const
char
*
showName
,
int32_t
columns
)
{
//--- meta ---
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
pShow
->
type
=
showType
;
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
);
ASSERT_EQ
(
pClient
->
pRsp
->
code
,
0
);
ASSERT_NE
(
pClient
->
pRsp
->
pCont
,
nullptr
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pClient
->
pRsp
->
pCont
;
ASSERT_NE
(
pShowRsp
,
nullptr
);
pShowRsp
->
showId
=
htonl
(
pShowRsp
->
showId
);
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
,
showName
);
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
columns
);
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
);
}
void
CheckSchema
(
int32_t
index
,
int8_t
type
,
int32_t
bytes
,
const
char
*
name
)
{
SSchema
*
pSchema
=
&
pMeta
->
pSchema
[
index
];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
type
,
type
);
EXPECT_EQ
(
pSchema
->
bytes
,
bytes
);
EXPECT_STREQ
(
pSchema
->
name
,
name
);
}
void
SendThenCheckShowRetrieveMsg
(
int32_t
rows
)
{
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
);
ASSERT_NE
(
pClient
->
pRsp
->
pCont
,
nullptr
);
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
,
rows
);
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
);
pData
=
pRetrieveRsp
->
data
;
pos
=
0
;
}
void
CheckInt16
(
int16_t
val
)
{
int16_t
data
=
*
((
int16_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int16_t
);
EXPECT_EQ
(
data
,
val
);
}
void
CheckInt64
(
int64_t
val
)
{
int64_t
data
=
*
((
int64_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int64_t
);
EXPECT_EQ
(
data
,
val
);
}
void
CheckTimestamp
()
{
int64_t
data
=
*
((
int64_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int64_t
);
EXPECT_GT
(
data
,
0
);
}
}
void
CheckBinary
(
const
char
*
val
,
int32_t
len
)
{
pos
+=
sizeof
(
VarDataLenT
);
char
*
data
=
(
char
*
)(
pData
+
pos
);
pos
+=
len
;
EXPECT_STREQ
(
data
,
val
);
}
int32_t
showId
;
STableMetaMsg
*
pMeta
;
SRetrieveTableRsp
*
pRetrieveRsp
;
char
*
pData
;
int32_t
pos
;
};
};
SServer
*
DndTestDnode
::
pServer1
;
SServer
*
DndTestDnode
::
pServer1
;
...
@@ -66,250 +184,59 @@ SServer* DndTestDnode::pServer5;
...
@@ -66,250 +184,59 @@ SServer* DndTestDnode::pServer5;
SClient
*
DndTestDnode
::
pClient
;
SClient
*
DndTestDnode
::
pClient
;
TEST_F
(
DndTestDnode
,
ShowDnode
)
{
TEST_F
(
DndTestDnode
,
ShowDnode
)
{
int32_t
showId
=
0
;
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
CheckSchema
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
//--- meta ---
CheckSchema
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"end point"
);
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
CheckSchema
(
2
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"vnodes"
);
pShow
->
type
=
TSDB_MGMT_TABLE_DNODE
;
CheckSchema
(
3
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"max vnodes"
);
strcpy
(
pShow
->
db
,
""
);
CheckSchema
(
4
,
TSDB_DATA_TYPE_BINARY
,
10
+
VARSTR_HEADER_SIZE
,
"status"
);
CheckSchema
(
5
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create time"
);
SRpcMsg
showRpcMsg
=
{
0
};
CheckSchema
(
6
,
TSDB_DATA_TYPE_BINARY
,
24
+
VARSTR_HEADER_SIZE
,
"offline reason"
);
showRpcMsg
.
pCont
=
pShow
;
showRpcMsg
.
contLen
=
sizeof
(
SShowMsg
);
SendThenCheckShowRetrieveMsg
(
1
);
showRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW
;
CheckInt16
(
1
);
CheckBinary
(
"localhost:9521"
,
TSDB_EP_LEN
);
sendMsg
(
pClient
,
&
showRpcMsg
);
CheckInt16
(
0
);
ASSERT_NE
(
pClient
->
pRsp
,
nullptr
);
CheckInt16
(
1
);
ASSERT_EQ
(
pClient
->
pRsp
->
code
,
0
);
CheckBinary
(
"ready"
,
10
);
ASSERT_NE
(
pClient
->
pRsp
->
pCont
,
nullptr
);
CheckTimestamp
();
CheckBinary
(
""
,
24
);
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
);
ASSERT_NE
(
pClient
->
pRsp
->
pCont
,
nullptr
);
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
,
CreateDnode_01
)
{
TEST_F(DndTestDnode, CreateUser_01) {
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateDnodeMsg
));
ASSERT_NE(pClient, nullptr);
strcpy
(
pReq
->
ep
,
"localhost:9522"
);
//--- create user ---
SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(sizeof(SCreateUserMsg));
strcpy(pReq->user, "u1");
strcpy(pReq->pass, "p1");
SRpcMsg
rpcMsg
=
{
0
};
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
pCont
=
pReq
;
rpcMsg.contLen = sizeof(SCreate
User
Msg);
rpcMsg
.
contLen
=
sizeof
(
SCreate
Dnode
Msg
);
rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_
USER
;
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CREATE_
DNODE
;
sendMsg
(
pClient
,
&
rpcMsg
);
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
//--- meta ---
taosMsleep
(
1300
);
SShowMsg* pShow = (SShowMsg*)rpcMallocCont(sizeof(SShowMsg));
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
pShow->type = TSDB_MGMT_TABLE_USER;
SendThenCheckShowRetrieveMsg
(
2
);
SRpcMsg showRpcMsg = {0};
CheckInt16
(
1
);
showRpcMsg.pCont = pShow;
CheckInt16
(
2
);
showRpcMsg.contLen = sizeof(SShowMsg);
CheckBinary
(
"localhost:9521"
,
TSDB_EP_LEN
);
showRpcMsg.msgType = TSDB_MSG_TYPE_SHOW;
CheckBinary
(
"localhost:9522"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
sendMsg(pClient, &showRpcMsg);
CheckInt16
(
0
);
SShowRsp* pShowRsp = (SShowRsp*)pClient->pRsp->pCont;
CheckInt16
(
1
);
STableMetaMsg* pMeta = &pShowRsp->tableMeta;
CheckInt16
(
1
);
pMeta->numOfColumns = htons(pMeta->numOfColumns);
CheckBinary
(
"ready"
,
10
);
EXPECT_EQ(pMeta->numOfColumns, 4);
CheckBinary
(
"ready"
,
10
);
CheckTimestamp
();
//--- retrieve ---
CheckTimestamp
();
SRetrieveTableMsg* pRetrieve = (SRetrieveTableMsg*)rpcMallocCont(sizeof(SRetrieveTableMsg));
CheckBinary
(
""
,
24
);
pRetrieve->showId = pShowRsp->showId;
CheckBinary
(
""
,
24
);
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");
}
}
}
#if 0
TEST_F(DndTestDnode, AlterUser_01) {
TEST_F(DndTestDnode, AlterUser_01) {
ASSERT_NE(pClient, nullptr);
ASSERT_NE(pClient, nullptr);
...
...
source/dnode/mgmt/impl/test/sut/deploy.cpp
浏览文件 @
6be27877
...
@@ -71,7 +71,6 @@ void initOption(SDnodeOpt* pOption, const char* path, const char* fqdn, uint16_t
...
@@ -71,7 +71,6 @@ void initOption(SDnodeOpt* pOption, const char* path, const char* fqdn, uint16_t
SServer
*
createServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
)
{
SServer
*
createServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
)
{
taosRemoveDir
(
path
);
taosRemoveDir
(
path
);
taosMkDir
(
path
);
taosMkDir
(
path
);
initLog
(
path
);
SDnodeOpt
option
=
{
0
};
SDnodeOpt
option
=
{
0
};
initOption
(
&
option
,
path
,
fqdn
,
port
,
firstEp
);
initOption
(
&
option
,
path
,
fqdn
,
port
,
firstEp
);
...
...
source/dnode/mgmt/impl/test/sut/deploy.h
浏览文件 @
6be27877
...
@@ -39,8 +39,11 @@ typedef struct {
...
@@ -39,8 +39,11 @@ typedef struct {
tsem_t
sem
;
tsem_t
sem
;
}
SClient
;
}
SClient
;
void
initLog
(
const
char
*
path
);
SServer
*
createServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
);
SServer
*
createServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
);
void
dropServer
(
SServer
*
pServer
);
void
dropServer
(
SServer
*
pServer
);
SClient
*
createClient
(
const
char
*
user
,
const
char
*
pass
,
const
char
*
fqdn
,
uint16_t
port
);
SClient
*
createClient
(
const
char
*
user
,
const
char
*
pass
,
const
char
*
fqdn
,
uint16_t
port
);
void
dropClient
(
SClient
*
pClient
);
void
dropClient
(
SClient
*
pClient
);
void
sendMsg
(
SClient
*
pClient
,
SRpcMsg
*
pMsg
);
void
sendMsg
(
SClient
*
pClient
,
SRpcMsg
*
pMsg
);
// class DndTest
\ No newline at end of file
source/dnode/mnode/impl/src/mndDnode.c
浏览文件 @
6be27877
...
@@ -756,7 +756,11 @@ static int32_t mndRetrieveDnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, i
...
@@ -756,7 +756,11 @@ static int32_t mndRetrieveDnodes(SMnodeMsg *pMsg, SShowObj *pShow, char *data, i
cols
++
;
cols
++
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
STR_TO_VARSTR
(
pWrite
,
offlineReason
[
pDnode
->
offlineReason
]);
if
(
pDnode
->
status
==
DND_STATUS_READY
)
{
STR_TO_VARSTR
(
pWrite
,
""
);
}
else
{
STR_TO_VARSTR
(
pWrite
,
offlineReason
[
pDnode
->
offlineReason
]);
}
cols
++
;
cols
++
;
numOfRows
++
;
numOfRows
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录