提交 7974143d 编写于 作者: S Shengliang Guan

minor changes

上级 dfd724a8
enable_testing()
add_subdirectory(qnode)
# add_subdirectory(auth)
# add_subdirectory(balance)
add_subdirectory(cluster)
......
/**
* @file dnode.cpp
* @author slguan (slguan@taosdata.com)
* @brief DNODE module dnode-msg tests
* @version 0.1
* @date 2021-12-15
*
* @copyright Copyright (c) 2021
*
*/
#include "sut.h"
class DndTestBnode : public ::testing::Test {
public:
void SetUp() override {}
void TearDown() override {}
public:
static void SetUpTestSuite() {
test.Init("/tmp/dnode_test_bnode1", 9068);
const char* fqdn = "localhost";
const char* firstEp = "localhost:9068";
server2.Start("/tmp/dnode_test_bnode2", fqdn, 9069, firstEp);
taosMsleep(300);
}
static void TearDownTestSuite() {
server2.Stop();
test.Cleanup();
}
static Testbase test;
static TestServer server2;
};
Testbase DndTestBnode::test;
TestServer DndTestBnode::server2;
TEST_F(DndTestBnode, 01_ShowBnode) {
test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, "");
CHECK_META("show bnodes", 3);
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 0);
}
TEST_F(DndTestBnode, 02_Create_Bnode_Invalid_Id) {
{
int32_t contLen = sizeof(SMCreateBnodeMsg);
SMCreateBnodeMsg* pReq = (SMCreateBnodeMsg*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(1);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, "");
CHECK_META("show bnodes", 3);
CHECK_SCHEMA(0, TSDB_DATA_TYPE_SMALLINT, 2, "id");
CHECK_SCHEMA(1, TSDB_DATA_TYPE_BINARY, TSDB_EP_LEN + VARSTR_HEADER_SIZE, "endpoint");
CHECK_SCHEMA(2, TSDB_DATA_TYPE_TIMESTAMP, 8, "create_time");
test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 1);
CheckInt16(1);
CheckBinary("localhost:9068", TSDB_EP_LEN);
CheckTimestamp();
}
}
TEST_F(DndTestBnode, 03_Create_Bnode_Invalid_Id) {
{
int32_t contLen = sizeof(SMCreateBnodeMsg);
SMCreateBnodeMsg* pReq = (SMCreateBnodeMsg*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(2);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_DNODE_NOT_EXIST);
}
}
TEST_F(DndTestBnode, 04_Create_Bnode) {
{
// create dnode
int32_t contLen = sizeof(SCreateDnodeMsg);
SCreateDnodeMsg* pReq = (SCreateDnodeMsg*)rpcMallocCont(contLen);
strcpy(pReq->fqdn, "localhost");
pReq->port = htonl(9069);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_DNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
taosMsleep(1300);
test.SendShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "");
test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 2);
}
{
// create bnode
int32_t contLen = sizeof(SMCreateBnodeMsg);
SMCreateBnodeMsg* pReq = (SMCreateBnodeMsg*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(2);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_CREATE_BNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, "");
test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 2);
CheckInt16(1);
CheckInt16(2);
CheckBinary("localhost:9068", TSDB_EP_LEN);
CheckBinary("localhost:9069", TSDB_EP_LEN);
CheckTimestamp();
CheckTimestamp();
}
{
// drop bnode
int32_t contLen = sizeof(SMDropBnodeMsg);
SMDropBnodeMsg* pReq = (SMDropBnodeMsg*)rpcMallocCont(contLen);
pReq->dnodeId = htonl(2);
SRpcMsg* pMsg = test.SendMsg(TDMT_MND_DROP_BNODE, pReq, contLen);
ASSERT_NE(pMsg, nullptr);
ASSERT_EQ(pMsg->code, 0);
test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, "");
test.SendShowRetrieveMsg();
EXPECT_EQ(test.GetShowRows(), 1);
CheckInt16(1);
CheckBinary("localhost:9068", TSDB_EP_LEN);
CheckTimestamp();
}
}
\ No newline at end of file
......@@ -9,7 +9,7 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestCluster : public ::testing::Test {
protected:
......
......@@ -9,7 +9,7 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestDb : public ::testing::Test {
protected:
......
......@@ -9,7 +9,7 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestDnode : public ::testing::Test {
public:
......
......@@ -9,7 +9,7 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestMnode : public ::testing::Test {
public:
......
......@@ -9,7 +9,7 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestProfile : public ::testing::Test {
protected:
......
aux_source_directory(. DQTEST_SRC)
add_executable(dnode_test_qnode ${DQTEST_SRC})
target_link_libraries(
dnode_test_qnode
PUBLIC sut
)
add_test(
NAME dnode_test_qnode
COMMAND dnode_test_qnode
)
/**
* @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;
......@@ -9,7 +9,7 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestShow : public ::testing::Test {
protected:
......
......@@ -9,7 +9,7 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestStb : public ::testing::Test {
protected:
......
......@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "base.h"
#include "sut.h"
static void processClientRsp(void* parent, SRpcMsg* pMsg, SEpSet* pEpSet) {
TestClient* client = (TestClient*)parent;
......
......@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "base.h"
#include "sut.h"
void* serverLoop(void* param) {
while (1) {
......
......@@ -13,7 +13,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "base.h"
#include "sut.h"
void Testbase::InitLog(const char* path) {
dDebugFlag = 0;
......
......@@ -9,7 +9,7 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestVgroup : public ::testing::Test {
protected:
......
......@@ -9,9 +9,9 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestAcct : public ::testing::Test {
class MndTestAcct : public ::testing::Test {
protected:
static void SetUpTestSuite() { test.Init("/tmp/mnode_test_acct", 9012); }
static void TearDownTestSuite() { test.Cleanup(); }
......@@ -23,9 +23,9 @@ class DndTestAcct : public ::testing::Test {
void TearDown() override {}
};
Testbase DndTestAcct::test;
Testbase MndTestAcct::test;
TEST_F(DndTestAcct, 01_CreateAcct) {
TEST_F(MndTestAcct, 01_Create_Acct) {
int32_t contLen = sizeof(SCreateAcctReq);
SCreateAcctReq* pReq = (SCreateAcctReq*)rpcMallocCont(contLen);
......@@ -35,7 +35,7 @@ TEST_F(DndTestAcct, 01_CreateAcct) {
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
}
TEST_F(DndTestAcct, 02_AlterAcct) {
TEST_F(MndTestAcct, 02_Alter_Acct) {
int32_t contLen = sizeof(SCreateAcctReq);
SAlterAcctReq* pReq = (SAlterAcctReq*)rpcMallocCont(contLen);
......@@ -45,7 +45,7 @@ TEST_F(DndTestAcct, 02_AlterAcct) {
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
}
TEST_F(DndTestAcct, 03_DropAcct) {
TEST_F(MndTestAcct, 03_Drop_Acct) {
int32_t contLen = sizeof(SDropAcctReq);
SDropAcctReq* pReq = (SDropAcctReq*)rpcMallocCont(contLen);
......@@ -55,7 +55,7 @@ TEST_F(DndTestAcct, 03_DropAcct) {
ASSERT_EQ(pMsg->code, TSDB_CODE_MND_MSG_NOT_PROCESSED);
}
TEST_F(DndTestAcct, 04_ShowAcct) {
TEST_F(MndTestAcct, 04_Show_Acct) {
int32_t contLen = sizeof(SShowMsg);
SShowMsg* pReq = (SShowMsg*)rpcMallocCont(contLen);
......
......@@ -9,9 +9,9 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestBnode : public ::testing::Test {
class MndTestBnode : public ::testing::Test {
public:
void SetUp() override {}
void TearDown() override {}
......@@ -35,10 +35,10 @@ class DndTestBnode : public ::testing::Test {
static TestServer server2;
};
Testbase DndTestBnode::test;
TestServer DndTestBnode::server2;
Testbase MndTestBnode::test;
TestServer MndTestBnode::server2;
TEST_F(DndTestBnode, 01_ShowBnode) {
TEST_F(MndTestBnode, 01_Show_Bnode) {
test.SendShowMetaMsg(TSDB_MGMT_TABLE_BNODE, "");
CHECK_META("show bnodes", 3);
......@@ -50,7 +50,7 @@ TEST_F(DndTestBnode, 01_ShowBnode) {
EXPECT_EQ(test.GetShowRows(), 0);
}
TEST_F(DndTestBnode, 02_Create_Bnode_Invalid_Id) {
TEST_F(MndTestBnode, 02_Create_Bnode_Invalid_Id) {
{
int32_t contLen = sizeof(SMCreateBnodeMsg);
......@@ -77,7 +77,7 @@ TEST_F(DndTestBnode, 02_Create_Bnode_Invalid_Id) {
}
}
TEST_F(DndTestBnode, 03_Create_Bnode_Invalid_Id) {
TEST_F(MndTestBnode, 03_Create_Bnode_Invalid_Id) {
{
int32_t contLen = sizeof(SMCreateBnodeMsg);
......@@ -90,7 +90,7 @@ TEST_F(DndTestBnode, 03_Create_Bnode_Invalid_Id) {
}
}
TEST_F(DndTestBnode, 04_Create_Bnode) {
TEST_F(MndTestBnode, 04_Create_Bnode) {
{
// create dnode
int32_t contLen = sizeof(SCreateDnodeMsg);
......
......@@ -9,9 +9,9 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestQnode : public ::testing::Test {
class MndTestQnode : public ::testing::Test {
public:
void SetUp() override {}
void TearDown() override {}
......@@ -35,10 +35,10 @@ class DndTestQnode : public ::testing::Test {
static TestServer server2;
};
Testbase DndTestQnode::test;
TestServer DndTestQnode::server2;
Testbase MndTestQnode::test;
TestServer MndTestQnode::server2;
TEST_F(DndTestQnode, 01_ShowQnode) {
TEST_F(MndTestQnode, 01_Show_Qnode) {
test.SendShowMetaMsg(TSDB_MGMT_TABLE_QNODE, "");
CHECK_META("show qnodes", 3);
......@@ -50,7 +50,7 @@ TEST_F(DndTestQnode, 01_ShowQnode) {
EXPECT_EQ(test.GetShowRows(), 0);
}
TEST_F(DndTestQnode, 02_Create_Qnode_Invalid_Id) {
TEST_F(MndTestQnode, 02_Create_Qnode_Invalid_Id) {
{
int32_t contLen = sizeof(SMCreateQnodeMsg);
......@@ -77,7 +77,7 @@ TEST_F(DndTestQnode, 02_Create_Qnode_Invalid_Id) {
}
}
TEST_F(DndTestQnode, 03_Create_Qnode_Invalid_Id) {
TEST_F(MndTestQnode, 03_Create_Qnode_Invalid_Id) {
{
int32_t contLen = sizeof(SMCreateQnodeMsg);
......@@ -90,7 +90,7 @@ TEST_F(DndTestQnode, 03_Create_Qnode_Invalid_Id) {
}
}
TEST_F(DndTestQnode, 04_Create_Qnode) {
TEST_F(MndTestQnode, 04_Create_Qnode) {
{
// create dnode
int32_t contLen = sizeof(SCreateDnodeMsg);
......
......@@ -9,9 +9,9 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestSnode : public ::testing::Test {
class MndTestSnode : public ::testing::Test {
public:
void SetUp() override {}
void TearDown() override {}
......@@ -35,10 +35,10 @@ class DndTestSnode : public ::testing::Test {
static TestServer server2;
};
Testbase DndTestSnode::test;
TestServer DndTestSnode::server2;
Testbase MndTestSnode::test;
TestServer MndTestSnode::server2;
TEST_F(DndTestSnode, 01_ShowSnode) {
TEST_F(MndTestSnode, 01_Show_Snode) {
test.SendShowMetaMsg(TSDB_MGMT_TABLE_SNODE, "");
CHECK_META("show snodes", 3);
......@@ -50,7 +50,7 @@ TEST_F(DndTestSnode, 01_ShowSnode) {
EXPECT_EQ(test.GetShowRows(), 0);
}
TEST_F(DndTestSnode, 02_Create_Snode_Invalid_Id) {
TEST_F(MndTestSnode, 02_Create_Snode_Invalid_Id) {
{
int32_t contLen = sizeof(SMCreateSnodeMsg);
......@@ -77,7 +77,7 @@ TEST_F(DndTestSnode, 02_Create_Snode_Invalid_Id) {
}
}
TEST_F(DndTestSnode, 03_Create_Snode_Invalid_Id) {
TEST_F(MndTestSnode, 03_Create_Snode_Invalid_Id) {
{
int32_t contLen = sizeof(SMCreateSnodeMsg);
......@@ -90,7 +90,7 @@ TEST_F(DndTestSnode, 03_Create_Snode_Invalid_Id) {
}
}
TEST_F(DndTestSnode, 04_Create_Snode) {
TEST_F(MndTestSnode, 04_Create_Snode) {
{
// create dnode
int32_t contLen = sizeof(SCreateDnodeMsg);
......
......@@ -9,10 +9,10 @@
*
*/
#include "base.h"
#include "sut.h"
#include "os.h"
class DndTestTrans : public ::testing::Test {
class MndTestTrans : public ::testing::Test {
protected:
static void SetUpTestSuite() { test.Init("/tmp/mnode_test_trans", 9013); }
static void TearDownTestSuite() { test.Cleanup(); }
......@@ -48,9 +48,9 @@ class DndTestTrans : public ::testing::Test {
void TearDown() override {}
};
Testbase DndTestTrans::test;
Testbase MndTestTrans::test;
TEST_F(DndTestTrans, 01_CreateUser_Crash) {
TEST_F(MndTestTrans, 01_Create_User_Crash) {
{
int32_t contLen = sizeof(SCreateUserReq);
......
......@@ -9,9 +9,9 @@
*
*/
#include "base.h"
#include "sut.h"
class DndTestUser : public ::testing::Test {
class MndTestUser : public ::testing::Test {
protected:
static void SetUpTestSuite() { test.Init("/tmp/mnode_test_user", 9011); }
static void TearDownTestSuite() { test.Cleanup(); }
......@@ -23,9 +23,9 @@ class DndTestUser : public ::testing::Test {
void TearDown() override {}
};
Testbase DndTestUser::test;
Testbase MndTestUser::test;
TEST_F(DndTestUser, 01_ShowUser) {
TEST_F(MndTestUser, 01_Show_User) {
test.SendShowMetaMsg(TSDB_MGMT_TABLE_USER, "");
CHECK_META("show users", 4);
......@@ -43,7 +43,7 @@ TEST_F(DndTestUser, 01_ShowUser) {
CheckBinary("root", TSDB_USER_LEN);
}
TEST_F(DndTestUser, 02_Create_User) {
TEST_F(MndTestUser, 02_Create_User) {
{
int32_t contLen = sizeof(SCreateUserReq);
......@@ -99,7 +99,7 @@ TEST_F(DndTestUser, 02_Create_User) {
EXPECT_EQ(test.GetShowRows(), 2);
}
TEST_F(DndTestUser, 03_Alter_User) {
TEST_F(MndTestUser, 03_Alter_User) {
{
int32_t contLen = sizeof(SAlterUserReq);
......@@ -149,7 +149,7 @@ TEST_F(DndTestUser, 03_Alter_User) {
}
}
TEST_F(DndTestUser, 04_Drop_User) {
TEST_F(MndTestUser, 04_Drop_User) {
{
int32_t contLen = sizeof(SDropUserReq);
......@@ -190,7 +190,7 @@ TEST_F(DndTestUser, 04_Drop_User) {
EXPECT_EQ(test.GetShowRows(), 1);
}
TEST_F(DndTestUser, 05_Create_Drop_Alter_User) {
TEST_F(MndTestUser, 05_Create_Drop_Alter_User) {
{
int32_t contLen = sizeof(SCreateUserReq);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册