Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ef0648d5
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看板
提交
ef0648d5
编写于
10月 28, 2022
作者:
D
dapan1121
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: add more ut cases
上级
b6068fd9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
236 addition
and
0 deletion
+236
-0
source/libs/catalog/test/catalogTests.cpp
source/libs/catalog/test/catalogTests.cpp
+236
-0
未找到文件。
source/libs/catalog/test/catalogTests.cpp
浏览文件 @
ef0648d5
...
...
@@ -59,6 +59,10 @@ enum {
CTGT_RSP_USERAUTH
,
CTGT_RSP_TBLCFG
,
CTGT_RSP_TBLINDEX
,
CTGT_RSP_DBCFG
,
CTGT_RSP_QNODELIST
,
CTGT_RSP_UDF
,
CTGT_RSP_SVRVER
,
CTGT_RSP_TBMETA_NOT_EXIST
,
};
...
...
@@ -74,7 +78,10 @@ int32_t ctgTestVgVersion = 1;
int32_t
ctgTestVgNum
=
10
;
int32_t
ctgTestColNum
=
2
;
int32_t
ctgTestTagNum
=
1
;
int32_t
ctgTestQnodeNum
=
3
;
int32_t
ctgTestIndexNum
=
3
;
int32_t
ctgTestFuncNum
=
2
;
int32_t
ctgTestFuncType
=
3
;
int32_t
ctgTestSVersion
=
1
;
int32_t
ctgTestTVersion
=
1
;
int32_t
ctgTestSuid
=
2
;
...
...
@@ -617,6 +624,84 @@ void ctgTestRspTableIndex(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg
tFreeSTableIndexRsp
(
&
tblRsp
);
}
void
ctgTestRspDBCfg
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
rpcFreeCont
(
pMsg
->
pCont
);
static
int32_t
idx
=
1
;
SDbCfgRsp
dbRsp
=
{
0
};
dbRsp
.
numOfVgroups
=
ctgTestVgNum
;
int32_t
contLen
=
tSerializeSDbCfgRsp
(
NULL
,
0
,
&
dbRsp
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDbCfgRsp
(
pReq
,
contLen
,
&
dbRsp
);
pRsp
->
code
=
0
;
pRsp
->
contLen
=
contLen
;
pRsp
->
pCont
=
pReq
;
}
void
ctgTestRspQnodeList
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
rpcFreeCont
(
pMsg
->
pCont
);
SQnodeListRsp
qlistRsp
=
{
0
};
qlistRsp
.
qnodeList
=
taosArrayInit
(
10
,
sizeof
(
SQueryNodeLoad
));
for
(
int32_t
i
=
0
;
i
<
ctgTestQnodeNum
;
++
i
)
{
SQueryNodeLoad
nodeLoad
=
{
0
};
nodeLoad
.
addr
.
nodeId
=
i
;
(
void
)
taosArrayPush
(
qlistRsp
.
qnodeList
,
&
nodeLoad
);
}
int32_t
rspLen
=
tSerializeSQnodeListRsp
(
NULL
,
0
,
&
qlistRsp
);
void
*
pReq
=
rpcMallocCont
(
rspLen
);
tSerializeSQnodeListRsp
(
pReq
,
rspLen
,
&
qlistRsp
);
pRsp
->
code
=
0
;
pRsp
->
contLen
=
rspLen
;
pRsp
->
pCont
=
pReq
;
tFreeSQnodeListRsp
(
&
qlistRsp
);
}
void
ctgTestRspUdfInfo
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
rpcFreeCont
(
pMsg
->
pCont
);
SRetrieveFuncRsp
funcRsp
=
{
0
};
funcRsp
.
numOfFuncs
=
1
;
funcRsp
.
pFuncInfos
=
taosArrayInit
(
1
,
sizeof
(
SFuncInfo
));
SFuncInfo
funcInfo
=
{
0
};
strcpy
(
funcInfo
.
name
,
"func1"
);
funcInfo
.
funcType
=
ctgTestFuncType
;
(
void
)
taosArrayPush
(
funcRsp
.
pFuncInfos
,
&
funcInfo
);
int32_t
rspLen
=
tSerializeSRetrieveFuncRsp
(
NULL
,
0
,
&
funcRsp
);
void
*
pReq
=
rpcMallocCont
(
rspLen
);
tSerializeSRetrieveFuncRsp
(
pReq
,
rspLen
,
&
funcRsp
);
pRsp
->
code
=
0
;
pRsp
->
contLen
=
rspLen
;
pRsp
->
pCont
=
pReq
;
tFreeSRetrieveFuncRsp
(
&
funcRsp
);
}
void
ctgTestRspSvrVer
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
rpcFreeCont
(
pMsg
->
pCont
);
SServerVerRsp
verRsp
=
{
0
};
strcpy
(
verRsp
.
ver
,
"1.0"
);
int32_t
rspLen
=
tSerializeSServerVerRsp
(
NULL
,
0
,
&
verRsp
);
void
*
pReq
=
rpcMallocCont
(
rspLen
);
tSerializeSServerVerRsp
(
pReq
,
rspLen
,
&
verRsp
);
pRsp
->
code
=
0
;
pRsp
->
contLen
=
rspLen
;
pRsp
->
pCont
=
pReq
;
}
void
ctgTestRspAuto
(
void
*
shandle
,
SEpSet
*
pEpSet
,
SRpcMsg
*
pMsg
,
SRpcMsg
*
pRsp
)
{
switch
(
pMsg
->
msgType
)
{
...
...
@@ -630,6 +715,18 @@ void ctgTestRspAuto(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp)
case
TDMT_MND_GET_TABLE_INDEX
:
ctgTestRspTableIndex
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
case
TDMT_MND_GET_DB_CFG
:
ctgTestRspDBCfg
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
case
TDMT_MND_QNODE_LIST
:
ctgTestRspQnodeList
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
case
TDMT_MND_RETRIEVE_FUNC
:
ctgTestRspUdfInfo
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
case
TDMT_MND_SERVER_VERSION
:
ctgTestRspSvrVer
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
default:
break
;
}
...
...
@@ -670,6 +767,18 @@ void ctgTestRspByIdx(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp
case
CTGT_RSP_TBLINDEX
:
ctgTestRspTableIndex
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
case
CTGT_RSP_DBCFG
:
ctgTestRspDBCfg
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
case
CTGT_RSP_QNODELIST
:
ctgTestRspQnodeList
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
case
CTGT_RSP_UDF
:
ctgTestRspUdfInfo
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
case
CTGT_RSP_SVRVER
:
ctgTestRspSvrVer
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
default:
ctgTestRspAuto
(
shandle
,
pEpSet
,
pMsg
,
pRsp
);
break
;
...
...
@@ -2712,6 +2821,133 @@ TEST(apiTest, catalogGetTableIndex_test) {
catalogDestroy
();
}
TEST
(
apiTest
,
catalogGetDBCfg_test
)
{
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
connInfo
=
{
0
};
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
&
connInfo
;
ctgTestInitLogFile
();
memset
(
ctgTestRspFunc
,
0
,
sizeof
(
ctgTestRspFunc
));
ctgTestRspIdx
=
0
;
ctgTestRspFunc
[
0
]
=
CTGT_RSP_DBCFG
;
ctgTestSetRspByIdx
();
initQueryModuleMsgHandle
();
int32_t
code
=
catalogInit
(
NULL
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SName
n
=
{
TSDB_TABLE_NAME_T
,
1
,
{
0
},
{
0
}};
strcpy
(
n
.
dbname
,
"db1"
);
strcpy
(
n
.
tname
,
ctgTestTablename
);
SDbCfgInfo
cfgInfo
=
{
0
};
code
=
catalogGetDBCfg
(
pCtg
,
mockPointer
,
ctgTestDbname
,
&
cfgInfo
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
cfgInfo
.
numOfVgroups
,
ctgTestVgNum
);
catalogDestroy
();
}
TEST
(
apiTest
,
catalogGetQnodeList_test
)
{
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
connInfo
=
{
0
};
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
&
connInfo
;
ctgTestInitLogFile
();
memset
(
ctgTestRspFunc
,
0
,
sizeof
(
ctgTestRspFunc
));
ctgTestRspIdx
=
0
;
ctgTestRspFunc
[
0
]
=
CTGT_RSP_QNODELIST
;
ctgTestSetRspByIdx
();
initQueryModuleMsgHandle
();
int32_t
code
=
catalogInit
(
NULL
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SArray
*
qnodeList
=
taosArrayInit
(
10
,
sizeof
(
SQueryNodeLoad
));
code
=
catalogGetQnodeList
(
pCtg
,
mockPointer
,
qnodeList
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
taosArrayGetSize
(
qnodeList
),
ctgTestQnodeNum
);
for
(
int32_t
i
=
0
;
i
<
ctgTestQnodeNum
;
++
i
)
{
SQueryNodeLoad
*
pLoad
=
(
SQueryNodeLoad
*
)
taosArrayGet
(
qnodeList
,
i
);
ASSERT_EQ
(
pLoad
->
addr
.
nodeId
,
i
);
}
catalogDestroy
();
}
TEST
(
apiTest
,
catalogGetUdfInfo_test
)
{
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
connInfo
=
{
0
};
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
&
connInfo
;
ctgTestInitLogFile
();
memset
(
ctgTestRspFunc
,
0
,
sizeof
(
ctgTestRspFunc
));
ctgTestRspIdx
=
0
;
ctgTestRspFunc
[
0
]
=
CTGT_RSP_UDF
;
ctgTestSetRspByIdx
();
initQueryModuleMsgHandle
();
int32_t
code
=
catalogInit
(
NULL
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
SFuncInfo
funcInfo
=
{
0
};
code
=
catalogGetUdfInfo
(
pCtg
,
mockPointer
,
"func1"
,
&
funcInfo
);
ASSERT_EQ
(
code
,
0
);
ASSERT_EQ
(
funcInfo
.
funcType
,
ctgTestFuncType
);
catalogDestroy
();
}
TEST
(
apiTest
,
catalogGetServerVersion_test
)
{
struct
SCatalog
*
pCtg
=
NULL
;
SRequestConnInfo
connInfo
=
{
0
};
SRequestConnInfo
*
mockPointer
=
(
SRequestConnInfo
*
)
&
connInfo
;
ctgTestInitLogFile
();
memset
(
ctgTestRspFunc
,
0
,
sizeof
(
ctgTestRspFunc
));
ctgTestRspIdx
=
0
;
ctgTestRspFunc
[
0
]
=
CTGT_RSP_SVRVER
;
ctgTestSetRspByIdx
();
initQueryModuleMsgHandle
();
int32_t
code
=
catalogInit
(
NULL
);
ASSERT_EQ
(
code
,
0
);
code
=
catalogGetHandle
(
ctgTestClusterId
,
&
pCtg
);
ASSERT_EQ
(
code
,
0
);
char
*
ver
=
NULL
;
code
=
catalogGetServerVersion
(
pCtg
,
mockPointer
,
&
ver
);
ASSERT_EQ
(
code
,
0
);
ASSERT_TRUE
(
0
==
strcmp
(
ver
,
"1.0"
));
catalogDestroy
();
}
int
main
(
int
argc
,
char
**
argv
)
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录