From 43f600e01b3eff3f3cf955e3a8817daca6255c74 Mon Sep 17 00:00:00 2001 From: Shengliang Guan Date: Mon, 13 Dec 2021 19:02:26 +0800 Subject: [PATCH] minor changes --- source/dnode/mgmt/impl/test/user/user.cpp | 82 +++++++++++++++++++---- 1 file changed, 68 insertions(+), 14 deletions(-) diff --git a/source/dnode/mgmt/impl/test/user/user.cpp b/source/dnode/mgmt/impl/test/user/user.cpp index 137e271b32..48be2635cd 100644 --- a/source/dnode/mgmt/impl/test/user/user.cpp +++ b/source/dnode/mgmt/impl/test/user/user.cpp @@ -185,30 +185,52 @@ TEST_F(DndTestUser, ShowUser) { } TEST_F(DndTestUser, CreateUser_01) { - SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(sizeof(SCreateUserMsg)); - strcpy(pReq->user, "u1"); - strcpy(pReq->pass, "p1"); + { + SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(sizeof(SCreateUserMsg)); + strcpy(pReq->user, "u1"); + strcpy(pReq->pass, "p1"); + + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = pReq; + rpcMsg.contLen = sizeof(SCreateUserMsg); + rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_USER; + + sendMsg(pClient, &rpcMsg); + SRpcMsg* pMsg = pClient->pRsp; + ASSERT_NE(pMsg, nullptr); + ASSERT_EQ(pMsg->code, 0); + } - SRpcMsg rpcMsg = {0}; - rpcMsg.pCont = pReq; - rpcMsg.contLen = sizeof(SCreateUserMsg); - rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_USER; + { + SCreateUserMsg* pReq = (SCreateUserMsg*)rpcMallocCont(sizeof(SCreateUserMsg)); + strcpy(pReq->user, "u2"); + strcpy(pReq->pass, "p2"); - sendMsg(pClient, &rpcMsg); - SRpcMsg* pMsg = pClient->pRsp; - ASSERT_NE(pMsg, nullptr); - ASSERT_EQ(pMsg->code, 0); + SRpcMsg rpcMsg = {0}; + rpcMsg.pCont = pReq; + rpcMsg.contLen = sizeof(SCreateUserMsg); + rpcMsg.msgType = TSDB_MSG_TYPE_CREATE_USER; + + sendMsg(pClient, &rpcMsg); + SRpcMsg* pMsg = pClient->pRsp; + ASSERT_NE(pMsg, nullptr); + ASSERT_EQ(pMsg->code, 0); + } SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_USER, "show users", 4); - SendThenCheckShowRetrieveMsg(2); + SendThenCheckShowRetrieveMsg(3); CheckBinary("u1", TSDB_USER_LEN); CheckBinary("root", TSDB_USER_LEN); + CheckBinary("u2", TSDB_USER_LEN); CheckBinary("normal", 10); CheckBinary("super", 10); + CheckBinary("normal", 10); + CheckTimestamp(); CheckTimestamp(); CheckTimestamp(); CheckBinary("root", TSDB_USER_LEN); CheckBinary("root", TSDB_USER_LEN); + CheckBinary("root", TSDB_USER_LEN); } TEST_F(DndTestUser, AlterUser_01) { @@ -227,15 +249,19 @@ TEST_F(DndTestUser, AlterUser_01) { ASSERT_EQ(pMsg->code, 0); SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_USER, "show users", 4); - SendThenCheckShowRetrieveMsg(2); + SendThenCheckShowRetrieveMsg(3); CheckBinary("u1", TSDB_USER_LEN); CheckBinary("root", TSDB_USER_LEN); + CheckBinary("u2", TSDB_USER_LEN); CheckBinary("normal", 10); CheckBinary("super", 10); + CheckBinary("normal", 10); + CheckTimestamp(); CheckTimestamp(); CheckTimestamp(); CheckBinary("root", TSDB_USER_LEN); CheckBinary("root", TSDB_USER_LEN); + CheckBinary("root", TSDB_USER_LEN); } TEST_F(DndTestUser, DropUser_01) { @@ -253,9 +279,37 @@ TEST_F(DndTestUser, DropUser_01) { ASSERT_EQ(pMsg->code, 0); SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_USER, "show users", 4); - SendThenCheckShowRetrieveMsg(1); + SendThenCheckShowRetrieveMsg(2); CheckBinary("root", TSDB_USER_LEN); + CheckBinary("u2", TSDB_USER_LEN); CheckBinary("super", 10); + CheckBinary("normal", 10); + CheckTimestamp(); CheckTimestamp(); CheckBinary("root", TSDB_USER_LEN); + CheckBinary("root", TSDB_USER_LEN); +} + +TEST_F(DndTestUser, RestartDnode) { + stopServer(pServer); + pServer = NULL; + + uInfo("start all server"); + + const char* fqdn = "localhost"; + const char* firstEp = "localhost:9530"; + pServer = startServer("/tmp/dndTestUser", fqdn, 9530, firstEp); + + uInfo("all server is running"); + + SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_USER, "show users", 4); + SendThenCheckShowRetrieveMsg(2); + CheckBinary("root", TSDB_USER_LEN); + CheckBinary("u2", TSDB_USER_LEN); + CheckBinary("super", 10); + CheckBinary("normal", 10); + CheckTimestamp(); + CheckTimestamp(); + CheckBinary("root", TSDB_USER_LEN); + CheckBinary("root", TSDB_USER_LEN); } -- GitLab