Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0e0af577
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看板
提交
0e0af577
编写于
12月 16, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
rename test codes
上级
190a7985
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
89 addition
and
82 deletion
+89
-82
source/dnode/mgmt/impl/test/acct/acct.cpp
source/dnode/mgmt/impl/test/acct/acct.cpp
+4
-4
source/dnode/mgmt/impl/test/db/db.cpp
source/dnode/mgmt/impl/test/db/db.cpp
+26
-15
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+26
-27
source/dnode/mgmt/impl/test/user/user.cpp
source/dnode/mgmt/impl/test/user/user.cpp
+27
-30
source/dnode/mnode/impl/src/mndVgroup.c
source/dnode/mnode/impl/src/mndVgroup.c
+6
-6
未找到文件。
source/dnode/mgmt/impl/test/acct/acct.cpp
浏览文件 @
0e0af577
...
...
@@ -49,7 +49,7 @@ SServer* DndTestAcct::pServer;
SClient
*
DndTestAcct
::
pClient
;
int32_t
DndTestAcct
::
connId
;
TEST_F
(
DndTestAcct
,
CreateAcct
)
{
TEST_F
(
DndTestAcct
,
01
_
CreateAcct
)
{
ASSERT_NE
(
pClient
,
nullptr
);
SCreateAcctMsg
*
pReq
=
(
SCreateAcctMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateAcctMsg
));
...
...
@@ -65,7 +65,7 @@ TEST_F(DndTestAcct, CreateAcct) {
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
TEST_F
(
DndTestAcct
,
AlterAcct
)
{
TEST_F
(
DndTestAcct
,
02
_
AlterAcct
)
{
ASSERT_NE
(
pClient
,
nullptr
);
SAlterAcctMsg
*
pReq
=
(
SAlterAcctMsg
*
)
rpcMallocCont
(
sizeof
(
SAlterAcctMsg
));
...
...
@@ -81,7 +81,7 @@ TEST_F(DndTestAcct, AlterAcct) {
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
TEST_F
(
DndTestAcct
,
DropAcct
)
{
TEST_F
(
DndTestAcct
,
03
_
DropAcct
)
{
ASSERT_NE
(
pClient
,
nullptr
);
SDropAcctMsg
*
pReq
=
(
SDropAcctMsg
*
)
rpcMallocCont
(
sizeof
(
SDropAcctMsg
));
...
...
@@ -97,7 +97,7 @@ TEST_F(DndTestAcct, DropAcct) {
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_MSG_NOT_PROCESSED
);
}
TEST_F
(
DndTestAcct
,
ShowAcct
)
{
TEST_F
(
DndTestAcct
,
04
_
ShowAcct
)
{
ASSERT_NE
(
pClient
,
nullptr
);
SShowMsg
*
pReq
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
...
...
source/dnode/mgmt/impl/test/db/db.cpp
浏览文件 @
0e0af577
...
...
@@ -48,11 +48,12 @@ class DndTestDb : public ::testing::Test {
void
SetUp
()
override
{}
void
TearDown
()
override
{}
void
SendTheCheckShowMetaMsg
(
int8_t
showType
,
const
char
*
showName
,
int32_t
columns
)
{
void
SendTheCheckShowMetaMsg
(
int8_t
showType
,
const
char
*
showName
,
int32_t
columns
,
const
char
*
db
)
{
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
pShow
->
type
=
showType
;
strcpy
(
pShow
->
db
,
""
);
if
(
db
!=
NULL
)
{
strcpy
(
pShow
->
db
,
db
);
}
SRpcMsg
showRpcMsg
=
{
0
};
showRpcMsg
.
pCont
=
pShow
;
showRpcMsg
.
contLen
=
sizeof
(
SShowMsg
);
...
...
@@ -183,7 +184,7 @@ SClient* DndTestDb::pClient;
int32_t
DndTestDb
::
connId
;
TEST_F
(
DndTestDb
,
01
_ShowDb
)
{
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
,
NULL
);
CheckSchema
(
0
,
TSDB_DATA_TYPE_BINARY
,
TSDB_DB_NAME_LEN
-
1
+
VARSTR_HEADER_SIZE
,
"name"
);
CheckSchema
(
1
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create time"
);
CheckSchema
(
2
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"replica"
);
...
...
@@ -204,7 +205,7 @@ TEST_F(DndTestDb, 01_ShowDb) {
SendThenCheckShowRetrieveMsg
(
0
);
}
TEST_F
(
DndTestDb
,
02
_CreateDb
)
{
TEST_F
(
DndTestDb
,
02
_Create
_Alter_Drop_
Db
)
{
{
taosMsleep
(
1100
);
...
...
@@ -241,7 +242,7 @@ TEST_F(DndTestDb, 02_CreateDb) {
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
,
NULL
);
SendThenCheckShowRetrieveMsg
(
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckTimestamp
();
...
...
@@ -259,9 +260,22 @@ TEST_F(DndTestDb, 02_CreateDb) {
CheckInt8
(
0
);
// cachelast
CheckBinary
(
"ms"
,
3
);
// precision
CheckInt8
(
0
);
// update
}
TEST_F
(
DndTestDb
,
03
_AlterDb
)
{
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_VGROUP
,
"show vgroups"
,
4
,
"1.d1"
);
CheckSchema
(
0
,
TSDB_DATA_TYPE_INT
,
4
,
"vgId"
);
CheckSchema
(
1
,
TSDB_DATA_TYPE_INT
,
4
,
"tables"
);
CheckSchema
(
2
,
TSDB_DATA_TYPE_SMALLINT
,
2
,
"v1_dnode"
);
CheckSchema
(
3
,
TSDB_DATA_TYPE_BINARY
,
9
+
VARSTR_HEADER_SIZE
,
"v1_status"
);
SendThenCheckShowRetrieveMsg
(
2
);
CheckInt32
(
1
);
CheckInt32
(
2
);
CheckInt32
(
0
);
CheckInt32
(
0
);
CheckInt16
(
1
);
CheckInt16
(
1
);
CheckBinary
(
"master"
,
9
);
CheckBinary
(
"master"
,
9
);
{
SAlterDbMsg
*
pReq
=
(
SAlterDbMsg
*
)
rpcMallocCont
(
sizeof
(
SAlterDbMsg
));
strcpy
(
pReq
->
db
,
"1.d1"
);
...
...
@@ -285,7 +299,7 @@ TEST_F(DndTestDb, 03_AlterDb) {
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
,
NULL
);
SendThenCheckShowRetrieveMsg
(
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckTimestamp
();
...
...
@@ -303,9 +317,8 @@ TEST_F(DndTestDb, 03_AlterDb) {
CheckInt8
(
1
);
// cachelast
CheckBinary
(
"ms"
,
3
);
// precision
CheckInt8
(
0
);
// update
}
TEST_F
(
DndTestDb
,
04
_RestartDnode
)
{
// restart
stopServer
(
pServer
);
pServer
=
NULL
;
...
...
@@ -317,7 +330,7 @@ TEST_F(DndTestDb, 04_RestartDnode) {
uInfo
(
"all server is running"
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
,
NULL
);
SendThenCheckShowRetrieveMsg
(
1
);
CheckBinary
(
"d1"
,
TSDB_DB_NAME_LEN
-
1
);
CheckTimestamp
();
...
...
@@ -335,9 +348,7 @@ TEST_F(DndTestDb, 04_RestartDnode) {
CheckInt8
(
1
);
// cachelast
CheckBinary
(
"ms"
,
3
);
// precision
CheckInt8
(
0
);
// update
}
TEST_F
(
DndTestDb
,
05
_DropDb
)
{
{
SDropDbMsg
*
pReq
=
(
SDropDbMsg
*
)
rpcMallocCont
(
sizeof
(
SAlterDbMsg
));
strcpy
(
pReq
->
db
,
"1.d1"
);
...
...
@@ -353,6 +364,6 @@ TEST_F(DndTestDb, 05_DropDb) {
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DB
,
"show databases"
,
16
,
NULL
);
SendThenCheckShowRetrieveMsg
(
0
);
}
\ No newline at end of file
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
0e0af577
...
...
@@ -224,19 +224,21 @@ TEST_F(DndTestDnode, 02_ConfigDnode) {
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
TEST_F
(
DndTestDnode
,
03
_CreateDnode
)
{
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateDnodeMsg
));
strcpy
(
pReq
->
ep
,
"localhost:9042"
);
TEST_F
(
DndTestDnode
,
03
_Create_Drop_Reatrt_Dnode
)
{
{
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateDnodeMsg
));
strcpy
(
pReq
->
ep
,
"localhost:9042"
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SCreateDnodeMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CREATE_DNODE
;
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SCreateDnodeMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CREATE_DNODE
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
taosMsleep
(
1300
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
...
...
@@ -255,21 +257,21 @@ TEST_F(DndTestDnode, 03_CreateDnode) {
CheckTimestamp
();
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
}
TEST_F
(
DndTestDnode
,
04
_DropDnode
)
{
SDropDnodeMsg
*
pReq
=
(
SDropDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SDropDnodeMsg
));
pReq
->
dnodeId
=
htonl
(
2
);
{
SDropDnodeMsg
*
pReq
=
(
SDropDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SDropDnodeMsg
));
pReq
->
dnodeId
=
htonl
(
2
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SDropDnodeMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_DROP_DNODE
;
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SDropDnodeMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_DROP_DNODE
;
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
sendMsg
(
pClient
,
&
rpcMsg
);
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
SendThenCheckShowRetrieveMsg
(
1
);
...
...
@@ -280,9 +282,7 @@ TEST_F(DndTestDnode, 04_DropDnode) {
CheckBinary
(
"ready"
,
10
);
CheckTimestamp
();
CheckBinary
(
""
,
24
);
}
TEST_F
(
DndTestDnode
,
05
_CreateDnode
)
{
{
SCreateDnodeMsg
*
pReq
=
(
SCreateDnodeMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateDnodeMsg
));
strcpy
(
pReq
->
ep
,
"localhost:9043"
);
...
...
@@ -359,9 +359,8 @@ TEST_F(DndTestDnode, 05_CreateDnode) {
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
CheckBinary
(
""
,
24
);
}
TEST_F
(
DndTestDnode
,
06
_RestartDnode
)
{
// restart
uInfo
(
"stop all server"
);
stopServer
(
pServer1
);
stopServer
(
pServer2
);
...
...
source/dnode/mgmt/impl/test/user/user.cpp
浏览文件 @
0e0af577
...
...
@@ -184,7 +184,7 @@ TEST_F(DndTestUser, 01_ShowUser) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
DndTestUser
,
02
_CreateUser
)
{
TEST_F
(
DndTestUser
,
02
_Create
_Drop_Alter_
User
)
{
{
SCreateUserMsg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
...
...
@@ -231,23 +231,22 @@ TEST_F(DndTestUser, 02_CreateUser) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
DndTestUser
,
03
_AlterUser
)
{
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
;
{
SAlterUserMsg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
sizeof
(
SAlterUserMsg
))
;
strcpy
(
pReq
->
user
,
"u1"
);
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
(
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
);
...
...
@@ -262,22 +261,21 @@ TEST_F(DndTestUser, 03_AlterUser) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
DndTestUser
,
04
_DropUser
)
{
SDropUserMsg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
sizeof
(
SDropUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pReq
;
rpcMsg
.
contLen
=
sizeof
(
SDropUserMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_DROP_USER
;
{
SDropUserMsg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
sizeof
(
SDropUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
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
(
SDropUserMsg
);
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_DROP_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
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
...
...
@@ -288,9 +286,8 @@ TEST_F(DndTestUser, 04_DropUser) {
CheckTimestamp
();
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
DndTestUser
,
05
_RestartDnode
)
{
// restart
stopServer
(
pServer
);
pServer
=
NULL
;
...
...
source/dnode/mnode/impl/src/mndVgroup.c
浏览文件 @
0e0af577
...
...
@@ -173,7 +173,11 @@ static int32_t mndGetAvailableDnode(SMnode *pMnode, SVgObj *pVgroup) {
if
(
mndIsDnodeInReadyStatus
(
pMnode
,
pDnode
))
{
SVnodeGid
*
pVgid
=
&
pVgroup
->
vnodeGid
[
allocedVnodes
];
pVgid
->
dnodeId
=
pDnode
->
id
;
pVgid
->
role
=
TAOS_SYNC_STATE_FOLLOWER
;
if
(
pVgroup
->
replica
==
1
)
{
pVgid
->
role
=
TAOS_SYNC_STATE_LEADER
;
}
else
{
pVgid
->
role
=
TAOS_SYNC_STATE_FOLLOWER
;
}
allocedVnodes
++
;
}
sdbRelease
(
pSdb
,
pDnode
);
...
...
@@ -303,7 +307,7 @@ static int32_t mndGetVgroupMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg
cols
++
;
for
(
int32_t
i
=
0
;
i
<
pShow
->
replica
;
++
i
)
{
pShow
->
bytes
[
cols
]
=
4
;
pShow
->
bytes
[
cols
]
=
2
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_SMALLINT
;
snprintf
(
pSchema
[
cols
].
name
,
TSDB_COL_NAME_LEN
,
"v%d_dnode"
,
i
+
1
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
...
...
@@ -363,10 +367,6 @@ static int32_t mndRetrieveVgroups(SMnodeMsg *pMsg, SShowObj *pShow, char *data,
cols
++
;
}
pWrite
=
data
+
pShow
->
offset
[
cols
]
*
rows
+
pShow
->
bytes
[
cols
]
*
numOfRows
;
*
(
int8_t
*
)
pWrite
=
pVgroup
->
compact
;
cols
++
;
sdbRelease
(
pSdb
,
pVgroup
);
numOfRows
++
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录