提交 637bf33c 编写于 作者: X Xiaoyu Wang

fix: catalog unit test

上级 e2f82f44
...@@ -27,8 +27,8 @@ ...@@ -27,8 +27,8 @@
#ifdef WINDOWS #ifdef WINDOWS
#define TD_USE_WINSOCK #define TD_USE_WINSOCK
#endif #endif
#include "catalogInt.h"
#include "catalog.h" #include "catalog.h"
#include "catalogInt.h"
#include "os.h" #include "os.h"
#include "stub.h" #include "stub.h"
#include "taos.h" #include "taos.h"
...@@ -450,7 +450,7 @@ void ctgTestRspSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg ...@@ -450,7 +450,7 @@ void ctgTestRspSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg
metaRsp.sversion = ctgTestSVersion; metaRsp.sversion = ctgTestSVersion;
metaRsp.tversion = ctgTestTVersion; metaRsp.tversion = ctgTestTVersion;
metaRsp.suid = ctgTestSuid; metaRsp.suid = ctgTestSuid;
metaRsp.tuid = ctgTestSuid+1; metaRsp.tuid = ctgTestSuid + 1;
metaRsp.vgId = 0; metaRsp.vgId = 0;
metaRsp.pSchemas = (SSchema *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchema)); metaRsp.pSchemas = (SSchema *)taosMemoryMalloc((metaRsp.numOfTags + metaRsp.numOfColumns) * sizeof(SSchema));
...@@ -536,7 +536,6 @@ void ctgTestRspMultiSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRp ...@@ -536,7 +536,6 @@ void ctgTestRspMultiSTableMeta(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRp
tFreeSTableMetaRsp(&metaRsp); tFreeSTableMetaRsp(&metaRsp);
} }
void ctgTestRspErrIndexInfo(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { void ctgTestRspErrIndexInfo(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
rpcFreeCont(pMsg->pCont); rpcFreeCont(pMsg->pCont);
...@@ -545,7 +544,6 @@ void ctgTestRspErrIndexInfo(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMs ...@@ -545,7 +544,6 @@ void ctgTestRspErrIndexInfo(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMs
pRsp->pCont = NULL; pRsp->pCont = NULL;
} }
void ctgTestRspUserAuth(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { void ctgTestRspUserAuth(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
rpcFreeCont(pMsg->pCont); rpcFreeCont(pMsg->pCont);
...@@ -553,6 +551,7 @@ void ctgTestRspUserAuth(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *p ...@@ -553,6 +551,7 @@ void ctgTestRspUserAuth(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *p
strcpy(userRsp.user, ctgTestUsername); strcpy(userRsp.user, ctgTestUsername);
userRsp.version = 1; userRsp.version = 1;
userRsp.superAuth = 1; userRsp.superAuth = 1;
userRsp.enable = 1;
int32_t contLen = tSerializeSGetUserAuthRsp(NULL, 0, &userRsp); int32_t contLen = tSerializeSGetUserAuthRsp(NULL, 0, &userRsp);
void *pReq = rpcMallocCont(contLen); void *pReq = rpcMallocCont(contLen);
...@@ -611,7 +610,7 @@ void ctgTestRspTableIndex(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg ...@@ -611,7 +610,7 @@ void ctgTestRspTableIndex(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg
STableIndexInfo info = {0}; STableIndexInfo info = {0};
for (int32_t i = 0; i < ctgTestIndexNum; ++i) { for (int32_t i = 0; i < ctgTestIndexNum; ++i) {
info.interval = 1 + i; info.interval = 1 + i;
info.expr = (char*)taosMemoryCalloc(1, 10); info.expr = (char *)taosMemoryCalloc(1, 10);
taosArrayPush(tblRsp.pIndex, &info); taosArrayPush(tblRsp.pIndex, &info);
} }
...@@ -727,8 +726,6 @@ void ctgTestRspDndeList(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *p ...@@ -727,8 +726,6 @@ void ctgTestRspDndeList(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *p
tFreeSDnodeListRsp(&dRsp); tFreeSDnodeListRsp(&dRsp);
} }
void ctgTestRspAuto(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { void ctgTestRspAuto(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
switch (pMsg->msgType) { switch (pMsg->msgType) {
case TDMT_MND_USE_DB: case TDMT_MND_USE_DB:
...@@ -763,7 +760,6 @@ void ctgTestRspAuto(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) ...@@ -763,7 +760,6 @@ void ctgTestRspAuto(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp)
return; return;
} }
void ctgTestRspByIdx(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) { void ctgTestRspByIdx(void *shandle, SEpSet *pEpSet, SRpcMsg *pMsg, SRpcMsg *pRsp) {
switch (ctgTestRspFunc[ctgTestRspIdx]) { switch (ctgTestRspFunc[ctgTestRspIdx]) {
case CTGT_RSP_VGINFO: case CTGT_RSP_VGINFO:
...@@ -1204,7 +1200,6 @@ void *ctgTestSetCtableMetaThread(void *param) { ...@@ -1204,7 +1200,6 @@ void *ctgTestSetCtableMetaThread(void *param) {
return NULL; return NULL;
} }
void ctgTestFetchRows(TAOS_RES *result, int32_t *rows) { void ctgTestFetchRows(TAOS_RES *result, int32_t *rows) {
TAOS_ROW row; TAOS_ROW row;
int num_fields = taos_num_fields(result); int num_fields = taos_num_fields(result);
...@@ -1220,7 +1215,7 @@ void ctgTestFetchRows(TAOS_RES *result, int32_t *rows) { ...@@ -1220,7 +1215,7 @@ void ctgTestFetchRows(TAOS_RES *result, int32_t *rows) {
} }
} }
void ctgTestExecQuery(TAOS * taos, char* sql, bool fetch, int32_t *rows) { void ctgTestExecQuery(TAOS *taos, char *sql, bool fetch, int32_t *rows) {
TAOS_RES *result = taos_query(taos, sql); TAOS_RES *result = taos_query(taos, sql);
int code = taos_errno(result); int code = taos_errno(result);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
...@@ -1232,7 +1227,6 @@ void ctgTestExecQuery(TAOS * taos, char* sql, bool fetch, int32_t *rows) { ...@@ -1232,7 +1227,6 @@ void ctgTestExecQuery(TAOS * taos, char* sql, bool fetch, int32_t *rows) {
taos_free_result(result); taos_free_result(result);
} }
TEST(tableMeta, normalTable) { TEST(tableMeta, normalTable) {
struct SCatalog *pCtg = NULL; struct SCatalog *pCtg = NULL;
SVgroupInfo vgInfo = {0}; SVgroupInfo vgInfo = {0};
...@@ -2045,7 +2039,6 @@ TEST(refreshGetMeta, normal2child) { ...@@ -2045,7 +2039,6 @@ TEST(refreshGetMeta, normal2child) {
ctgTestCurrentSTableName = NULL; ctgTestCurrentSTableName = NULL;
} }
TEST(refreshGetMeta, stable2child) { TEST(refreshGetMeta, stable2child) {
struct SCatalog *pCtg = NULL; struct SCatalog *pCtg = NULL;
SRequestConnInfo connInfo = {0}; SRequestConnInfo connInfo = {0};
...@@ -2966,14 +2959,13 @@ TEST(apiTest, catalogGetQnodeList_test) { ...@@ -2966,14 +2959,13 @@ TEST(apiTest, catalogGetQnodeList_test) {
ASSERT_EQ(taosArrayGetSize(qnodeList), ctgTestQnodeNum); ASSERT_EQ(taosArrayGetSize(qnodeList), ctgTestQnodeNum);
for (int32_t i = 0; i < ctgTestQnodeNum; ++i) { for (int32_t i = 0; i < ctgTestQnodeNum; ++i) {
SQueryNodeLoad * pLoad = (SQueryNodeLoad *)taosArrayGet(qnodeList, i); SQueryNodeLoad *pLoad = (SQueryNodeLoad *)taosArrayGet(qnodeList, i);
ASSERT_EQ(pLoad->addr.nodeId, i); ASSERT_EQ(pLoad->addr.nodeId, i);
} }
catalogDestroy(); catalogDestroy();
} }
TEST(apiTest, catalogGetUdfInfo_test) { TEST(apiTest, catalogGetUdfInfo_test) {
struct SCatalog *pCtg = NULL; struct SCatalog *pCtg = NULL;
SRequestConnInfo connInfo = {0}; SRequestConnInfo connInfo = {0};
...@@ -3003,7 +2995,6 @@ TEST(apiTest, catalogGetUdfInfo_test) { ...@@ -3003,7 +2995,6 @@ TEST(apiTest, catalogGetUdfInfo_test) {
catalogDestroy(); catalogDestroy();
} }
TEST(apiTest, catalogGetServerVersion_test) { TEST(apiTest, catalogGetServerVersion_test) {
struct SCatalog *pCtg = NULL; struct SCatalog *pCtg = NULL;
SRequestConnInfo connInfo = {0}; SRequestConnInfo connInfo = {0};
...@@ -3025,7 +3016,7 @@ TEST(apiTest, catalogGetServerVersion_test) { ...@@ -3025,7 +3016,7 @@ TEST(apiTest, catalogGetServerVersion_test) {
code = catalogGetHandle(ctgTestClusterId, &pCtg); code = catalogGetHandle(ctgTestClusterId, &pCtg);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
char* ver = NULL; char *ver = NULL;
code = catalogGetServerVersion(pCtg, mockPointer, &ver); code = catalogGetServerVersion(pCtg, mockPointer, &ver);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
ASSERT_TRUE(0 == strcmp(ver, "1.0")); ASSERT_TRUE(0 == strcmp(ver, "1.0"));
...@@ -3065,7 +3056,6 @@ TEST(apiTest, catalogUpdateTableIndex_test) { ...@@ -3065,7 +3056,6 @@ TEST(apiTest, catalogUpdateTableIndex_test) {
catalogDestroy(); catalogDestroy();
} }
TEST(apiTest, catalogGetDnodeList_test) { TEST(apiTest, catalogGetDnodeList_test) {
struct SCatalog *pCtg = NULL; struct SCatalog *pCtg = NULL;
SRequestConnInfo connInfo = {0}; SRequestConnInfo connInfo = {0};
...@@ -3087,7 +3077,7 @@ TEST(apiTest, catalogGetDnodeList_test) { ...@@ -3087,7 +3077,7 @@ TEST(apiTest, catalogGetDnodeList_test) {
code = catalogGetHandle(ctgTestClusterId, &pCtg); code = catalogGetHandle(ctgTestClusterId, &pCtg);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
SArray* pList = NULL; SArray *pList = NULL;
code = catalogGetDnodeList(pCtg, mockPointer, &pList); code = catalogGetDnodeList(pCtg, mockPointer, &pList);
ASSERT_EQ(code, 0); ASSERT_EQ(code, 0);
ASSERT_EQ(taosArrayGetSize(pList), 1); ASSERT_EQ(taosArrayGetSize(pList), 1);
...@@ -3149,7 +3139,6 @@ TEST(intTest, autoCreateTableTest) { ...@@ -3149,7 +3139,6 @@ TEST(intTest, autoCreateTableTest) {
#endif #endif
int main(int argc, char **argv) { int main(int argc, char **argv) {
testing::InitGoogleTest(&argc, argv); testing::InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS(); return RUN_ALL_TESTS();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册