Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
0d596ea3
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看板
未验证
提交
0d596ea3
编写于
12月 13, 2021
作者:
S
Shengliang Guan
提交者:
GitHub
12月 13, 2021
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #9070 from taosdata/feature/dnode3
Feature/dnode3
上级
793eb114
43f600e0
变更
4
显示空白变更内容
内联
并排
Showing
4 changed file
with
239 addition
and
332 deletion
+239
-332
source/dnode/mgmt/impl/test/dnode/dnode.cpp
source/dnode/mgmt/impl/test/dnode/dnode.cpp
+6
-5
source/dnode/mgmt/impl/test/user/user.cpp
source/dnode/mgmt/impl/test/user/user.cpp
+227
-320
source/dnode/mnode/impl/src/mndUser.c
source/dnode/mnode/impl/src/mndUser.c
+4
-5
source/dnode/mnode/sdb/src/sdb.c
source/dnode/mnode/sdb/src/sdb.c
+2
-2
未找到文件。
source/dnode/mgmt/impl/test/dnode/dnode.cpp
浏览文件 @
0d596ea3
...
@@ -271,7 +271,6 @@ TEST_F(DndTestDnode, DropDnode_01) {
...
@@ -271,7 +271,6 @@ TEST_F(DndTestDnode, DropDnode_01) {
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
taosMsleep
(
1300
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_DNODE
,
"show dnodes"
,
7
);
SendThenCheckShowRetrieveMsg
(
1
);
SendThenCheckShowRetrieveMsg
(
1
);
CheckInt16
(
1
);
CheckInt16
(
1
);
...
@@ -363,7 +362,7 @@ TEST_F(DndTestDnode, CreateDnode_02) {
...
@@ -363,7 +362,7 @@ TEST_F(DndTestDnode, CreateDnode_02) {
}
}
TEST_F
(
DndTestDnode
,
RestartDnode_01
)
{
TEST_F
(
DndTestDnode
,
RestartDnode_01
)
{
uInfo
(
"
===>
stop all server"
);
uInfo
(
"stop all server"
);
stopServer
(
pServer1
);
stopServer
(
pServer1
);
stopServer
(
pServer2
);
stopServer
(
pServer2
);
stopServer
(
pServer3
);
stopServer
(
pServer3
);
...
@@ -375,14 +374,16 @@ TEST_F(DndTestDnode, RestartDnode_01) {
...
@@ -375,14 +374,16 @@ TEST_F(DndTestDnode, RestartDnode_01) {
pServer4
=
NULL
;
pServer4
=
NULL
;
pServer5
=
NULL
;
pServer5
=
NULL
;
taosMsleep
(
3000
);
// wait tcp port cleanedup
uInfo
(
"start all server"
);
uInfo
(
"===> start all server"
);
const
char
*
fqdn
=
"localhost"
;
const
char
*
fqdn
=
"localhost"
;
const
char
*
firstEp
=
"localhost:9521"
;
const
char
*
firstEp
=
"localhost:9521"
;
pServer1
=
startServer
(
"/tmp/dndTestDnode1"
,
fqdn
,
9521
,
firstEp
);
pServer1
=
startServer
(
"/tmp/dndTestDnode1"
,
fqdn
,
9521
,
firstEp
);
// pServer1 = startServer("/tmp/dndTestDnode3", fqdn, 9523, firstEp);
// pServer1 = startServer("/tmp/dndTestDnode4", fqdn, 9524, firstEp);
// pServer1 = startServer("/tmp/dndTestDnode5", fqdn, 9525, firstEp);
uInfo
(
"
===>
all server is running"
);
uInfo
(
"all server is running"
);
// taosMsleep(1300);
// taosMsleep(1300);
// SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "show dnodes", 7);
// SendTheCheckShowMetaMsg(TSDB_MGMT_TABLE_DNODE, "show dnodes", 7);
...
...
source/dnode/mgmt/impl/test/user/user.cpp
浏览文件 @
0d596ea3
...
@@ -17,43 +17,40 @@
...
@@ -17,43 +17,40 @@
class
DndTestUser
:
public
::
testing
::
Test
{
class
DndTestUser
:
public
::
testing
::
Test
{
protected:
protected:
void
SetUp
()
override
{}
static
SServer
*
CreateServer
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
)
{
void
TearDown
()
override
{}
SServer
*
pServer
=
createServer
(
path
,
fqdn
,
port
,
firstEp
);
ASSERT
(
pServer
);
return
pServer
;
}
static
void
SetUpTestSuite
()
{
static
void
SetUpTestSuite
()
{
const
char
*
user
=
"root"
;
initLog
(
"/tmp/dndTestUser"
);
const
char
*
pass
=
"taosdata"
;
const
char
*
path
=
"/tmp/dndTestUser"
;
const
char
*
fqdn
=
"localhost"
;
uint16_t
port
=
9524
;
const
char
*
firstEp
=
"localhost:9524"
;
pServer
=
createServer
(
path
,
fqdn
,
port
,
firstEp
);
const
char
*
fqdn
=
"localhost"
;
ASSERT
(
pServer
);
const
char
*
firstEp
=
"localhost:9530"
;
pClient
=
createClient
(
user
,
pass
,
fqdn
,
port
);
pServer
=
CreateServer
(
"/tmp/dndTestUser"
,
fqdn
,
9530
,
firstEp
);
pClient
=
createClient
(
"root"
,
"taosdata"
,
fqdn
,
9530
);
taosMsleep
(
300
);
}
}
static
void
TearDownTestSuite
()
{
static
void
TearDownTestSuite
()
{
stopServer
(
pServer
);
stopServer
(
pServer
);
dropClient
(
pClient
);
dropClient
(
pClient
);
pServer
=
NULL
;
pClient
=
NULL
;
}
}
static
SServer
*
pServer
;
static
SServer
*
pServer
;
static
SClient
*
pClient
;
static
SClient
*
pClient
;
static
int32_t
connId
;
static
int32_t
connId
;
};
SServer
*
DndTestUser
::
pServer
;
SClient
*
DndTestUser
::
pClient
;
int32_t
DndTestUser
::
connId
;
#if 0
public:
TEST_F(DndTestUser, ShowUser) {
void
SetUp
()
override
{}
int32_t showId = 0;
void
TearDown
()
override
{}
//--- meta ---
void
SendTheCheckShowMetaMsg
(
int8_t
showType
,
const
char
*
showName
,
int32_t
columns
)
{
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
pShow->type = TSDB_MGMT_TABLE_USER
;
pShow
->
type
=
showType
;
strcpy
(
pShow
->
db
,
""
);
strcpy
(
pShow
->
db
,
""
);
SRpcMsg
showRpcMsg
=
{
0
};
SRpcMsg
showRpcMsg
=
{
0
};
...
@@ -63,66 +60,45 @@ TEST_F(DndTestUser, ShowUser) {
...
@@ -63,66 +60,45 @@ TEST_F(DndTestUser, ShowUser) {
sendMsg
(
pClient
,
&
showRpcMsg
);
sendMsg
(
pClient
,
&
showRpcMsg
);
ASSERT_NE
(
pClient
->
pRsp
,
nullptr
);
ASSERT_NE
(
pClient
->
pRsp
,
nullptr
);
ASSERT_EQ
(
pClient
->
pRsp
->
code
,
0
);
ASSERT_NE
(
pClient
->
pRsp
->
pCont
,
nullptr
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pClient
->
pRsp
->
pCont
;
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pClient
->
pRsp
->
pCont
;
ASSERT_NE
(
pShowRsp
,
nullptr
);
ASSERT_NE
(
pShowRsp
,
nullptr
);
pShowRsp
->
showId
=
htonl
(
pShowRsp
->
showId
);
pShowRsp
->
showId
=
htonl
(
pShowRsp
->
showId
);
STableMetaMsg*
pMeta = &pShowRsp->tableMeta;
pMeta
=
&
pShowRsp
->
tableMeta
;
pMeta->contLen = htonl(pMeta->contLen
);
pMeta
->
numOfTags
=
htons
(
pMeta
->
numOfTags
);
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
pMeta
->
sversion
=
htons
(
pMeta
->
sversion
);
pMeta
->
sversion
=
htons
(
pMeta
->
sversion
);
pMeta
->
tversion
=
htons
(
pMeta
->
tversion
);
pMeta
->
tversion
=
htons
(
pMeta
->
tversion
);
pMeta->tid = htonl(pMeta->tid);
pMeta
->
tuid
=
htobe64
(
pMeta
->
tuid
);
pMeta->uid = htobe64(pMeta->uid);
pMeta
->
suid
=
htobe64
(
pMeta
->
suid
);
pMeta
->
suid
=
htobe64
(
pMeta
->
suid
);
showId
=
pShowRsp
->
showId
;
showId
=
pShowRsp
->
showId
;
EXPECT_NE
(
pShowRsp
->
showId
,
0
);
EXPECT_NE
(
pShowRsp
->
showId
,
0
);
EXPECT_EQ(pMeta->contLen, 0);
EXPECT_STREQ
(
pMeta
->
tbFname
,
showName
);
EXPECT_STREQ(pMeta->tbFname, "show users");
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
numOfTags
,
0
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
columns
);
EXPECT_EQ
(
pMeta
->
precision
,
0
);
EXPECT_EQ
(
pMeta
->
precision
,
0
);
EXPECT_EQ
(
pMeta
->
tableType
,
0
);
EXPECT_EQ
(
pMeta
->
tableType
,
0
);
EXPECT_EQ(pMeta->numOfColumns, 4
);
EXPECT_EQ
(
pMeta
->
update
,
0
);
EXPECT_EQ
(
pMeta
->
sversion
,
0
);
EXPECT_EQ
(
pMeta
->
sversion
,
0
);
EXPECT_EQ
(
pMeta
->
tversion
,
0
);
EXPECT_EQ
(
pMeta
->
tversion
,
0
);
EXPECT_EQ(pMeta->tid, 0);
EXPECT_EQ
(
pMeta
->
tuid
,
0
);
EXPECT_EQ(pMeta->uid, 0);
EXPECT_STREQ(pMeta->sTableName, "");
EXPECT_EQ
(
pMeta
->
suid
,
0
);
EXPECT_EQ
(
pMeta
->
suid
,
0
);
}
SSchema* pSchema = NULL;
void
CheckSchema
(
int32_t
index
,
int8_t
type
,
int32_t
bytes
,
const
char
*
name
)
{
SSchema
*
pSchema
=
&
pMeta
->
pSchema
[
index
];
pSchema = &pMeta->pSchema[0];
pSchema->bytes = htons(pSchema->bytes);
EXPECT_EQ(pSchema->colId, 0);
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
EXPECT_EQ(pSchema->bytes, TSDB_USER_LEN + VARSTR_HEADER_SIZE);
EXPECT_STREQ(pSchema->name, "name");
pSchema = &pMeta->pSchema[1];
pSchema->bytes = htons(pSchema->bytes);
EXPECT_EQ(pSchema->colId, 0);
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
EXPECT_EQ(pSchema->bytes, 10 + VARSTR_HEADER_SIZE);
EXPECT_STREQ(pSchema->name, "privilege");
pSchema = &pMeta->pSchema[2];
pSchema->bytes = htons(pSchema->bytes);
EXPECT_EQ(pSchema->colId, 0);
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_TIMESTAMP);
EXPECT_EQ(pSchema->bytes, 8);
EXPECT_STREQ(pSchema->name, "create_time");
pSchema = &pMeta->pSchema[3];
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
pSchema
->
bytes
=
htons
(
pSchema
->
bytes
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ
(
pSchema
->
colId
,
0
);
EXPECT_EQ(pSchema->type, TSDB_DATA_TYPE_BINARY);
EXPECT_EQ
(
pSchema
->
type
,
type
);
EXPECT_EQ(pSchema->bytes, TSDB_USER_LEN + VARSTR_HEADER_SIZE);
EXPECT_EQ
(
pSchema
->
bytes
,
bytes
);
EXPECT_STREQ(pSchema->name, "account");
EXPECT_STREQ
(
pSchema
->
name
,
name
);
}
//--- retrieve ---
void
SendThenCheckShowRetrieveMsg
(
int32_t
rows
)
{
SRetrieveTableMsg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
SRetrieveTableMsg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
pRetrieve
->
showId
=
htonl
(
showId
);
pRetrieve
->
showId
=
htonl
(
showId
);
pRetrieve
->
free
=
0
;
pRetrieve
->
free
=
0
;
...
@@ -133,86 +109,83 @@ TEST_F(DndTestUser, ShowUser) {
...
@@ -133,86 +109,83 @@ TEST_F(DndTestUser, ShowUser) {
retrieveRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW_RETRIEVE
;
retrieveRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW_RETRIEVE
;
sendMsg
(
pClient
,
&
retrieveRpcMsg
);
sendMsg
(
pClient
,
&
retrieveRpcMsg
);
ASSERT_NE
(
pClient
->
pRsp
,
nullptr
);
ASSERT_NE
(
pClient
->
pRsp
,
nullptr
);
ASSERT_EQ
(
pClient
->
pRsp
->
code
,
0
);
ASSERT_EQ
(
pClient
->
pRsp
->
code
,
0
);
ASSERT_NE
(
pClient
->
pRsp
->
pCont
,
nullptr
);
SRetrieveTableRsp*
pRetrieveRsp = (SRetrieveTableRsp*)pClient->pRsp->pCont;
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
pClient
->
pRsp
->
pCont
;
ASSERT_NE
(
pRetrieveRsp
,
nullptr
);
ASSERT_NE
(
pRetrieveRsp
,
nullptr
);
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
pRetrieveRsp
->
offset
=
htobe64
(
pRetrieveRsp
->
offset
);
pRetrieveRsp
->
offset
=
htobe64
(
pRetrieveRsp
->
offset
);
pRetrieveRsp
->
useconds
=
htobe64
(
pRetrieveRsp
->
useconds
);
pRetrieveRsp
->
useconds
=
htobe64
(
pRetrieveRsp
->
useconds
);
pRetrieveRsp
->
compLen
=
htonl
(
pRetrieveRsp
->
compLen
);
pRetrieveRsp
->
compLen
=
htonl
(
pRetrieveRsp
->
compLen
);
EXPECT_EQ(pRetrieveRsp->numOfRows, 2
);
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
rows
);
EXPECT_EQ
(
pRetrieveRsp
->
offset
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
offset
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
useconds
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
useconds
,
0
);
EXPECT_EQ(pRetrieveRsp->completed, 1
);
// EXPECT_EQ(pRetrieveRsp->completed, completed
);
EXPECT_EQ
(
pRetrieveRsp
->
precision
,
TSDB_TIME_PRECISION_MILLI
);
EXPECT_EQ
(
pRetrieveRsp
->
precision
,
TSDB_TIME_PRECISION_MILLI
);
EXPECT_EQ
(
pRetrieveRsp
->
compressed
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
compressed
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
reserved
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
reserved
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
compLen
,
0
);
EXPECT_EQ
(
pRetrieveRsp
->
compLen
,
0
);
char* pData = pRetrieveRsp->data;
pData
=
pRetrieveRsp
->
data
;
int32_t pos = 0;
pos
=
0
;
char* strVal = NULL;
int64_t int64Val = 0;
//--- name ---
{
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "root");
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "_root");
}
}
//--- privilege ---
void
CheckInt16
(
int16_t
val
)
{
{
int16_t
data
=
*
((
int16_t
*
)(
pData
+
pos
));
pos += sizeof(VarDataLenT);
pos
+=
sizeof
(
int16_t
);
strVal = (char*)(pData + pos);
EXPECT_EQ
(
data
,
val
);
pos += 10;
EXPECT_STREQ(strVal, "super");
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += 10;
EXPECT_STREQ(strVal, "writable");
}
}
//--- create_time ---
void
CheckInt64
(
int64_t
val
)
{
{
int64_t
data
=
*
((
int64_t
*
)(
pData
+
pos
));
int64Val = *((int64_t*)(pData + pos));
pos
+=
sizeof
(
int64_t
);
pos
+=
sizeof
(
int64_t
);
EXPECT_GT(int64Val, 0);
EXPECT_EQ
(
data
,
val
);
}
int64Val = *((int64_t*)(pData + pos));
void
CheckTimestamp
()
{
int64_t
data
=
*
((
int64_t
*
)(
pData
+
pos
));
pos
+=
sizeof
(
int64_t
);
pos
+=
sizeof
(
int64_t
);
EXPECT_GT(
int64Val
, 0);
EXPECT_GT
(
data
,
0
);
}
}
//--- account ---
void
CheckBinary
(
const
char
*
val
,
int32_t
len
)
{
{
pos
+=
sizeof
(
VarDataLenT
);
pos
+=
sizeof
(
VarDataLenT
);
strVal = (char*)(pData + pos);
char
*
data
=
(
char
*
)(
pData
+
pos
);
pos += TSDB_USER_LEN;
pos
+=
len
;
EXPECT_STREQ(strVal, "root");
EXPECT_STREQ
(
data
,
val
);
pos += sizeof(VarDataLenT);
strVal = (char*)(pData + pos);
pos += TSDB_USER_LEN;
EXPECT_STREQ(strVal, "root");
}
}
int32_t
showId
;
STableMetaMsg
*
pMeta
;
SRetrieveTableRsp
*
pRetrieveRsp
;
char
*
pData
;
int32_t
pos
;
};
SServer
*
DndTestUser
::
pServer
;
SClient
*
DndTestUser
::
pClient
;
int32_t
DndTestUser
::
connId
;
TEST_F
(
DndTestUser
,
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"
);
CheckSchema
(
2
,
TSDB_DATA_TYPE_TIMESTAMP
,
8
,
"create time"
);
CheckSchema
(
3
,
TSDB_DATA_TYPE_BINARY
,
TSDB_USER_LEN
+
VARSTR_HEADER_SIZE
,
"account"
);
SendThenCheckShowRetrieveMsg
(
1
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"super"
,
10
);
CheckTimestamp
();
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
}
}
#endif
TEST_F
(
DndTestUser
,
CreateUser_01
)
{
TEST_F
(
DndTestUser
,
CreateUser_01
)
{
ASSERT_NE
(
pClient
,
nullptr
);
{
//--- create user ---
SCreateUserMsg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateUserMsg
));
SCreateUserMsg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
strcpy
(
pReq
->
pass
,
"p1"
);
...
@@ -226,61 +199,41 @@ TEST_F(DndTestUser, CreateUser_01) {
...
@@ -226,61 +199,41 @@ TEST_F(DndTestUser, CreateUser_01) {
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
}
//--- meta ---
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
pShow
->
type
=
TSDB_MGMT_TABLE_USER
;
SRpcMsg
showRpcMsg
=
{
0
};
showRpcMsg
.
pCont
=
pShow
;
showRpcMsg
.
contLen
=
sizeof
(
SShowMsg
);
showRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW
;
sendMsg
(
pClient
,
&
showRpcMsg
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pClient
->
pRsp
->
pCont
;
STableMetaMsg
*
pMeta
=
&
pShowRsp
->
tableMeta
;
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
4
);
//--- retrieve ---
SRetrieveTableMsg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
pRetrieve
->
showId
=
pShowRsp
->
showId
;
SRpcMsg
retrieveRpcMsg
=
{
0
};
retrieveRpcMsg
.
pCont
=
pRetrieve
;
retrieveRpcMsg
.
contLen
=
sizeof
(
SRetrieveTableMsg
);
retrieveRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW_RETRIEVE
;
sendMsg
(
pClient
,
&
retrieveRpcMsg
);
SRetrieveTableRsp
*
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
pClient
->
pRsp
->
pCont
;
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
3
);
char
*
pData
=
pRetrieveRsp
->
data
;
int32_t
pos
=
0
;
char
*
strVal
=
NULL
;
//--- name ---
{
{
pos
+=
sizeof
(
VarDataLenT
);
SCreateUserMsg
*
pReq
=
(
SCreateUserMsg
*
)
rpcMallocCont
(
sizeof
(
SCreateUserMsg
));
strVal
=
(
char
*
)(
pData
+
pos
);
strcpy
(
pReq
->
user
,
"u2"
);
pos
+=
TSDB_USER_LEN
;
strcpy
(
pReq
->
pass
,
"p2"
);
EXPECT_STREQ
(
strVal
,
"u1"
);
pos
+=
sizeof
(
VarDataLenT
)
;
SRpcMsg
rpcMsg
=
{
0
}
;
strVal
=
(
char
*
)(
pData
+
pos
)
;
rpcMsg
.
pCont
=
pReq
;
pos
+=
TSDB_USER_LEN
;
rpcMsg
.
contLen
=
sizeof
(
SCreateUserMsg
)
;
EXPECT_STREQ
(
strVal
,
"root"
)
;
rpcMsg
.
msgType
=
TSDB_MSG_TYPE_CREATE_USER
;
pos
+=
sizeof
(
VarDataLenT
);
sendMsg
(
pClient
,
&
rpcMsg
);
strVal
=
(
char
*
)(
pData
+
pos
)
;
SRpcMsg
*
pMsg
=
pClient
->
pRsp
;
pos
+=
TSDB_USER_LEN
;
ASSERT_NE
(
pMsg
,
nullptr
)
;
EXPECT_STREQ
(
strVal
,
"_root"
);
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
(
DndTestUser
,
AlterUser_01
)
{
TEST_F
(
DndTestUser
,
AlterUser_01
)
{
ASSERT_NE
(
pClient
,
nullptr
);
//--- drop user ---
SAlterUserMsg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
sizeof
(
SAlterUserMsg
));
SAlterUserMsg
*
pReq
=
(
SAlterUserMsg
*
)
rpcMallocCont
(
sizeof
(
SAlterUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
pass
,
"p2"
);
strcpy
(
pReq
->
pass
,
"p2"
);
...
@@ -295,60 +248,23 @@ TEST_F(DndTestUser, AlterUser_01) {
...
@@ -295,60 +248,23 @@ TEST_F(DndTestUser, AlterUser_01) {
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
//--- meta ---
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_USER
,
"show users"
,
4
);
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
SendThenCheckShowRetrieveMsg
(
3
);
pShow
->
type
=
TSDB_MGMT_TABLE_USER
;
CheckBinary
(
"u1"
,
TSDB_USER_LEN
);
SRpcMsg
showRpcMsg
=
{
0
};
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
showRpcMsg
.
pCont
=
pShow
;
CheckBinary
(
"u2"
,
TSDB_USER_LEN
);
showRpcMsg
.
contLen
=
sizeof
(
SShowMsg
);
CheckBinary
(
"normal"
,
10
);
showRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW
;
CheckBinary
(
"super"
,
10
);
CheckBinary
(
"normal"
,
10
);
sendMsg
(
pClient
,
&
showRpcMsg
);
CheckTimestamp
();
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pClient
->
pRsp
->
pCont
;
CheckTimestamp
();
STableMetaMsg
*
pMeta
=
&
pShowRsp
->
tableMeta
;
CheckTimestamp
();
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
4
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
//--- retrieve ---
SRetrieveTableMsg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
pRetrieve
->
showId
=
pShowRsp
->
showId
;
SRpcMsg
retrieveRpcMsg
=
{
0
};
retrieveRpcMsg
.
pCont
=
pRetrieve
;
retrieveRpcMsg
.
contLen
=
sizeof
(
SRetrieveTableMsg
);
retrieveRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW_RETRIEVE
;
sendMsg
(
pClient
,
&
retrieveRpcMsg
);
SRetrieveTableRsp
*
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
pClient
->
pRsp
->
pCont
;
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
3
);
char
*
pData
=
pRetrieveRsp
->
data
;
int32_t
pos
=
0
;
char
*
strVal
=
NULL
;
//--- name ---
{
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"u1"
);
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"root"
);
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"_root"
);
}
}
}
TEST_F
(
DndTestUser
,
DropUser_01
)
{
TEST_F
(
DndTestUser
,
DropUser_01
)
{
ASSERT_NE
(
pClient
,
nullptr
);
//--- drop user ---
SDropUserMsg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
sizeof
(
SDropUserMsg
));
SDropUserMsg
*
pReq
=
(
SDropUserMsg
*
)
rpcMallocCont
(
sizeof
(
SDropUserMsg
));
strcpy
(
pReq
->
user
,
"u1"
);
strcpy
(
pReq
->
user
,
"u1"
);
...
@@ -362,47 +278,38 @@ TEST_F(DndTestUser, DropUser_01) {
...
@@ -362,47 +278,38 @@ TEST_F(DndTestUser, DropUser_01) {
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_NE
(
pMsg
,
nullptr
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
ASSERT_EQ
(
pMsg
->
code
,
0
);
//--- meta ---
SendTheCheckShowMetaMsg
(
TSDB_MGMT_TABLE_USER
,
"show users"
,
4
);
SShowMsg
*
pShow
=
(
SShowMsg
*
)
rpcMallocCont
(
sizeof
(
SShowMsg
));
SendThenCheckShowRetrieveMsg
(
2
);
pShow
->
type
=
TSDB_MGMT_TABLE_USER
;
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
SRpcMsg
showRpcMsg
=
{
0
};
CheckBinary
(
"u2"
,
TSDB_USER_LEN
);
showRpcMsg
.
pCont
=
pShow
;
CheckBinary
(
"super"
,
10
);
showRpcMsg
.
contLen
=
sizeof
(
SShowMsg
);
CheckBinary
(
"normal"
,
10
);
showRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW
;
CheckTimestamp
();
CheckTimestamp
();
sendMsg
(
pClient
,
&
showRpcMsg
);
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
SShowRsp
*
pShowRsp
=
(
SShowRsp
*
)
pClient
->
pRsp
->
pCont
;
CheckBinary
(
"root"
,
TSDB_USER_LEN
);
STableMetaMsg
*
pMeta
=
&
pShowRsp
->
tableMeta
;
}
pMeta
->
numOfColumns
=
htons
(
pMeta
->
numOfColumns
);
EXPECT_EQ
(
pMeta
->
numOfColumns
,
4
);
//--- retrieve ---
SRetrieveTableMsg
*
pRetrieve
=
(
SRetrieveTableMsg
*
)
rpcMallocCont
(
sizeof
(
SRetrieveTableMsg
));
pRetrieve
->
showId
=
pShowRsp
->
showId
;
SRpcMsg
retrieveRpcMsg
=
{
0
};
retrieveRpcMsg
.
pCont
=
pRetrieve
;
retrieveRpcMsg
.
contLen
=
sizeof
(
SRetrieveTableMsg
);
retrieveRpcMsg
.
msgType
=
TSDB_MSG_TYPE_SHOW_RETRIEVE
;
sendMsg
(
pClient
,
&
retrieveRpcMsg
);
SRetrieveTableRsp
*
pRetrieveRsp
=
(
SRetrieveTableRsp
*
)
pClient
->
pRsp
->
pCont
;
pRetrieveRsp
->
numOfRows
=
htonl
(
pRetrieveRsp
->
numOfRows
);
EXPECT_EQ
(
pRetrieveRsp
->
numOfRows
,
2
);
char
*
pData
=
pRetrieveRsp
->
data
;
TEST_F
(
DndTestUser
,
RestartDnode
)
{
int32_t
pos
=
0
;
stopServer
(
pServer
)
;
char
*
strVal
=
NULL
;
pServer
=
NULL
;
//--- name ---
uInfo
(
"start all server"
);
{
pos
+=
sizeof
(
VarDataLenT
);
strVal
=
(
char
*
)(
pData
+
pos
);
pos
+=
TSDB_USER_LEN
;
EXPECT_STREQ
(
strVal
,
"root"
);
pos
+=
sizeof
(
VarDataLenT
);
const
char
*
fqdn
=
"localhost"
;
strVal
=
(
char
*
)(
pData
+
pos
);
const
char
*
firstEp
=
"localhost:9530"
;
pos
+=
TSDB_USER_LEN
;
pServer
=
startServer
(
"/tmp/dndTestUser"
,
fqdn
,
9530
,
firstEp
);
EXPECT_STREQ
(
strVal
,
"_root"
);
}
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
);
}
}
source/dnode/mnode/impl/src/mndUser.c
浏览文件 @
0d596ea3
...
@@ -85,9 +85,11 @@ static int32_t mndCreateDefaultUsers(SMnode *pMnode) {
...
@@ -85,9 +85,11 @@ static int32_t mndCreateDefaultUsers(SMnode *pMnode) {
return
-
1
;
return
-
1
;
}
}
#if 0
if (mndCreateDefaultUser(pMnode, TSDB_DEFAULT_USER, "_" TSDB_DEFAULT_USER, TSDB_DEFAULT_PASS) != 0) {
if (mndCreateDefaultUser(pMnode, TSDB_DEFAULT_USER, "_" TSDB_DEFAULT_USER, TSDB_DEFAULT_PASS) != 0) {
return -1;
return -1;
}
}
#endif
return
0
;
return
0
;
}
}
...
@@ -469,7 +471,7 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
...
@@ -469,7 +471,7 @@ static int32_t mndGetUserMeta(SMnodeMsg *pMsg, SShowObj *pShow, STableMetaMsg *p
pShow
->
bytes
[
cols
]
=
8
;
pShow
->
bytes
[
cols
]
=
8
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
pSchema
[
cols
].
type
=
TSDB_DATA_TYPE_TIMESTAMP
;
strcpy
(
pSchema
[
cols
].
name
,
"create
_
time"
);
strcpy
(
pSchema
[
cols
].
name
,
"create
time"
);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
pSchema
[
cols
].
bytes
=
htons
(
pShow
->
bytes
[
cols
]);
cols
++
;
cols
++
;
...
@@ -516,11 +518,8 @@ static int32_t mndRetrieveUsers(SMnodeMsg *pMsg, SShowObj *pShow, char *data, in
...
@@ -516,11 +518,8 @@ static int32_t mndRetrieveUsers(SMnodeMsg *pMsg, SShowObj *pShow, char *data, in
if
(
pUser
->
superAuth
)
{
if
(
pUser
->
superAuth
)
{
const
char
*
src
=
"super"
;
const
char
*
src
=
"super"
;
STR_WITH_SIZE_TO_VARSTR
(
pWrite
,
src
,
strlen
(
src
));
STR_WITH_SIZE_TO_VARSTR
(
pWrite
,
src
,
strlen
(
src
));
}
else
if
(
pUser
->
writeAuth
)
{
const
char
*
src
=
"writable"
;
STR_WITH_SIZE_TO_VARSTR
(
pWrite
,
src
,
strlen
(
src
));
}
else
{
}
else
{
const
char
*
src
=
"
readable
"
;
const
char
*
src
=
"
normal
"
;
STR_WITH_SIZE_TO_VARSTR
(
pWrite
,
src
,
strlen
(
src
));
STR_WITH_SIZE_TO_VARSTR
(
pWrite
,
src
,
strlen
(
src
));
}
}
cols
++
;
cols
++
;
...
...
source/dnode/mnode/sdb/src/sdb.c
浏览文件 @
0d596ea3
...
@@ -52,10 +52,10 @@ SSdb *sdbInit(SSdbOpt *pOption) {
...
@@ -52,10 +52,10 @@ SSdb *sdbInit(SSdbOpt *pOption) {
void
sdbCleanup
(
SSdb
*
pSdb
)
{
void
sdbCleanup
(
SSdb
*
pSdb
)
{
mDebug
(
"start to cleanup sdb"
);
mDebug
(
"start to cleanup sdb"
);
if
(
pSdb
->
curVer
!=
pSdb
->
lastCommitVer
)
{
//
if (pSdb->curVer != pSdb->lastCommitVer) {
mDebug
(
"write sdb file for curVer:% "
PRId64
" and lastVer:%"
PRId64
,
pSdb
->
curVer
,
pSdb
->
lastCommitVer
);
mDebug
(
"write sdb file for curVer:% "
PRId64
" and lastVer:%"
PRId64
,
pSdb
->
curVer
,
pSdb
->
lastCommitVer
);
sdbWriteFile
(
pSdb
);
sdbWriteFile
(
pSdb
);
}
//
}
if
(
pSdb
->
currDir
!=
NULL
)
{
if
(
pSdb
->
currDir
!=
NULL
)
{
tfree
(
pSdb
->
currDir
);
tfree
(
pSdb
->
currDir
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录