Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
ac7a543b
T
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
ac7a543b
编写于
12月 15, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
TD-10431 acct test
上级
c8a74657
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
111 addition
and
97 deletion
+111
-97
source/dnode/mgmt/impl/test/CMakeLists.txt
source/dnode/mgmt/impl/test/CMakeLists.txt
+1
-1
source/dnode/mgmt/impl/test/acct/CMakeLists.txt
source/dnode/mgmt/impl/test/acct/CMakeLists.txt
+6
-6
source/dnode/mgmt/impl/test/acct/acct.cpp
source/dnode/mgmt/impl/test/acct/acct.cpp
+13
-10
source/dnode/mgmt/impl/test/db/db.cpp
source/dnode/mgmt/impl/test/db/db.cpp
+79
-67
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+7
-7
source/dnode/mgmt/impl/test/user/user.cpp
source/dnode/mgmt/impl/test/user/user.cpp
+5
-5
source/dnode/mnode/impl/src/mndDb.c
source/dnode/mnode/impl/src/mndDb.c
+0
-1
未找到文件。
source/dnode/mgmt/impl/test/CMakeLists.txt
浏览文件 @
ac7a543b
#
add_subdirectory(acct)
add_subdirectory
(
acct
)
# add_subdirectory(auth)
# add_subdirectory(balance)
# add_subdirectory(cluster)
...
...
source/dnode/mgmt/impl/test/acct/CMakeLists.txt
浏览文件 @
ac7a543b
add_executable
(
dn
dTestA
cct
""
)
add_executable
(
dn
ode_test_a
cct
""
)
target_sources
(
dn
dTestA
cct
target_sources
(
dn
ode_test_a
cct
PRIVATE
"acct.cpp"
"../sut/deploy.cpp"
)
target_link_libraries
(
dn
dTestA
cct
dn
ode_test_a
cct
PUBLIC dnode
PUBLIC util
PUBLIC os
PUBLIC gtest_main
)
target_include_directories
(
dn
dTestA
cct
target_include_directories
(
dn
ode_test_a
cct
PUBLIC
"
${
CMAKE_SOURCE_DIR
}
/include/server/dnode/mgmt"
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/../../inc"
...
...
@@ -24,6 +24,6 @@ target_include_directories(dndTestAcct
enable_testing
()
add_test
(
NAME dn
dTestA
cct
COMMAND dn
dTestA
cct
NAME dn
ode_test_a
cct
COMMAND dn
ode_test_a
cct
)
source/dnode/mgmt/impl/test/acct/acct.cpp
浏览文件 @
ac7a543b
...
...
@@ -17,24 +17,27 @@
class
DndTestAcct
:
public
::
testing
::
Test
{
protected:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
static
SServer
*
CreateServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
)
{
SServer
*
pServer
=
createServer
(
path
,
fqdn
,
port
,
firstEp
);
ASSERT
(
pServer
);
return
pServer
;
}
static
void
SetUpTestSuite
()
{
const
char
*
user
=
"root"
;
const
char
*
pass
=
"taosdata"
;
const
char
*
path
=
"/tmp/dndTestAcct"
;
const
char
*
fqdn
=
"localhost"
;
uint16_t
port
=
9520
;
initLog
(
"/tmp/tdlog"
);
pServer
=
createServer
(
path
,
fqdn
,
port
);
ASSERT
(
pServer
);
pClient
=
createClient
(
user
,
pass
,
fqdn
,
port
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:9012"
;
pServer
=
CreateServer
(
"/tmp/dnode_test_user"
,
fqdn
,
9012
,
firstEp
);
pClient
=
createClient
(
"root"
,
"taosdata"
,
fqdn
,
9012
);
taosMsleep
(
300
);
}
static
void
TearDownTestSuite
()
{
stopServer
(
pServer
);
dropClient
(
pClient
);
pServer
=
NULL
;
pClient
=
NULL
;
}
static
SServer
*
pServer
;
...
...
source/dnode/mgmt/impl/test/db/db.cpp
浏览文件 @
ac7a543b
...
...
@@ -182,7 +182,7 @@ SServer* DndTestDb::pServer;
SClient
*
DndTestDb
::
pClient
;
int32_t
DndTestDb
::
connId
;
TEST_F
(
DndTestDb
,
ShowDb
)
{
TEST_F
(
DndTestDb
,
01
_
ShowDb
)
{
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
);
CheckSchema
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
"name"
);
CheckSchema
(
1
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create time"
);
...
...
@@ -204,7 +204,7 @@ TEST_F(DndTestDb, ShowDb) {
SendThenCheckShowRetrieveMsg
(
0
);
}
TEST_F
(
DndTestDb
,
CreateDb_01
)
{
TEST_F
(
DndTestDb
,
02
_CreateDb
)
{
{
SCreateDbMsg
*
pReq
=
(
SCreateDbMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateDbMsg
));
strcpy
(
pReq
->
db
,
"1.d1"
);
...
...
@@ -258,65 +258,51 @@ TEST_F(DndTestDb, CreateDb_01) {
CheckInt8
(
0
);
// update
}
#if 0
TEST_F(DndTestDb, AlterUser_01) {
SAlterUserMsg* pReq = (SAlterUserMsg*)rpcMallocCont(sizeof(SAlterUserMsg));
strcpy(pReq->user, "u1");
strcpy(pReq->pass, "p2");
SRpcMsg rpcMsg = {0};
rpcMsg.pCont = pReq;
rpcMsg.contLen = sizeof(SAlterUserMsg);
rpcMsg.msgType = TSDB_MSG_TYPE_ALTER_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(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(DndTestDb, DropUser_01) {
SDropUserMsg* pReq = (SDropUserMsg*)rpcMallocCont(sizeof(SDropUserMsg));
strcpy(pReq->user, "u1");
TEST_F
(
DndTestDb
,
03
_AlterDb
)
{
{
SAlterDbMsg
*
pReq
=
(
SAlterDbMsg
*
)
rpcMallocCont
(
sizeof
(
SAlterDbMsg
));
strcpy
(
pReq
->
db
,
"1.d1"
);
pReq
->
totalBlocks
=
htonl
(
12
);
pReq
->
daysToKeep0
=
htonl
(
300
);
pReq
->
daysToKeep1
=
htonl
(
400
);
pReq
->
daysToKeep2
=
htonl
(
500
);
pReq
->
fsyncPeriod
=
htonl
(
4000
);
pReq
->
walLevel
=
2
;
pReq
->
quorum
=
2
;
pReq
->
cacheLastRow
=
1
;
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg.contLen = sizeof(SDropUser
Msg);
rpcMsg.msgType = TSDB_MSG_TYPE_DROP_USER
;
rpcMsg
.
contLen
=
sizeof
(
SAlterDb
Msg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_ALTER_DB
;
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);
CheckBinary("root", TSDB_USER_LEN);
CheckBinary("u2", TSDB_USER_LEN);
CheckBinary("super", 10);
CheckBinary("normal", 10);
CheckTimestamp();
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
);
SendThenCheckShowRetrieveMsg
(
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckTimestamp
();
CheckBinary("root", TSDB_USER_LEN);
CheckBinary("root", TSDB_USER_LEN);
CheckInt16
(
1
);
// replica
CheckInt16
(
2
);
// quorum
CheckInt16
(
10
);
// days
CheckBinary
(
"300,400,500"
,
24
);
// days
CheckInt32
(
16
);
// cache
CheckInt32
(
12
);
// blocks
CheckInt32
(
100
);
// minrows
CheckInt32
(
4096
);
// maxrows
CheckInt8
(
2
);
// wallevel
CheckInt32
(
4000
);
// fsync
CheckInt8
(
2
);
// comp
CheckInt8
(
1
);
// cachelast
CheckBinary
(
"ms"
,
3
);
// precision
CheckInt8
(
0
);
// update
}
TEST_F(DndTestDb, RestartDnode) {
TEST_F
(
DndTestDb
,
04
_
RestartDnode
)
{
stopServer
(
pServer
);
pServer
=
NULL
;
...
...
@@ -328,16 +314,42 @@ TEST_F(DndTestDb, RestartDnode) {
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();
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
);
SendThenCheckShowRetrieveMsg
(
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckTimestamp
();
CheckBinary("root", TSDB_USER_LEN);
CheckBinary("root", TSDB_USER_LEN);
CheckInt16
(
1
);
// replica
CheckInt16
(
2
);
// quorum
CheckInt16
(
10
);
// days
CheckBinary
(
"300,400,500"
,
24
);
// days
CheckInt32
(
16
);
// cache
CheckInt32
(
12
);
// blocks
CheckInt32
(
100
);
// minrows
CheckInt32
(
4096
);
// maxrows
CheckInt8
(
2
);
// wallevel
CheckInt32
(
4000
);
// fsync
CheckInt8
(
2
);
// comp
CheckInt8
(
1
);
// cachelast
CheckBinary
(
"ms"
,
3
);
// precision
CheckInt8
(
0
);
// update
}
#endif
\ No newline at end of file
TEST_F
(
DndTestDb
,
05
_DropDb
)
{
{
SDropDbMsg
*
pReq
=
(
SDropDbMsg
*
)
rpcMallocCont
(
sizeof
(
SAlterDbMsg
));
strcpy
(
pReq
->
db
,
"1.d1"
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SDropDbMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_DROP_DB
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
);
SendThenCheckShowRetrieveMsg
(
0
);
}
\ No newline at end of file
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
ac7a543b
...
...
@@ -24,7 +24,7 @@ class DndTestDnode : public ::testing::Test {
}
static
void
SetUpTestSuite
()
{
initLog
(
"/tmp/
dnode_test_dnode
"
);
initLog
(
"/tmp/
tdlog
"
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:9041"
;
...
...
@@ -188,7 +188,7 @@ SServer* DndTestDnode::pServer4;
SServer
*
DndTestDnode
::
pServer5
;
SClient
*
DndTestDnode
::
pClient
;
TEST_F
(
DndTestDnode
,
ShowDnode
)
{
TEST_F
(
DndTestDnode
,
01
_
ShowDnode
)
{
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
CheckSchema
(
0
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"id"
);
CheckSchema
(
1
,
TSDB_DATA_TYPE_BINARY
,
TSDB_EP_LEN
+
VARSTR_HEADER_SIZE
,
"end point"
);
...
...
@@ -208,7 +208,7 @@ TEST_F(DndTestDnode, ShowDnode) {
CheckBinary
(
""
,
24
);
}
TEST_F
(
DndTestDnode
,
ConfigDnode_01
)
{
TEST_F
(
DndTestDnode
,
02
_ConfigDnode
)
{
SCfgDnodeMsg
*
pReq
=
(
SCfgDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SCfgDnodeMsg
));
pReq
->
dnodeId
=
htonl
(
1
);
strcpy
(
pReq
->
config
,
"ddebugflag 131"
);
...
...
@@ -224,7 +224,7 @@ TEST_F(DndTestDnode, ConfigDnode_01) {
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
TEST_F
(
DndTestDnode
,
CreateDnode_01
)
{
TEST_F
(
DndTestDnode
,
03
_CreateDnode
)
{
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateDnodeMsg
));
strcpy
(
pReq
->
ep
,
"localhost:9042"
);
...
...
@@ -257,7 +257,7 @@ TEST_F(DndTestDnode, CreateDnode_01) {
CheckBinary
(
""
,
24
);
}
TEST_F
(
DndTestDnode
,
DropDnode_01
)
{
TEST_F
(
DndTestDnode
,
04
_DropDnode
)
{
SDropDnodeMsg
*
pReq
=
(
SDropDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SDropDnodeMsg
));
pReq
->
dnodeId
=
htonl
(
2
);
...
...
@@ -282,7 +282,7 @@ TEST_F(DndTestDnode, DropDnode_01) {
CheckBinary
(
""
,
24
);
}
TEST_F
(
DndTestDnode
,
CreateDnode_02
)
{
TEST_F
(
DndTestDnode
,
05
_CreateDnode
)
{
{
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateDnodeMsg
));
strcpy
(
pReq
->
ep
,
"localhost:9043"
);
...
...
@@ -361,7 +361,7 @@ TEST_F(DndTestDnode, CreateDnode_02) {
CheckBinary
(
""
,
24
);
}
TEST_F
(
DndTestDnode
,
RestartDnode_01
)
{
TEST_F
(
DndTestDnode
,
06
_RestartDnode
)
{
uInfo
(
"stop all server"
);
stopServer
(
pServer1
);
stopServer
(
pServer2
);
...
...
source/dnode/mgmt/impl/test/user/user.cpp
浏览文件 @
ac7a543b
...
...
@@ -170,7 +170,7 @@ SServer* DndTestUser::pServer;
SClient
*
DndTestUser
::
pClient
;
int32_t
DndTestUser
::
connId
;
TEST_F
(
DndTestUser
,
ShowUser
)
{
TEST_F
(
DndTestUser
,
01
_
ShowUser
)
{
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_USER
,
"show users"
,
4
);
CheckSchema
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"name"
);
CheckSchema
(
1
,
TSDB_DATA_TYPE_BINARY
,
10
+
VARSTR_HEADER_SIZE
,
"privilege"
);
...
...
@@ -184,7 +184,7 @@ TEST_F(DndTestUser, ShowUser) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
DndTestUser
,
CreateUser_01
)
{
TEST_F
(
DndTestUser
,
02
_CreateUser
)
{
{
SCreateUserMsg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
...
...
@@ -233,7 +233,7 @@ TEST_F(DndTestUser, CreateUser_01) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
DndTestUser
,
AlterUser_01
)
{
TEST_F
(
DndTestUser
,
03
_AlterUser
)
{
SAlterUserMsg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
sizeof
(
SAlterUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p2"
);
...
...
@@ -264,7 +264,7 @@ TEST_F(DndTestUser, AlterUser_01) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
DndTestUser
,
DropUser_01
)
{
TEST_F
(
DndTestUser
,
04
_DropUser
)
{
SDropUserMsg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
sizeof
(
SDropUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
...
...
@@ -290,7 +290,7 @@ TEST_F(DndTestUser, DropUser_01) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
DndTestUser
,
RestartDnode
)
{
TEST_F
(
DndTestUser
,
05
_
RestartDnode
)
{
stopServer
(
pServer
);
pServer
=
NULL
;
...
...
source/dnode/mnode/impl/src/mndDb.c
浏览文件 @
ac7a543b
...
...
@@ -646,7 +646,6 @@ static int32_t mndProcessDropDbMsg(SMnodeMsg *pMsg) {
mndReleaseDb
(
pMnode
,
pDb
);
if
(
code
!=
0
)
{
terrno
=
code
;
mError
(
"db:%s, failed to drop since %s"
,
pDrop
->
db
,
terrstr
());
return
code
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录