Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
b67074c0
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看板
提交
b67074c0
编写于
12月 13, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 create dnode test
上级
0a810dd6
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
112 addition
and
67 deletion
+112
-67
source/dnode/mgmt/impl/src/dndDnode.c
source/dnode/mgmt/impl/src/dndDnode.c
+5
-4
source/dnode/mgmt/impl/src/dnode.c
source/dnode/mgmt/impl/src/dnode.c
+1
-1
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+98
-56
source/dnode/mgmt/impl/test/sut/deploy.cpp
source/dnode/mgmt/impl/test/sut/deploy.cpp
+4
-2
source/dnode/mgmt/impl/test/sut/deploy.h
source/dnode/mgmt/impl/test/sut/deploy.h
+0
-2
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+4
-2
未找到文件。
source/dnode/mgmt/impl/src/dndDnode.c
浏览文件 @
b67074c0
...
...
@@ -281,9 +281,8 @@ PRASE_DNODE_OVER:
if
(
pMgmt
->
dnodeEps
==
NULL
)
{
pMgmt
->
dnodeEps
=
calloc
(
1
,
sizeof
(
SDnodeEps
)
+
sizeof
(
SDnodeEp
));
pMgmt
->
dnodeEps
->
num
=
1
;
pMgmt
->
dnodeEps
->
eps
[
0
].
isMnode
=
1
;
pMgmt
->
dnodeEps
->
eps
[
0
].
port
=
pDnode
->
opt
.
serverPort
;
tstrncpy
(
pMgmt
->
dnodeEps
->
eps
[
0
].
fqdn
,
pDnode
->
opt
.
localFqdn
,
TSDB_FQDN_LEN
);
pMgmt
->
dnodeEps
->
eps
[
0
].
isMnode
=
1
;
taosGetFqdnPortFromEp
(
pDnode
->
opt
.
firstEp
,
pMgmt
->
dnodeEps
->
eps
[
0
].
fqdn
,
&
pMgmt
->
dnodeEps
->
eps
[
0
].
port
);
}
dndResetDnodes
(
pDnode
,
pMgmt
->
dnodeEps
);
...
...
@@ -371,6 +370,8 @@ void dndSendStatusMsg(SDnode *pDnode) {
SRpcMsg
rpcMsg
=
{.
pCont
=
pStatus
,
.
contLen
=
contLen
,
.
msgType
=
TSDB_MSG_TYPE_STATUS
};
pMgmt
->
statusSent
=
1
;
dTrace
(
"pDnode:%p, send status msg to mnode"
,
pDnode
);
dndSendMsgToMnode
(
pDnode
,
&
rpcMsg
);
}
...
...
@@ -476,11 +477,11 @@ static void *dnodeThreadRoutine(void *param) {
while
(
true
)
{
pthread_testcancel
();
taosMsleep
(
ms
);
if
(
dndGetStat
(
pDnode
)
==
DND_STAT_RUNNING
&&
!
pMgmt
->
statusSent
)
{
dndSendStatusMsg
(
pDnode
);
}
taosMsleep
(
ms
);
}
}
...
...
source/dnode/mgmt/impl/src/dnode.c
浏览文件 @
b67074c0
...
...
@@ -196,7 +196,7 @@ SDnode *dndInit(SDnodeOpt *pOption) {
dndSetStat
(
pDnode
,
DND_STAT_RUNNING
);
dndSendStatusMsg
(
pDnode
);
dndReportStartup
(
pDnode
,
"TDengine"
,
"initialized successfully"
);
dInfo
(
"TDengine is initialized successfully
"
);
dInfo
(
"TDengine is initialized successfully
, pDnode:%p"
,
pDnode
);
return
pDnode
;
}
...
...
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
b67074c0
...
...
@@ -24,15 +24,15 @@ class DndTestDnode : public ::testing::Test {
}
static
void
SetUpTestSuite
()
{
initLog
(
"/tmp/dndTestDnode
1
"
);
initLog
(
"/tmp/dndTestDnode"
);
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);
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
);
taosMsleep
(
300
);
}
...
...
@@ -58,7 +58,6 @@ class DndTestDnode : public ::testing::Test {
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
,
""
);
...
...
@@ -108,7 +107,7 @@ class DndTestDnode : public ::testing::Test {
EXPECT_STREQ
(
pSchema
->
name
,
name
);
}
void
SendThenCheckShowRetrieveMsg
(
int32_t
rows
)
{
void
SendThenCheckShowRetrieveMsg
(
int32_t
rows
,
int32_t
completed
)
{
SRetrieveTableMsg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
pRetrieve
->
showId
=
htonl
(
showId
);
pRetrieve
->
free
=
0
;
...
...
@@ -134,7 +133,7 @@ class DndTestDnode : public ::testing::Test {
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
rows
);
EXPECT_EQ
(
pRetrieveRsp
->
offset
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
useconds
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
completed
,
1
);
EXPECT_EQ
(
pRetrieveRsp
->
completed
,
completed
);
EXPECT_EQ
(
pRetrieveRsp
->
precision
,
TSDB_TIME_PRECISION_MILLI
);
EXPECT_EQ
(
pRetrieveRsp
->
compressed
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
reserved
,
0
);
...
...
@@ -193,7 +192,7 @@ TEST_F(DndTestDnode, ShowDnode) {
CheckSchema
(
5
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create time"
);
CheckSchema
(
6
,
TSDB_DATA_TYPE_BINARY
,
24
+
VARSTR_HEADER_SIZE
,
"offline reason"
);
SendThenCheckShowRetrieveMsg
(
1
);
SendThenCheckShowRetrieveMsg
(
1
,
1
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:9521"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
...
...
@@ -219,7 +218,7 @@ TEST_F(DndTestDnode, CreateDnode_01) {
taosMsleep
(
1300
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
SendThenCheckShowRetrieveMsg
(
2
);
SendThenCheckShowRetrieveMsg
(
2
,
1
);
CheckInt16
(
1
);
CheckInt16
(
2
);
CheckBinary
(
"localhost:9521"
,
TSDB_EP_LEN
);
...
...
@@ -305,66 +304,109 @@ TEST_F(DndTestDnode, AlterUser_01) {
}
}
TEST_F(DndTestDnode, DropUser_01) {
ASSERT_NE(pClient, nullptr);
#endif
//--- drop user ---
SDrop
UserMsg* pReq = (SDropUserMsg*)rpcMallocCont(sizeof(SDropUser
Msg));
strcpy(pReq->user, "u1"
);
TEST_F
(
DndTestDnode
,
DropDnode_01
)
{
SDrop
DnodeMsg
*
pReq
=
(
SDropDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SDropDnode
Msg
));
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg.contLen = sizeof(SDrop
User
Msg);
rpcMsg.msgType = TSDB_MSG_TYPE_DROP_
USER
;
rpcMsg
.
contLen
=
sizeof
(
SDrop
Dnode
Msg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_DROP_
DNODE
;
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);
taosMsleep
(
1300
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
SendThenCheckShowRetrieveMsg
(
1
,
0
);
CheckInt16
(
1
);
CheckBinary
(
"localhost:9521"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
1
);
CheckBinary
(
"ready"
,
10
);
CheckTimestamp
();
CheckBinary
(
""
,
24
);
}
char* pData = pRetrieveRsp->data;
int32_t pos = 0;
char* strVal = NULL;
TEST_F
(
DndTestDnode
,
CreateDnode_02
)
{
{
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateDnodeMsg
));
strcpy
(
pReq
->
ep
,
"localhost:9523"
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SCreateDnodeMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CREATE_DNODE
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
//--- name ---
{
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "root");
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateDnodeMsg
));
strcpy
(
pReq
->
ep
,
"localhost:9524"
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SCreateDnodeMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CREATE_DNODE
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "_root");
{
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateDnodeMsg
));
strcpy
(
pReq
->
ep
,
"localhost:9525"
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SCreateDnodeMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CREATE_DNODE
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
}
#endif
\ No newline at end of file
taosMsleep
(
1300
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
SendThenCheckShowRetrieveMsg
(
4
,
0
);
CheckInt16
(
1
);
CheckInt16
(
3
);
CheckInt16
(
4
);
CheckInt16
(
5
);
CheckBinary
(
"localhost:9521"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:9523"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:9524"
,
TSDB_EP_LEN
);
CheckBinary
(
"localhost:9525"
,
TSDB_EP_LEN
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
0
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckBinary
(
"ready"
,
10
);
CheckBinary
(
"ready"
,
10
);
CheckBinary
(
"ready"
,
10
);
CheckBinary
(
"ready"
,
10
);
CheckTimestamp
();
CheckTimestamp
();
CheckTimestamp
();
CheckTimestamp
();
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
}
\ No newline at end of file
source/dnode/mgmt/impl/test/sut/deploy.cpp
浏览文件 @
b67074c0
...
...
@@ -16,9 +16,9 @@
#include "deploy.h"
void
initLog
(
const
char
*
path
)
{
dDebugFlag
=
207
;
dDebugFlag
=
143
;
vDebugFlag
=
0
;
mDebugFlag
=
207
;
mDebugFlag
=
143
;
cDebugFlag
=
0
;
jniDebugFlag
=
0
;
tmrDebugFlag
=
0
;
...
...
@@ -35,6 +35,8 @@ void initLog(const char* path) {
tsdbDebugFlag
=
0
;
cqDebugFlag
=
0
;
taosMkDir
(
path
);
char
temp
[
PATH_MAX
];
snprintf
(
temp
,
PATH_MAX
,
"%s/taosdlog"
,
path
);
if
(
taosInitLog
(
temp
,
tsNumOfLogLines
,
1
)
!=
0
)
{
...
...
source/dnode/mgmt/impl/test/sut/deploy.h
浏览文件 @
b67074c0
...
...
@@ -45,5 +45,3 @@ void dropServer(SServer* pServer);
SClient
*
createClient
(
const
char
*
user
,
const
char
*
pass
,
const
char
*
fqdn
,
uint16_t
port
);
void
dropClient
(
SClient
*
pClient
);
void
sendMsg
(
SClient
*
pClient
,
SRpcMsg
*
pMsg
);
// class DndTest
\ No newline at end of file
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
b67074c0
...
...
@@ -16,6 +16,8 @@
#define _DEFAULT_SOURCE
#include "mndShow.h"
#define SHOW_STEP_SIZE 100
static
SShowObj
*
mndCreateShowObj
(
SMnode
*
pMnode
,
SShowMsg
*
pMsg
);
static
void
mndFreeShowObj
(
SShowObj
*
pShow
);
static
SShowObj
*
mndAcquireShowObj
(
SMnode
*
pMnode
,
int32_t
showId
);
...
...
@@ -211,7 +213,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
}
/* return no more than 100 tables in one round trip */
if
(
rowsToRead
>
100
)
rowsToRead
=
100
;
if
(
rowsToRead
>
SHOW_STEP_SIZE
)
rowsToRead
=
SHOW_STEP_SIZE
;
/*
* the actual number of table may be larger than the value of pShow->numOfRows, if a query is
...
...
@@ -220,7 +222,7 @@ static int32_t mndProcessRetrieveMsg(SMnodeMsg *pMnodeMsg) {
if
(
rowsToRead
<
0
)
rowsToRead
=
0
;
size
=
pShow
->
rowSize
*
rowsToRead
;
size
+=
100
;
size
+=
SHOW_STEP_SIZE
;
SRetrieveTableRsp
*
pRsp
=
rpcMallocCont
(
size
);
if
(
pRsp
==
NULL
)
{
mndReleaseShowObj
(
pShow
,
false
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录