Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
97df31eb
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看板
提交
97df31eb
编写于
12月 31, 2021
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
unitest for create user
上级
65acb7df
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
172 addition
and
34 deletion
+172
-34
include/common/tmsg.h
include/common/tmsg.h
+23
-32
source/dnode/mgmt/impl/src/dndTransport.c
source/dnode/mgmt/impl/src/dndTransport.c
+1
-1
source/dnode/mgmt/impl/test/user/user.cpp
source/dnode/mgmt/impl/test/user/user.cpp
+148
-1
未找到文件。
include/common/tmsg.h
浏览文件 @
97df31eb
...
...
@@ -354,9 +354,9 @@ typedef struct SEpSet {
}
SEpSet
;
static
FORCE_INLINE
int
taosEncodeSEpSet
(
void
**
buf
,
const
SEpSet
*
pEp
)
{
if
(
buf
==
NULL
)
return
sizeof
(
SEpSet
);
if
(
buf
==
NULL
)
return
sizeof
(
SEpSet
);
memcpy
(
buf
,
pEp
,
sizeof
(
SEpSet
));
//TODO: endian conversion
//
TODO: endian conversion
return
sizeof
(
SEpSet
);
}
...
...
@@ -370,7 +370,7 @@ typedef struct {
int64_t
clusterId
;
int32_t
connId
;
int8_t
superUser
;
int8_t
reserved
[
5
];
int8_t
align
[
3
];
SEpSet
epSet
;
}
SConnectRsp
;
...
...
@@ -383,20 +383,17 @@ typedef struct {
int32_t
maxStreams
;
int32_t
accessState
;
// Configured only by command
int64_t
maxStorage
;
// In unit of GB
int32_t
reserve
[
8
];
}
SCreateAcctMsg
,
SAlterAcctMsg
;
typedef
struct
{
char
user
[
TSDB_USER_LEN
];
int32_t
reserve
[
8
];
char
user
[
TSDB_USER_LEN
];
}
SDropUserMsg
,
SDropAcctMsg
;
typedef
struct
{
int8_t
type
;
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_PASSWORD_LEN
];
int8_t
superUser
;
// denote if it is a super user or not
int32_t
reserve
[
8
];
int8_t
type
;
char
user
[
TSDB_USER_LEN
];
char
pass
[
TSDB_PASSWORD_LEN
];
int8_t
superUser
;
// denote if it is a super user or not
}
SCreateUserMsg
,
SAlterUserMsg
;
typedef
struct
{
...
...
@@ -585,7 +582,6 @@ typedef struct {
int8_t
update
;
int8_t
cacheLastRow
;
int8_t
ignoreExist
;
int32_t
reserve
[
8
];
}
SCreateDbMsg
;
typedef
struct
{
...
...
@@ -598,29 +594,24 @@ typedef struct {
int8_t
walLevel
;
int8_t
quorum
;
int8_t
cacheLastRow
;
int32_t
reserve
[
8
];
}
SAlterDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
int8_t
ignoreNotExists
;
int32_t
reserve
[
8
];
char
db
[
TSDB_TABLE_FNAME_LEN
];
int8_t
ignoreNotExists
;
}
SDropDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
int32_t
vgVersion
;
int32_t
reserve
[
8
];
}
SUseDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
int32_t
reserve
[
8
];
char
db
[
TSDB_TABLE_FNAME_LEN
];
}
SSyncDbMsg
;
typedef
struct
{
char
db
[
TSDB_TABLE_FNAME_LEN
];
int32_t
reserve
[
8
];
char
db
[
TSDB_TABLE_FNAME_LEN
];
}
SCompactDbMsg
;
typedef
struct
{
...
...
@@ -676,7 +667,7 @@ typedef struct {
typedef
struct
{
int32_t
vgId
;
int8_t
role
;
int8_t
reserved
[
3
];
int8_t
align
[
3
];
int64_t
totalStorage
;
int64_t
compStorage
;
int64_t
pointsWritten
;
...
...
@@ -713,7 +704,7 @@ typedef struct {
typedef
struct
{
int32_t
id
;
int8_t
isMnode
;
int8_t
reserved
;
int8_t
align
;
uint16_t
port
;
char
fqdn
[
TSDB_FQDN_LEN
];
}
SDnodeEp
;
...
...
@@ -947,7 +938,7 @@ typedef struct {
int32_t
totalDnodes
;
int32_t
onlineDnodes
;
int8_t
killConnection
;
int8_t
reserved
[
3
];
int8_t
align
[
3
];
SEpSet
epSet
;
}
SHeartBeatRsp
;
...
...
@@ -975,7 +966,7 @@ typedef struct {
typedef
struct
{
int8_t
finished
;
int8_t
reserved1
[
7
];
int8_t
align
[
7
];
char
name
[
TSDB_STEP_NAME_LEN
];
char
desc
[
TSDB_STEP_DESC_LEN
];
}
SStartupMsg
;
...
...
@@ -1118,10 +1109,10 @@ typedef struct STaskDropRsp {
}
STaskDropRsp
;
typedef
struct
{
int8_t
igExists
;
char
*
name
;
char
*
physicalPlan
;
char
*
logicalPlan
;
int8_t
igExists
;
char
*
name
;
char
*
physicalPlan
;
char
*
logicalPlan
;
}
SCMCreateTopicReq
;
static
FORCE_INLINE
int
tSerializeSCMCreateTopicReq
(
void
**
buf
,
const
SCMCreateTopicReq
*
pReq
)
{
...
...
@@ -1157,8 +1148,8 @@ static FORCE_INLINE void* tDeserializeSCMCreateTopicRsp(void* buf, SCMCreateTopi
}
typedef
struct
{
char
*
topicName
;
char
*
consumerGroup
;
char
*
topicName
;
char
*
consumerGroup
;
int64_t
consumerId
;
}
SCMSubscribeReq
;
...
...
@@ -1179,7 +1170,7 @@ static FORCE_INLINE void* tDeserializeSCMSubscribeReq(void* buf, SCMSubscribeReq
typedef
struct
{
int32_t
vgId
;
SEpSet
pEpSet
;
SEpSet
pEpSet
;
}
SCMSubscribeRsp
;
static
FORCE_INLINE
int
tSerializeSCMSubscribeRsp
(
void
**
buf
,
const
SCMSubscribeRsp
*
pRsp
)
{
...
...
source/dnode/mgmt/impl/src/dndTransport.c
浏览文件 @
97df31eb
...
...
@@ -160,8 +160,8 @@ static void dndProcessResponse(void *parent, SRpcMsg *pMsg, SEpSet *pEpSet) {
DndMsgFp
fp
=
pMgmt
->
msgFp
[
TMSG_INDEX
(
msgType
)];
if
(
fp
!=
NULL
)
{
dTrace
(
"RPC %p, rsp:%s will be processed, code:0x%x"
,
pMsg
->
handle
,
TMSG_INFO
(
msgType
),
pMsg
->
code
&
0XFFFF
);
(
*
fp
)(
pDnode
,
pMsg
,
pEpSet
);
dTrace
(
"RPC %p, rsp:%s is processed, code:0x%x"
,
pMsg
->
handle
,
TMSG_INFO
(
msgType
),
pMsg
->
code
&
0XFFFF
);
}
else
{
dError
(
"RPC %p, rsp:%s not processed"
,
pMsg
->
handle
,
TMSG_INFO
(
msgType
));
rpcFreeCont
(
pMsg
->
pCont
);
...
...
source/dnode/mgmt/impl/test/user/user.cpp
浏览文件 @
97df31eb
...
...
@@ -43,6 +43,153 @@ TEST_F(DndTestUser, 01_ShowUser) {
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
TEST_F
(
DndTestUser
,
02
_Create_User
)
{
{
int32_t
contLen
=
sizeof
(
SCreateUserMsg
);
SCreateUserMsg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
{
int32_t
contLen
=
sizeof
(
SCreateUserMsg
);
SCreateUserMsg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
""
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
}
{
int32_t
contLen
=
sizeof
(
SCreateUserMsg
);
SCreateUserMsg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"root"
);
strcpy
(
pReq
->
pass
,
"1"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_USER_ALREADY_EXIST
);
}
{
int32_t
contLen
=
sizeof
(
SCreateUserMsg
);
SCreateUserMsg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
TEST_F
(
DndTestUser
,
03
_Alter_User
)
{
{
int32_t
contLen
=
sizeof
(
SAlterUserMsg
);
SAlterUserMsg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
""
);
strcpy
(
pReq
->
pass
,
"p1"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
{
int32_t
contLen
=
sizeof
(
SAlterUserMsg
);
SAlterUserMsg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
""
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
}
{
int32_t
contLen
=
sizeof
(
SAlterUserMsg
);
SAlterUserMsg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u4"
);
strcpy
(
pReq
->
pass
,
"1"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
}
{
int32_t
contLen
=
sizeof
(
SAlterUserMsg
);
SAlterUserMsg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"1"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
}
TEST_F
(
DndTestUser
,
04
_Drop_User
)
{
{
int32_t
contLen
=
sizeof
(
SDropUserMsg
);
SDropUserMsg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
""
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
{
int32_t
contLen
=
sizeof
(
SDropUserMsg
);
SDropUserMsg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u4"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
}
{
int32_t
contLen
=
sizeof
(
SDropUserMsg
);
SDropUserMsg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
contLen
);
strcpy
(
pReq
->
user
,
"u1"
);
SRpcMsg
*
pMsg
=
test
.
SendMsg
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
TEST_F
(
DndTestUser
,
02
_Create_Drop_Alter_User
)
{
{
int32_t
contLen
=
sizeof
(
SCreateUserMsg
);
...
...
@@ -161,4 +308,4 @@ TEST_F(DndTestUser, 02_Create_Drop_Alter_User) {
CheckTimestamp
();
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录