more
This commit is contained in:
parent
cb5c12f1c6
commit
2ad2efdfa3
|
@ -71,60 +71,44 @@ static SKVRow vtCreateBasicTag() {
|
||||||
return pTag;
|
return pTag;
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(vnodeApiTest, vnode_simple_create_table_test) {
|
static void vtBuildCreateStbReq(tb_uid_t suid, char *tbname, SRpcMsg **ppMsg) {
|
||||||
vnodeDestroy("vnode1");
|
SRpcMsg * pMsg;
|
||||||
|
STSchema *pSchema;
|
||||||
|
STSchema *pTagSchema;
|
||||||
|
int zs;
|
||||||
|
void * pBuf;
|
||||||
|
|
||||||
GTEST_ASSERT_GE(vnodeInit(2), 0);
|
pSchema = vtCreateBasicSchema();
|
||||||
|
pTagSchema = vtCreateBasicTagSchema();
|
||||||
|
|
||||||
// Create and open a vnode
|
|
||||||
SVnode *pVnode = vnodeOpen("vnode1", NULL);
|
|
||||||
ASSERT_NE(pVnode, nullptr);
|
|
||||||
|
|
||||||
tb_uid_t suid = 1638166374163;
|
|
||||||
{
|
|
||||||
// Create a super table
|
|
||||||
STSchema *pSchema = vtCreateBasicSchema();
|
|
||||||
STSchema *pTagSchema = vtCreateBasicTagSchema();
|
|
||||||
char tbname[128] = "st";
|
|
||||||
|
|
||||||
SArray * pMsgs = (SArray *)taosArrayInit(1, sizeof(SRpcMsg *));
|
|
||||||
SVnodeReq vCreateSTbReq = VNODE_INIT_CREATE_STB_REQ(tbname, UINT32_MAX, UINT32_MAX, suid, pSchema, pTagSchema);
|
SVnodeReq vCreateSTbReq = VNODE_INIT_CREATE_STB_REQ(tbname, UINT32_MAX, UINT32_MAX, suid, pSchema, pTagSchema);
|
||||||
|
|
||||||
int zs = vnodeBuildReq(NULL, &vCreateSTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
zs = vnodeBuildReq(NULL, &vCreateSTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||||
SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg) + zs);
|
pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg) + zs);
|
||||||
pMsg->msgType = TSDB_MSG_TYPE_CREATE_TABLE;
|
pMsg->msgType = TSDB_MSG_TYPE_CREATE_TABLE;
|
||||||
pMsg->contLen = zs;
|
pMsg->contLen = zs;
|
||||||
pMsg->pCont = POINTER_SHIFT(pMsg, sizeof(SRpcMsg));
|
pMsg->pCont = POINTER_SHIFT(pMsg, sizeof(SRpcMsg));
|
||||||
|
|
||||||
void *pBuf = pMsg->pCont;
|
pBuf = pMsg->pCont;
|
||||||
|
|
||||||
vnodeBuildReq(&pBuf, &vCreateSTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
vnodeBuildReq(&pBuf, &vCreateSTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||||
META_CLEAR_TB_CFG(&vCreateSTbReq);
|
META_CLEAR_TB_CFG(&vCreateSTbReq);
|
||||||
|
|
||||||
taosArrayPush(pMsgs, &(pMsg));
|
|
||||||
|
|
||||||
vnodeProcessWMsgs(pVnode, pMsgs);
|
|
||||||
|
|
||||||
free(pMsg);
|
|
||||||
taosArrayDestroy(pMsgs);
|
|
||||||
tdFreeSchema(pSchema);
|
tdFreeSchema(pSchema);
|
||||||
tdFreeSchema(pTagSchema);
|
tdFreeSchema(pTagSchema);
|
||||||
}
|
|
||||||
|
|
||||||
{
|
*ppMsg = pMsg;
|
||||||
// Create some child tables
|
}
|
||||||
int ntables = 1000000;
|
|
||||||
int batch = 10;
|
static void vtBuildCreateCtbReq(tb_uid_t suid, char *tbname, SRpcMsg **ppMsg) {
|
||||||
for (int i = 0; i < ntables / batch; i++) {
|
SRpcMsg *pMsg;
|
||||||
SArray *pMsgs = (SArray *)taosArrayInit(batch, sizeof(SRpcMsg *));
|
int tz;
|
||||||
for (int j = 0; j < batch; j++) {
|
SKVRow pTag;
|
||||||
SKVRow pTag = vtCreateBasicTag();
|
|
||||||
char tbname[128];
|
pTag = vtCreateBasicTag();
|
||||||
sprintf(tbname, "tb%d", i * batch + j);
|
|
||||||
SVnodeReq vCreateCTbReq = VNODE_INIT_CREATE_CTB_REQ(tbname, UINT32_MAX, UINT32_MAX, suid, pTag);
|
SVnodeReq vCreateCTbReq = VNODE_INIT_CREATE_CTB_REQ(tbname, UINT32_MAX, UINT32_MAX, suid, pTag);
|
||||||
|
|
||||||
int tz = vnodeBuildReq(NULL, &vCreateCTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
tz = vnodeBuildReq(NULL, &vCreateCTbReq, TSDB_MSG_TYPE_CREATE_TABLE);
|
||||||
SRpcMsg *pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg) + tz);
|
pMsg = (SRpcMsg *)malloc(sizeof(SRpcMsg) + tz);
|
||||||
pMsg->msgType = TSDB_MSG_TYPE_CREATE_TABLE;
|
pMsg->msgType = TSDB_MSG_TYPE_CREATE_TABLE;
|
||||||
pMsg->contLen = tz;
|
pMsg->contLen = tz;
|
||||||
pMsg->pCont = POINTER_SHIFT(pMsg, sizeof(*pMsg));
|
pMsg->pCont = POINTER_SHIFT(pMsg, sizeof(*pMsg));
|
||||||
|
@ -134,26 +118,68 @@ TEST(vnodeApiTest, vnode_simple_create_table_test) {
|
||||||
META_CLEAR_TB_CFG(&vCreateCTbReq);
|
META_CLEAR_TB_CFG(&vCreateCTbReq);
|
||||||
free(pTag);
|
free(pTag);
|
||||||
|
|
||||||
taosArrayPush(pMsgs, &(pMsg));
|
*ppMsg = pMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
vnodeProcessWMsgs(pVnode, pMsgs);
|
static void vtClearMsgBatch(SArray *pMsgArr) {
|
||||||
|
SRpcMsg *pMsg;
|
||||||
for (int j = 0; j < batch; j++) {
|
for (size_t i = 0; i < taosArrayGetSize(pMsgArr); i++) {
|
||||||
SRpcMsg *pMsg = *(SRpcMsg **)taosArrayPop(pMsgs);
|
pMsg = *(SRpcMsg **)taosArrayGet(pMsgArr, i);
|
||||||
free(pMsg);
|
free(pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
taosArrayDestroy(pMsgs);
|
taosArrayClear(pMsgArr);
|
||||||
|
}
|
||||||
|
|
||||||
// std::cout << "the " << i << "th batch is created" << std::endl;
|
TEST(vnodeApiTest, vnode_simple_create_table_test) {
|
||||||
}
|
tb_uid_t suid = 1638166374163;
|
||||||
|
SRpcMsg *pMsg;
|
||||||
|
SArray * pMsgArr = NULL;
|
||||||
|
SVnode * pVnode;
|
||||||
|
int rcode;
|
||||||
|
int ntables = 1000000;
|
||||||
|
int batch = 10;
|
||||||
|
char tbname[128];
|
||||||
|
|
||||||
|
pMsgArr = (SArray *)taosArrayInit(batch, sizeof(pMsg));
|
||||||
|
|
||||||
|
vnodeDestroy("vnode1");
|
||||||
|
GTEST_ASSERT_GE(vnodeInit(2), 0);
|
||||||
|
|
||||||
|
// CREATE AND OPEN A VNODE
|
||||||
|
pVnode = vnodeOpen("vnode1", NULL);
|
||||||
|
ASSERT_NE(pVnode, nullptr);
|
||||||
|
|
||||||
|
// CREATE A SUPER TABLE
|
||||||
|
sprintf(tbname, "st");
|
||||||
|
vtBuildCreateStbReq(suid, tbname, &pMsg);
|
||||||
|
taosArrayPush(pMsgArr, &pMsg);
|
||||||
|
rcode = vnodeProcessWMsgs(pVnode, pMsgArr);
|
||||||
|
ASSERT_EQ(rcode, 0);
|
||||||
|
vtClearMsgBatch(pMsgArr);
|
||||||
|
|
||||||
|
// CREATE A LOT OF CHILD TABLES
|
||||||
|
for (int i = 0; i < ntables / batch; i++) {
|
||||||
|
// Build request batch
|
||||||
|
for (int j = 0; j < batch; j++) {
|
||||||
|
sprintf(tbname, "ct%d", i * batch + j + 1);
|
||||||
|
vtBuildCreateCtbReq(suid, tbname, &pMsg);
|
||||||
|
taosArrayPush(pMsgArr, &pMsg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close the vnode
|
// Process request batch
|
||||||
|
rcode = vnodeProcessWMsgs(pVnode, pMsgArr);
|
||||||
|
ASSERT_EQ(rcode, 0);
|
||||||
|
|
||||||
|
// Clear request batch
|
||||||
|
vtClearMsgBatch(pMsgArr);
|
||||||
|
}
|
||||||
|
|
||||||
|
// CLOSE THE VNODE
|
||||||
vnodeClose(pVnode);
|
vnodeClose(pVnode);
|
||||||
|
|
||||||
vnodeClear();
|
vnodeClear();
|
||||||
|
|
||||||
|
taosArrayDestroy(pMsgArr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(vnodeApiTest, vnode_simple_insert_test) {
|
TEST(vnodeApiTest, vnode_simple_insert_test) {
|
||||||
|
|
Loading…
Reference in New Issue