Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
676e70d5
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看板
提交
676e70d5
编写于
6月 21, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
refactor: add gtid to log
上级
40a84f9f
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
31 addition
and
529 deletion
+31
-529
source/dnode/mgmt/node_util/inc/dmUtil.h
source/dnode/mgmt/node_util/inc/dmUtil.h
+6
-6
source/dnode/mgmt/test/sut/src/server.cpp
source/dnode/mgmt/test/sut/src/server.cpp
+1
-1
source/dnode/mgmt/test/sut/src/sut.cpp
source/dnode/mgmt/test/sut/src/sut.cpp
+1
-0
source/dnode/mnode/impl/inc/mndInt.h
source/dnode/mnode/impl/inc/mndInt.h
+6
-6
source/dnode/mnode/impl/test/user/user.cpp
source/dnode/mnode/impl/test/user/user.cpp
+1
-508
source/dnode/vnode/src/inc/vnd.h
source/dnode/vnode/src/inc/vnd.h
+15
-7
source/libs/transport/inc/transLog.h
source/libs/transport/inc/transLog.h
+1
-1
未找到文件。
source/dnode/mgmt/node_util/inc/dmUtil.h
浏览文件 @
676e70d5
...
...
@@ -53,12 +53,12 @@ extern "C" {
#define dDebug(...) { if (dDebugFlag & DEBUG_DEBUG) { taosPrintLog("DND ", DEBUG_DEBUG, dDebugFlag, __VA_ARGS__); }}
#define dTrace(...) { if (dDebugFlag & DEBUG_TRACE) { taosPrintLog("DND ", DEBUG_TRACE, dDebugFlag, __VA_ARGS__); }}
#define dGFatal(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dFatal(param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define dGError(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dError(param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define dGWarn(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dWarn (param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define dGInfo(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dInfo (param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define dGDebug(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dDebug(param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define dGTrace(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); dTrace(param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define dGFatal(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); dFatal(param ", gtid:%s", __VA_ARGS__, buf);}
#define dGError(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); dError(param ", gtid:%s", __VA_ARGS__, buf);}
#define dGWarn(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); dWarn (param ", gtid:%s", __VA_ARGS__, buf);}
#define dGInfo(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); dInfo (param ", gtid:%s", __VA_ARGS__, buf);}
#define dGDebug(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); dDebug(param ", gtid:%s", __VA_ARGS__, buf);}
#define dGTrace(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); dTrace(param ", gtid:%s", __VA_ARGS__, buf);}
// clang-format on
...
...
source/dnode/mgmt/test/sut/src/server.cpp
浏览文件 @
676e70d5
...
...
@@ -28,7 +28,7 @@ bool TestServer::Start() {
taosThreadAttrSetDetachState
(
&
thAttr
,
PTHREAD_CREATE_JOINABLE
);
taosThreadCreate
(
&
threadId
,
&
thAttr
,
serverLoop
,
NULL
);
taosThreadAttrDestroy
(
&
thAttr
);
taosMsleep
(
2
100
);
taosMsleep
(
3
100
);
return
true
;
}
...
...
source/dnode/mgmt/test/sut/src/sut.cpp
浏览文件 @
676e70d5
...
...
@@ -102,6 +102,7 @@ int32_t Testbase::SendShowReq(int8_t showType, const char* tb, const char* db) {
ASSERT
(
pRsp
->
pCont
!=
nullptr
);
if
(
pRsp
->
contLen
==
0
)
return
-
1
;
if
(
pRsp
->
code
!=
0
)
return
-
1
;
showRsp
=
(
SRetrieveMetaTableRsp
*
)
pRsp
->
pCont
;
showRsp
->
handle
=
htobe64
(
showRsp
->
handle
);
// show Id
...
...
source/dnode/mnode/impl/inc/mndInt.h
浏览文件 @
676e70d5
...
...
@@ -42,12 +42,12 @@ extern "C" {
#define mDebug(...) { if (mDebugFlag & DEBUG_DEBUG) { taosPrintLog("MND ", DEBUG_DEBUG, mDebugFlag, __VA_ARGS__); }}
#define mTrace(...) { if (mDebugFlag & DEBUG_TRACE) { taosPrintLog("MND ", DEBUG_TRACE, mDebugFlag, __VA_ARGS__); }}
#define mGFatal(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mFatal(param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define mGError(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mError(param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define mGWarn(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mWarn (param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define mGInfo(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mInfo (param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define mGDebug(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mDebug(param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define mGTrace(param, ...)
do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", gtid:%s", __VA_ARGS__, buf);} while(0)
#define mGFatal(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mFatal(param ", gtid:%s", __VA_ARGS__, buf);}
#define mGError(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mError(param ", gtid:%s", __VA_ARGS__, buf);}
#define mGWarn(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mWarn (param ", gtid:%s", __VA_ARGS__, buf);}
#define mGInfo(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mInfo (param ", gtid:%s", __VA_ARGS__, buf);}
#define mGDebug(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mDebug(param ", gtid:%s", __VA_ARGS__, buf);}
#define mGTrace(param, ...)
{ char buf[40] = {0}; TRACE_TO_STR(trace, buf); mTrace(param ", gtid:%s", __VA_ARGS__, buf);}
// clang-format on
...
...
source/dnode/mnode/impl/test/user/user.cpp
浏览文件 @
676e70d5
...
...
@@ -26,514 +26,7 @@ class MndTestUser : public ::testing::Test {
Testbase
MndTestUser
::
test
;
TEST_F
(
MndTestUser
,
01
_Show_User
)
{
uInfo
(
"show users"
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
TEST_F
(
MndTestUser
,
02
_Create_User
)
{
{
SCreateUserReq
createReq
=
{
0
};
strcpy
(
createReq
.
user
,
""
);
strcpy
(
createReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
{
SCreateUserReq
createReq
=
{
0
};
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
""
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
}
{
SCreateUserReq
createReq
=
{
0
};
strcpy
(
createReq
.
user
,
"root"
);
strcpy
(
createReq
.
pass
,
"1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_USER_ALREADY_EXIST
);
}
{
SCreateUserReq
createReq
=
{
0
};
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
{
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u1"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
{
SCreateUserReq
createReq
=
{
0
};
strcpy
(
createReq
.
user
,
"u2"
);
strcpy
(
createReq
.
pass
,
"p1"
);
createReq
.
superUser
=
1
;
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
{
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u2"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
}
TEST_F
(
MndTestUser
,
03
_Alter_User
)
{
{
SCreateUserReq
createReq
=
{
0
};
strcpy
(
createReq
.
user
,
"u3"
);
strcpy
(
createReq
.
pass
,
"p1"
);
createReq
.
superUser
=
1
;
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_PASSWD
;
strcpy
(
alterReq
.
user
,
""
);
strcpy
(
alterReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_PASSWD
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
""
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_PASS_FORMAT
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_PASSWD
;
strcpy
(
alterReq
.
user
,
"u4"
);
strcpy
(
alterReq
.
pass
,
"1"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_PASSWD
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_SUPERUSER
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
alterReq
.
superUser
=
1
;
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_REMOVE_ALL_DB
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"1.*"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_REMOVE_ALL_DB
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"1.*"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_ADD_READ_DB
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"d1"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_DB_NOT_EXIST
);
}
{
SCreateDbReq
createReq
=
{
0
};
strcpy
(
createReq
.
db
,
"1.d2"
);
createReq
.
numOfVgroups
=
2
;
createReq
.
buffer
=
-
1
;
createReq
.
pageSize
=
-
1
;
createReq
.
pages
=
-
1
;
createReq
.
daysPerFile
=
10
*
1440
;
createReq
.
daysToKeep0
=
3650
*
1440
;
createReq
.
daysToKeep1
=
3650
*
1440
;
createReq
.
daysToKeep2
=
3650
*
1440
;
createReq
.
minRows
=
100
;
createReq
.
maxRows
=
4096
;
createReq
.
fsyncPeriod
=
3000
;
createReq
.
walLevel
=
1
;
createReq
.
precision
=
0
;
createReq
.
compression
=
2
;
createReq
.
replications
=
1
;
createReq
.
strict
=
1
;
createReq
.
cacheLastRow
=
0
;
createReq
.
ignoreExist
=
1
;
int32_t
contLen
=
tSerializeSCreateDbReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateDbReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_DB
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_ADD_READ_DB
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"1.d2"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_ADD_READ_DB
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"1.d2"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SGetUserAuthReq
authReq
=
{
0
};
strcpy
(
authReq
.
user
,
"u3"
);
int32_t
contLen
=
tSerializeSGetUserAuthReq
(
NULL
,
0
,
&
authReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSGetUserAuthReq
(
pReq
,
contLen
,
&
authReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_GET_USER_AUTH
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
SGetUserAuthRsp
authRsp
=
{
0
};
tDeserializeSGetUserAuthRsp
(
pRsp
->
pCont
,
pRsp
->
contLen
,
&
authRsp
);
EXPECT_STREQ
(
authRsp
.
user
,
"u3"
);
EXPECT_EQ
(
authRsp
.
superAuth
,
1
);
int32_t
numOfReadDbs
=
taosHashGetSize
(
authRsp
.
readDbs
);
int32_t
numOfWriteDbs
=
taosHashGetSize
(
authRsp
.
writeDbs
);
EXPECT_EQ
(
numOfReadDbs
,
1
);
EXPECT_EQ
(
numOfWriteDbs
,
0
);
char
*
dbname
=
(
char
*
)
taosHashGet
(
authRsp
.
readDbs
,
"1.d2"
,
4
);
EXPECT_TRUE
(
dbname
!=
NULL
);
taosHashCleanup
(
authRsp
.
readDbs
);
taosHashCleanup
(
authRsp
.
writeDbs
);
}
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_REMOVE_READ_DB
;
strcpy
(
alterReq
.
user
,
"u3"
);
strcpy
(
alterReq
.
pass
,
"1"
);
strcpy
(
alterReq
.
dbname
,
"1.d2"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u3"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
}
TEST_F
(
MndTestUser
,
05
_Drop_User
)
{
{
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
""
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_INVALID_USER_FORMAT
);
}
{
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u4"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
TSDB_CODE_MND_USER_NOT_EXIST
);
}
{
SCreateUserReq
createReq
=
{
0
};
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u1"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
TEST_F
(
MndTestUser
,
06
_Create_Drop_Alter_User
)
{
{
SCreateUserReq
createReq
=
{
0
};
strcpy
(
createReq
.
user
,
"u1"
);
strcpy
(
createReq
.
pass
,
"p1"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
{
SCreateUserReq
createReq
=
{
0
};
strcpy
(
createReq
.
user
,
"u2"
);
strcpy
(
createReq
.
pass
,
"p2"
);
int32_t
contLen
=
tSerializeSCreateUserReq
(
NULL
,
0
,
&
createReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSCreateUserReq
(
pReq
,
contLen
,
&
createReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_CREATE_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
3
);
{
SAlterUserReq
alterReq
=
{
0
};
alterReq
.
alterType
=
TSDB_ALTER_USER_PASSWD
;
strcpy
(
alterReq
.
user
,
"u1"
);
strcpy
(
alterReq
.
pass
,
"p2"
);
int32_t
contLen
=
tSerializeSAlterUserReq
(
NULL
,
0
,
&
alterReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSAlterUserReq
(
pReq
,
contLen
,
&
alterReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_ALTER_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
3
);
{
SDropUserReq
dropReq
=
{
0
};
strcpy
(
dropReq
.
user
,
"u1"
);
int32_t
contLen
=
tSerializeSDropUserReq
(
NULL
,
0
,
&
dropReq
);
void
*
pReq
=
rpcMallocCont
(
contLen
);
tSerializeSDropUserReq
(
pReq
,
contLen
,
&
dropReq
);
SRpcMsg
*
pRsp
=
test
.
SendReq
(
TDMT_MND_DROP_USER
,
pReq
,
contLen
);
ASSERT_NE
(
pRsp
,
nullptr
);
ASSERT_EQ
(
pRsp
->
code
,
0
);
}
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
// restart
test
.
Restart
();
taosMsleep
(
1000
);
test
.
SendShowReq
(
TSDB_MGMT_TABLE_USER
,
"user_users"
,
""
);
EXPECT_EQ
(
test
.
GetShowRows
(),
2
);
}
source/dnode/vnode/src/inc/vnd.h
浏览文件 @
676e70d5
...
...
@@ -26,13 +26,21 @@ extern "C" {
#endif
// clang-format off
#define vFatal(...) do { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }} while(0)
#define vError(...) do { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }} while(0)
#define vWarn(...) do { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("VND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }} while(0)
#define vInfo(...) do { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND ", DEBUG_INFO, 255, __VA_ARGS__); }} while(0)
#define vDebug(...) do { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", DEBUG_DEBUG, vDebugFlag, __VA_ARGS__); }} while(0)
#define vTrace(...) do { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }} while(0)
#define vGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vTrace(param " GTID: %s", __VA_ARGS__, buf);} while(0)//#define vDye(...) do
#define vFatal(...) { if (vDebugFlag & DEBUG_FATAL) { taosPrintLog("VND FATAL ", DEBUG_FATAL, 255, __VA_ARGS__); }}
#define vError(...) { if (vDebugFlag & DEBUG_ERROR) { taosPrintLog("VND ERROR ", DEBUG_ERROR, 255, __VA_ARGS__); }}
#define vWarn(...) { if (vDebugFlag & DEBUG_WARN) { taosPrintLog("VND WARN ", DEBUG_WARN, 255, __VA_ARGS__); }}
#define vInfo(...) { if (vDebugFlag & DEBUG_INFO) { taosPrintLog("VND ", DEBUG_INFO, 255, __VA_ARGS__); }}
#define vDebug(...) { if (vDebugFlag & DEBUG_DEBUG) { taosPrintLog("VND ", DEBUG_DEBUG, vDebugFlag, __VA_ARGS__); }}
#define vTrace(...) { if (vDebugFlag & DEBUG_TRACE) { taosPrintLog("VND ", DEBUG_TRACE, vDebugFlag, __VA_ARGS__); }}
#define vGFatal(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vFatal(param ", gtid:%s", __VA_ARGS__, buf);}
#define vGError(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vError(param ", gtid:%s", __VA_ARGS__, buf);}
#define vGWarn(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vWarn (param ", gtid:%s", __VA_ARGS__, buf);}
#define vGInfo(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vInfo (param ", gtid:%s", __VA_ARGS__, buf);}
#define vGDebug(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vDebug(param ", gtid:%s", __VA_ARGS__, buf);}
#define vGTrace(param, ...) { char buf[40] = {0}; TRACE_TO_STR(trace, buf); vTrace(param ", gtid:%s", __VA_ARGS__, buf);}
// clang-format on
// vnodeCfg.c
...
...
source/libs/transport/inc/transLog.h
浏览文件 @
676e70d5
...
...
@@ -33,7 +33,7 @@ extern "C" {
#define tDump(x, y) do {if (rpcDebugFlag & DEBUG_DUMP) { taosDumpData((unsigned char *)x, y); } } while(0)
//#define tTR(param, ...) do { char buf[40] = {0};TRACE_TO_STR(trace, buf);tTrace("TRID: %s "param, buf, __VA_ARGS__);} while(0)
#define tGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tTrace(param ",
GTID:
%s", __VA_ARGS__, buf);} while(0)
#define tGTrace(param, ...) do { char buf[40] = {0}; TRACE_TO_STR(trace, buf); tTrace(param ",
gtid:
%s", __VA_ARGS__, buf);} while(0)
// clang-format on
#ifdef __cplusplus
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录