TDengine/source/dnode/mgmt/impl/test/qnode/dqnode.cpp

74 lines
1.8 KiB
C++
Raw Normal View History

2022-01-04 12:36:54 +00:00
/**
* @file dqnode.cpp
* @author slguan (slguan@taosdata.com)
* @brief DNODE module qnode tests
* @version 1.0
* @date 2022-01-05
*
* @copyright Copyright (c) 2022
*
*/
#include "sut.h"
class DndTestQnode : public ::testing::Test {
protected:
static void SetUpTestSuite() { test.Init("/tmp/dnode_test_qnode", 9111); }
static void TearDownTestSuite() { test.Cleanup(); }
static Testbase test;
public:
void SetUp() override {}
void TearDown() override {}
};
Testbase DndTestQnode::test;
2022-01-04 12:42:03 +00:00
2022-01-04 13:31:49 +00:00
TEST_F(DndTestQnode, 01_Create_Qnode_Invalid) {
2022-01-04 12:42:03 +00:00
{
2022-01-04 13:31:49 +00:00
int32_t contLen = sizeof(SDCreateQnodeReq);
2022-01-04 12:42:03 +00:00
2022-01-04 13:31:49 +00:00
SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(2);
2022-01-04 12:42:03 +00:00
2022-01-04 13:31:49 +00:00
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen);
2022-01-04 12:42:03 +00:00
ASSERT_NE(pMsg, nullptr);
2022-01-04 13:31:49 +00:00
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ID_INVALID);
2022-01-04 12:42:03 +00:00
}
2022-01-04 13:31:49 +00:00
{
int32_t contLen = sizeof(SDCreateQnodeReq);
2022-01-04 12:42:03 +00:00
2022-01-04 13:31:49 +00:00
SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(1);
2022-01-04 12:42:03 +00:00
2022-01-04 13:31:49 +00:00
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
}
2022-01-04 12:42:03 +00:00
2022-01-04 13:31:49 +00:00
{
int32_t contLen = sizeof(SDCreateQnodeReq);
2022-01-04 12:42:03 +00:00
2022-01-04 13:31:49 +00:00
SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(1);
2022-01-04 12:42:03 +00:00
2022-01-04 13:31:49 +00:00
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED);
}
2022-01-04 12:42:03 +00:00
2022-01-04 13:31:49 +00:00
test.Restart();
2022-01-04 12:42:03 +00:00
2022-01-04 13:31:49 +00:00
{
int32_t contLen = sizeof(SDCreateQnodeReq);
SDCreateQnodeReq* pReq = (SDCreateQnodeReq*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(1);
SRpcMsg* pMsg = test.SendMsg(TDMT_DND_CREATE_QNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, TSDB_CODE_DND_QNODE_ALREADY_DEPLOYED);
}
2022-01-04 12:42:03 +00:00
}