Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
45391bcd
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看板
提交
45391bcd
编写于
12月 16, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refact test files
上级
7a2fd456
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
139 addition
and
132 deletion
+139
-132
source/dnode/mgmt/impl/test/CMakeLists.txt
source/dnode/mgmt/impl/test/CMakeLists.txt
+1
-1
source/dnode/mgmt/impl/test/cluster/CMakeLists.txt
source/dnode/mgmt/impl/test/cluster/CMakeLists.txt
+6
-6
source/dnode/mgmt/impl/test/cluster/cluster.cpp
source/dnode/mgmt/impl/test/cluster/cluster.cpp
+121
-114
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+2
-2
source/dnode/mgmt/impl/test/show/CMakeLists.txt
source/dnode/mgmt/impl/test/show/CMakeLists.txt
+6
-6
source/dnode/mnode/impl/src/mndCluster.c
source/dnode/mnode/impl/src/mndCluster.c
+2
-2
source/dnode/mnode/impl/src/mndShow.c
source/dnode/mnode/impl/src/mndShow.c
+1
-1
未找到文件。
source/dnode/mgmt/impl/test/CMakeLists.txt
浏览文件 @
45391bcd
...
...
@@ -2,7 +2,7 @@
add_subdirectory
(
acct
)
# add_subdirectory(auth)
# add_subdirectory(balance)
#
add_subdirectory(cluster)
add_subdirectory
(
cluster
)
add_subdirectory
(
db
)
add_subdirectory
(
dnode
)
# add_subdirectory(func)
...
...
source/dnode/mgmt/impl/test/cluster/CMakeLists.txt
浏览文件 @
45391bcd
add_executable
(
dn
dTestC
luster
""
)
add_executable
(
dn
ode_test_c
luster
""
)
target_sources
(
dn
dTestC
luster
target_sources
(
dn
ode_test_c
luster
PRIVATE
"cluster.cpp"
"../sut/deploy.cpp"
)
target_link_libraries
(
dn
dTestC
luster
dn
ode_test_c
luster
PUBLIC dnode
PUBLIC util
PUBLIC os
PUBLIC gtest_main
)
target_include_directories
(
dn
dTestC
luster
target_include_directories
(
dn
ode_test_c
luster
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/server/dnode/mgmt"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../inc"
...
...
@@ -24,6 +24,6 @@ target_include_directories(dndTestCluster
enable_testing
()
add_test
(
NAME dn
dTestC
luster
COMMAND dn
dTestC
luster
NAME dn
ode_test_c
luster
COMMAND dn
ode_test_c
luster
)
source/dnode/mgmt/impl/test/cluster/cluster.cpp
浏览文件 @
45391bcd
...
...
@@ -13,154 +13,161 @@
class
DndTestCluster
:
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
*
user
=
"root"
;
const
char
*
pass
=
"taosdata"
;
const
char
*
path
=
"/tmp/dndTestCluster"
;
const
char
*
fqdn
=
"localhost"
;
uint16_t
port
=
9521
;
initLog
(
"/tmp/tdlog"
);
pServer
=
createServer
(
path
,
fqdn
,
port
);
ASSERT
(
pServer
);
pClient
=
createClient
(
user
,
pass
,
fqdn
,
port
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:9030"
;
pServer
=
CreateServer
(
"/tmp/dnode_test_cluster"
,
fqdn
,
9030
,
firstEp
);
pClient
=
createClient
(
"root"
,
"taosdata"
,
fqdn
,
9030
);
taosMsleep
(
1100
);
}
static
void
TearDownTestSuite
()
{
stopServer
(
pServer
);
dropClient
(
pClient
);
pServer
=
NULL
;
pClient
=
NULL
;
}
static
SServer
*
pServer
;
static
SClient
*
pClient
;
static
int32_t
connId
;
};
SServer
*
DndTestCluster
::
pServer
;
SClient
*
DndTestCluster
::
pClient
;
int32_t
DndTestCluster
::
connId
;
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
TEST_F
(
DndTestCluster
,
ShowCluster
)
{
ASSERT_NE
(
pClient
,
nullptr
);
int32_t
showId
=
0
;
{
SShowMsg
*
pReq
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
pReq
->
type
=
TSDB_MGMT_TABLE_CLUSTER
;
strcpy
(
pReq
->
db
,
""
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SShowMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
SShowRsp
*
pRsp
=
(
SShowRsp
*
)
pMsg
->
pCont
;
ASSERT_NE
(
pRsp
,
nullptr
);
pRsp
->
showId
=
htonl
(
pRsp
->
showId
);
STableMetaMsg
*
pMeta
=
&
pRsp
->
tableMeta
;
pMeta
->
contLen
=
htonl
(
pMeta
->
contLen
);
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
pMeta
->
sversion
=
htons
(
pMeta
->
sversion
);
pMeta
->
tversion
=
htons
(
pMeta
->
tversion
);
pMeta
->
tid
=
htonl
(
pMeta
->
tid
);
pMeta
->
uid
=
htobe64
(
pMeta
->
uid
);
void
SendTheCheckShowMetaMsg
(
int8_t
showType
,
const
char
*
showName
,
int32_t
columns
,
const
char
*
db
)
{
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
pShow
->
type
=
showType
;
if
(
db
!=
NULL
)
{
strcpy
(
pShow
->
db
,
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
=
htonl
(
pMeta
->
numOfTags
);
pMeta
->
numOfColumns
=
htonl
(
pMeta
->
numOfColumns
);
pMeta
->
sversion
=
htonl
(
pMeta
->
sversion
);
pMeta
->
tversion
=
htonl
(
pMeta
->
tversion
);
pMeta
->
tuid
=
htobe64
(
pMeta
->
tuid
);
pMeta
->
suid
=
htobe64
(
pMeta
->
suid
);
showId
=
pRsp
->
showId
;
showId
=
p
Show
Rsp
->
showId
;
EXPECT_NE
(
pRsp
->
showId
,
0
);
EXPECT_EQ
(
pMeta
->
contLen
,
0
);
EXPECT_STREQ
(
pMeta
->
tbFname
,
"show cluster"
);
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
->
numOfColumns
,
3
);
EXPECT_EQ
(
pMeta
->
update
,
0
);
EXPECT_EQ
(
pMeta
->
sversion
,
0
);
EXPECT_EQ
(
pMeta
->
tversion
,
0
);
EXPECT_EQ
(
pMeta
->
tid
,
0
);
EXPECT_EQ
(
pMeta
->
uid
,
0
);
EXPECT_STREQ
(
pMeta
->
sTableName
,
""
);
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_INT
);
EXPECT_EQ
(
pSchema
->
bytes
,
4
);
EXPECT_STREQ
(
pSchema
->
name
,
"id"
);
pSchema
=
&
pMeta
->
pSchema
[
1
];
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
,
TSDB_DATA_TYPE_BINARY
);
EXPECT_EQ
(
pSchema
->
bytes
,
TSDB_CLUSTER_ID_LEN
+
VARSTR_HEADER_SIZE
);
EXPECT_STREQ
(
pSchema
->
name
,
"name"
);
EXPECT_EQ
(
pSchema
->
type
,
type
);
EXPECT_EQ
(
pSchema
->
bytes
,
bytes
);
EXPECT_STREQ
(
pSchema
->
name
,
name
);
}
pSchema
=
&
pMeta
->
pSchema
[
2
];
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"
);
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, completed);
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
;
}
{
SRetrieveTableMsg
*
pReq
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
pReq
->
showId
=
htonl
(
showId
);
pReq
->
free
=
0
;
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SRetrieveTableMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW_RETRIEVE
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
SRetrieveTableRsp
*
pRsp
=
(
SRetrieveTableRsp
*
)
pMsg
->
pCont
;
ASSERT_NE
(
pRsp
,
nullptr
);
pRsp
->
numOfRows
=
htonl
(
pRsp
->
numOfRows
);
pRsp
->
offset
=
htobe64
(
pRsp
->
offset
);
pRsp
->
useconds
=
htobe64
(
pRsp
->
useconds
);
pRsp
->
compLen
=
htonl
(
pRsp
->
compLen
);
EXPECT_EQ
(
pRsp
->
numOfRows
,
1
);
EXPECT_EQ
(
pRsp
->
offset
,
0
);
EXPECT_EQ
(
pRsp
->
useconds
,
0
);
EXPECT_EQ
(
pRsp
->
completed
,
1
);
EXPECT_EQ
(
pRsp
->
precision
,
TSDB_TIME_PRECISION_MILLI
);
EXPECT_EQ
(
pRsp
->
compressed
,
0
);
EXPECT_EQ
(
pRsp
->
reserved
,
0
);
EXPECT_EQ
(
pRsp
->
compLen
,
0
);
char
*
pData
=
pRsp
->
data
;
int32_t
pos
=
0
;
int32_t
id
=
*
((
int32_t
*
)(
pData
+
pos
));
void
CheckInt32
()
{
int32_t
data
=
*
((
int32_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int32_t
);
EXPECT_GT
(
data
,
0
);
}
void
CheckTimestamp
()
{
int64_t
data
=
*
((
int64_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int64_t
);
EXPECT_GT
(
data
,
0
);
}
int32_t
nameLen
=
varDataLen
(
pData
+
pos
);
void
CheckBinary
(
int32_t
len
)
{
pos
+=
sizeof
(
VarDataLenT
);
char
*
data
=
(
char
*
)(
pData
+
pos
);
pos
+=
len
;
}
char
*
name
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_CLUSTER_ID_LEN
;
int32_t
showId
;
STableMetaMsg
*
pMeta
;
SRetrieveTableRsp
*
pRetrieveRsp
;
char
*
pData
;
int32_t
pos
;
};
int64_t
create_time
=
*
((
int64_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int64_t
);
SServer
*
DndTestCluster
::
pServer
;
SClient
*
DndTestCluster
::
pClient
;
int32_t
DndTestCluster
::
connId
;
EXPECT_NE
(
id
,
0
);
EXPECT_EQ
(
nameLen
,
36
);
EXPECT_STRNE
(
name
,
""
);
EXPECT_GT
(
create_time
,
0
);
printf
(
"--- id:%d nameLen:%d name:%s time:%"
PRId64
" ---
\n
"
,
id
,
nameLen
,
name
,
create_time
);
}
TEST_F
(
DndTestCluster
,
01
_ShowCluster
)
{
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_CLUSTER
,
"show cluster"
,
3
,
NULL
);
CheckSchema
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"id"
);
CheckSchema
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_CLUSTER_ID_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
CheckSchema
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create time"
);
SendThenCheckShowRetrieveMsg
(
1
);
CheckInt32
();
CheckBinary
(
TSDB_CLUSTER_ID_LEN
);
CheckTimestamp
();
}
\ No newline at end of file
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
45391bcd
...
...
@@ -81,8 +81,8 @@ class DndTestDnode : public ::testing::Test {
pMeta
->
numOfTags
=
htonl
(
pMeta
->
numOfTags
);
pMeta
->
numOfColumns
=
htonl
(
pMeta
->
numOfColumns
);
pMeta
->
sversion
=
htonl
(
pMeta
->
sversion
);
pMeta
->
tversion
=
hton
s
(
pMeta
->
tversion
);
pMeta
->
tuid
=
hto
nl
(
pMeta
->
tuid
);
pMeta
->
tversion
=
hton
l
(
pMeta
->
tversion
);
pMeta
->
tuid
=
hto
be64
(
pMeta
->
tuid
);
pMeta
->
suid
=
htobe64
(
pMeta
->
suid
);
showId
=
pShowRsp
->
showId
;
...
...
source/dnode/mgmt/impl/test/show/CMakeLists.txt
浏览文件 @
45391bcd
add_executable
(
dn
dTestS
how
""
)
add_executable
(
dn
ode_test_s
how
""
)
target_sources
(
dn
dTestS
how
target_sources
(
dn
ode_test_s
how
PRIVATE
"show.cpp"
"../sut/deploy.cpp"
)
target_link_libraries
(
dn
dTestS
how
dn
ode_test_s
how
PUBLIC dnode
PUBLIC util
PUBLIC os
PUBLIC gtest_main
)
target_include_directories
(
dn
dTestS
how
target_include_directories
(
dn
ode_test_s
how
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/server/dnode/mgmt"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../inc"
...
...
@@ -24,6 +24,6 @@ target_include_directories(dndTestShow
enable_testing
()
add_test
(
NAME dn
dTestS
how
COMMAND dn
dTestS
how
NAME dn
ode_test_s
how
COMMAND dn
ode_test_s
how
)
source/dnode/mnode/impl/src/mndCluster.c
浏览文件 @
45391bcd
...
...
@@ -154,11 +154,11 @@ static int32_t mndGetClusterMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create
_
time"
);
strcpy
(
pSchema
[
cols
].
name
,
"create
time"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
pMeta
->
numOfColumns
=
hton
s
(
cols
);
pMeta
->
numOfColumns
=
hton
l
(
cols
);
strcpy
(
pMeta
->
tbFname
,
mndShowStr
(
pShow
->
type
));
pShow
->
numOfColumns
=
cols
;
...
...
source/dnode/mnode/impl/src/mndShow.c
浏览文件 @
45391bcd
...
...
@@ -291,7 +291,7 @@ char *mndShowStr(int32_t showType) {
case
TSDB_MGMT_TABLE_VNODES
:
return
"show vnodes"
;
case
TSDB_MGMT_TABLE_CLUSTER
:
return
"show cluster
s
"
;
return
"show cluster"
;
case
TSDB_MGMT_TABLE_STREAMTABLES
:
return
"show streamtables"
;
case
TSDB_MGMT_TABLE_TP
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录