Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
aff44f1a
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22017
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看板
提交
aff44f1a
编写于
12月 03, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 dnode test01
上级
608b96d3
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
45 addition
and
20 deletion
+45
-20
source/dnode/mgmt/impl/test/test01/CMakeLists.txt
source/dnode/mgmt/impl/test/test01/CMakeLists.txt
+4
-1
source/dnode/mgmt/impl/test/test01/test01.cpp
source/dnode/mgmt/impl/test/test01/test01.cpp
+41
-19
source/dnode/mgmt/impl/test/util/deploy.cpp
source/dnode/mgmt/impl/test/util/deploy.cpp
+0
-0
未找到文件。
source/dnode/mgmt/impl/test/test01/CMakeLists.txt
浏览文件 @
aff44f1a
...
...
@@ -2,12 +2,15 @@ add_executable(dndTest01 "")
target_sources
(
dndTest01
PRIVATE
"dndTest01.cpp"
"test01.cpp"
"../util/deploy.cpp"
)
target_link_libraries
(
dndTest01
PUBLIC dnode
PUBLIC util
PUBLIC os
PUBLIC gtest_main
)
...
...
source/dnode/mgmt/impl/test/test01/
dndT
est01.cpp
→
source/dnode/mgmt/impl/test/test01/
t
est01.cpp
浏览文件 @
aff44f1a
...
...
@@ -14,13 +14,16 @@
*/
#include <gtest/gtest.h>
#include <cstring>
#include <iostream>
#include <queue>
#include "tthread.h"
#include "os.h"
#include "dnode.h"
#include "taosmsg.h"
#include "tconfig.h"
#include "tglobal.h"
#include "tnote.h"
#include "trpc.h"
#include "tthread.h"
#include "ulog.h"
typedef
struct
{
SDnode
*
pDnode
;
...
...
@@ -28,7 +31,7 @@ typedef struct {
}
SServer
;
void
*
runServer
(
void
*
param
)
{
SServer
*
pServer
=
param
;
SServer
*
pServer
=
(
SServer
*
)
param
;
while
(
1
)
{
taosMsleep
(
100
);
pthread_testcancel
();
...
...
@@ -49,19 +52,19 @@ void initOption(SDnodeOpt* pOption) {
pOption
->
shellActivityTimer
=
30
;
pOption
->
serverPort
=
9527
;
strncpy
(
pOption
->
dataDir
,
"./test01"
);
str
n
cpy
(
pOption
->
localEp
,
"localhost:9527"
);
str
n
cpy
(
pOption
->
localFqdn
,
"localhost"
);
tstrn
cpy
(
pOption
->
firstEp
,
"localhost:9527"
);
strcpy
(
pOption
->
localEp
,
"localhost:9527"
);
strcpy
(
pOption
->
localFqdn
,
"localhost"
);
str
cpy
(
pOption
->
firstEp
,
"localhost:9527"
);
}
Server
*
createServer
()
{
S
S
erver
*
createServer
()
{
SDnodeOpt
option
=
{
0
};
initOption
(
&
option
);
SDnode
*
pDnode
=
dndInit
(
&
option
);
ASSERT
(
pDnode
);
S
erver
*
pServer
=
calloc
(
1
,
sizeof
(
SServer
));
S
Server
*
pServer
=
(
SServer
*
)
calloc
(
1
,
sizeof
(
SServer
));
ASSERT
(
pServer
);
pServer
->
pDnode
=
pDnode
;
...
...
@@ -84,13 +87,13 @@ typedef struct {
}
SClient
;
static
void
processClientRsp
(
void
*
parent
,
SRpcMsg
*
pMsg
,
SEpSet
*
pEpSet
)
{
SClient
*
pClient
=
parent
;
SClient
*
pClient
=
(
SClient
*
)
parent
;
pClient
->
pRsp
=
pMsg
;
tsem_post
(
pMgmt
->
clientRpc
);
tsem_post
(
&
pClient
->
sem
);
}
SClient
*
createClient
()
{
SClient
*
pClient
=
calloc
(
1
,
sizeof
(
SClient
));
SClient
*
pClient
=
(
SClient
*
)
calloc
(
1
,
sizeof
(
SClient
));
ASSERT
(
pClient
);
char
secretEncrypt
[
32
]
=
{
0
};
...
...
@@ -107,7 +110,7 @@ SClient* createClient() {
rpcInit
.
idleTime
=
30
*
1000
;
rpcInit
.
user
=
"root"
;
rpcInit
.
ckey
=
"key"
;
rpcInit
.
parent
=
p
Dnode
;
rpcInit
.
parent
=
p
Client
;
rpcInit
.
secret
=
(
char
*
)
secretEncrypt
;
rpcInit
.
parent
=
pClient
;
// rpcInit.spi = 1;
...
...
@@ -130,8 +133,8 @@ void sendMsg(SClient* pClient, SRpcMsg* pMsg) {
epSet
.
port
[
0
]
=
9527
;
strcpy
(
epSet
.
fqdn
[
0
],
"localhost"
);
rpcSendRequest
(
p
Mgm
t
->
clientRpc
,
&
epSet
,
pMsg
,
NULL
);
tsem_wait
(
pMgmt
->
clientRpc
);
rpcSendRequest
(
p
Clien
t
->
clientRpc
,
&
epSet
,
pMsg
,
NULL
);
tsem_wait
(
&
pClient
->
sem
);
}
class
DndTest01
:
public
::
testing
::
Test
{
...
...
@@ -150,7 +153,26 @@ class DndTest01 : public ::testing::Test {
};
TEST_F
(
DndTest01
,
connectMsg
)
{
SConnectMsg
*
pReq
=
rpcMallocCont
()
SConnectMsg
*
pReq
=
(
SConnectMsg
*
)
rpcMallocCont
(
sizeof
(
SConnectMsg
));
pReq
->
pid
=
1234
;
strcpy
(
pReq
->
app
,
"test01"
);
strcpy
(
pReq
->
app
,
""
);
SRpcMsg
rpcMsg
=
{.
pCont
=
pReq
,
.
contLen
=
sizeof
(
SConnectMsg
),
.
msgType
=
TSDB_MSG_TYPE_AUTH
};
sendMsg
(
pClient
,
&
rpcMsg
);
SConnectRsp
*
pRsp
=
(
SConnectRsp
*
)
pClient
->
pRsp
;
EXPECT_NE
(
pRsp
,
NULL
);
EXPECT_EQ
(
pRsp
->
acctId
,
1
);
EXPECT_GT
(
pRsp
->
clusterId
,
0
);
EXPECT_GT
(
pRsp
->
connId
,
1
);
EXPECT_EQ
(
pRsp
->
superAuth
,
1
);
EXPECT_EQ
(
pRsp
->
readAuth
,
1
);
EXPECT_EQ
(
pRsp
->
writeAuth
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
inUse
,
0
);
EXPECT_EQ
(
pRsp
->
epSet
.
numOfEps
,
1
);
EXPECT_EQ
(
pRsp
->
epSet
.
port
[
0
],
9527
);
EXPECT_STREQ
(
pRsp
->
epSet
.
fqdn
[
0
],
"localhost"
);
}
source/dnode/mgmt/impl/test/
test01
/deploy.cpp
→
source/dnode/mgmt/impl/test/
util
/deploy.cpp
浏览文件 @
aff44f1a
文件已移动
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录