Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
8cafeb72
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看板
提交
8cafeb72
编写于
12月 23, 2022
作者:
X
Xiaoyu Wang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
enh: improve unit tests
上级
3d3885d1
变更
4
展开全部
显示空白变更内容
内联
并排
Showing
4 changed file
with
701 addition
and
263 deletion
+701
-263
source/libs/parser/test/parAlterToBalanceTest.cpp
source/libs/parser/test/parAlterToBalanceTest.cpp
+300
-141
source/libs/parser/test/parExplainToSyncdbTest.cpp
source/libs/parser/test/parExplainToSyncdbTest.cpp
+31
-3
source/libs/parser/test/parInitialCTest.cpp
source/libs/parser/test/parInitialCTest.cpp
+332
-116
source/libs/parser/test/parInitialDTest.cpp
source/libs/parser/test/parInitialDTest.cpp
+38
-3
未找到文件。
source/libs/parser/test/parAlterToBalanceTest.cpp
浏览文件 @
8cafeb72
...
...
@@ -21,6 +21,25 @@ namespace ParserTest {
class
ParserInitialATest
:
public
ParserDdlTest
{};
/*
* ALTER ACCOUNT account_name alter_account_options
*
* alter_account_options:
* alter_account_option ...
*
* alter_account_option: {
* PASS value
* | PPS value
* | TSERIES value
* | STORAGE value
* | STREAMS value
* | QTIME value
* | DBS value
* | USERS value
* | CONNS value
* | STATE value
* }
*/
TEST_F
(
ParserInitialATest
,
alterAccount
)
{
useDb
(
"root"
,
"test"
);
...
...
@@ -48,6 +67,7 @@ TEST_F(ParserInitialATest, alterDnode) {
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_ALTER_DNODE_STMT
);
ASSERT_EQ
(
pQuery
->
pCmdMsg
->
msgType
,
TDMT_MND_CONFIG_DNODE
);
SMCfgDnodeReq
req
=
{
0
};
ASSERT_EQ
(
tDeserializeSMCfgDnodeReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
req
.
dnodeId
,
expect
.
dnodeId
);
...
...
@@ -86,9 +106,8 @@ TEST_F(ParserInitialATest, alterDnode) {
* | KEEP {int_value | duration_value} -- rang [1, 365000], default 3650, unit day
* | PAGES int_value -- rang [64, INT32_MAX], default 256, unit page
* | REPLICA int_value -- todo: enum 1, 3, default 1, unit replica
* | STRICT {'off' | 'on'} -- todo: default 'off'
* | WAL_LEVEL int_value -- enum 1, 2, default 1
* | S
S
T_TRIGGER int_value -- rang [1, 16], default 8
* | S
T
T_TRIGGER int_value -- rang [1, 16], default 8
* }
*/
TEST_F
(
ParserInitialATest
,
alterDatabase
)
{
...
...
@@ -130,10 +149,11 @@ TEST_F(ParserInitialATest, alterDatabase) {
auto
setAlterDbStrict
=
[
&
](
int8_t
strict
)
{
expect
.
strict
=
strict
;
};
auto
setAlterDbCacheModel
=
[
&
](
int8_t
cacheModel
)
{
expect
.
cacheLast
=
cacheModel
;
};
auto
setAlterDbReplica
=
[
&
](
int8_t
replications
)
{
expect
.
replications
=
replications
;
};
auto
setAlterDbS
s
tTrigger
=
[
&
](
int8_t
sstTrigger
)
{
expect
.
sstTrigger
=
sstTrigger
;
};
auto
setAlterDbS
t
tTrigger
=
[
&
](
int8_t
sstTrigger
)
{
expect
.
sstTrigger
=
sstTrigger
;
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_ALTER_DATABASE_STMT
);
ASSERT_EQ
(
pQuery
->
pCmdMsg
->
msgType
,
TDMT_MND_ALTER_DB
);
SAlterDbReq
req
=
{
0
};
ASSERT_EQ
(
tDeserializeSAlterDbReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
std
::
string
(
req
.
db
),
std
::
string
(
expect
.
db
));
...
...
@@ -161,11 +181,12 @@ TEST_F(ParserInitialATest, alterDatabase) {
setAlterDbFsync
(
200
);
setAlterDbWal
(
1
);
setAlterDbCacheModel
(
TSDB_CACHE_MODEL_LAST_ROW
);
setAlterDbS
s
tTrigger
(
16
);
setAlterDbS
t
tTrigger
(
16
);
setAlterDbBuffer
(
16
);
setAlterDbPages
(
128
);
setAlterDbReplica
(
3
);
run
(
"ALTER DATABASE test BUFFER 16 CACHEMODEL 'last_row' CACHESIZE 32 WAL_FSYNC_PERIOD 200 KEEP 10 PAGES 128 "
"WAL_LEVEL 1 STT_TRIGGER 16"
);
"
REPLICA 3
WAL_LEVEL 1 STT_TRIGGER 16"
);
clearAlterDbReq
();
initAlterDb
(
"test"
);
...
...
@@ -240,6 +261,22 @@ TEST_F(ParserInitialATest, alterDatabase) {
setAlterDbWal
(
2
);
run
(
"ALTER DATABASE test WAL_LEVEL 2"
);
clearAlterDbReq
();
initAlterDb
(
"test"
);
setAlterDbReplica
(
1
);
run
(
"ALTER DATABASE test REPLICA 1"
);
setAlterDbReplica
(
3
);
run
(
"ALTER DATABASE test REPLICA 3"
);
clearAlterDbReq
();
initAlterDb
(
"test"
);
setAlterDbSttTrigger
(
1
);
run
(
"ALTER DATABASE test STT_TRIGGER 1"
);
setAlterDbSttTrigger
(
4
);
run
(
"ALTER DATABASE test STT_TRIGGER 4"
);
setAlterDbSttTrigger
(
16
);
run
(
"ALTER DATABASE test STT_TRIGGER 16"
);
clearAlterDbReq
();
}
TEST_F
(
ParserInitialATest
,
alterDatabaseSemanticCheck
)
{
...
...
@@ -260,6 +297,7 @@ TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) {
run
(
"ALTER DATABASE test PAGES 63"
,
TSDB_CODE_PAR_INVALID_DB_OPTION
);
run
(
"ALTER DATABASE test WAL_LEVEL 0"
,
TSDB_CODE_PAR_INVALID_DB_OPTION
);
run
(
"ALTER DATABASE test WAL_LEVEL 3"
,
TSDB_CODE_PAR_INVALID_DB_OPTION
);
run
(
"ALTER DATABASE test REPLICA 2"
,
TSDB_CODE_PAR_INVALID_DB_OPTION
);
run
(
"ALTER DATABASE test STT_TRIGGER 0"
,
TSDB_CODE_PAR_INVALID_DB_OPTION
);
run
(
"ALTER DATABASE test STT_TRIGGER 17"
,
TSDB_CODE_PAR_INVALID_DB_OPTION
);
// Regardless of the specific sentence
...
...
@@ -267,7 +305,7 @@ TEST_F(ParserInitialATest, alterDatabaseSemanticCheck) {
}
/*
* ALTER LOCAL
dnode_id
'config' ['value']
* ALTER LOCAL 'config' ['value']
*/
TEST_F
(
ParserInitialATest
,
alterLocal
)
{
useDb
(
"root"
,
"test"
);
...
...
@@ -311,19 +349,19 @@ TEST_F(ParserInitialATest, alterLocal) {
* | ADD COLUMN col_name column_type
* | DROP COLUMN col_name
* | MODIFY COLUMN col_name column_type
* | RENAME COLUMN old_col_name new_col_name -- normal table
* | ADD TAG tag_name tag_type -- super table
* | DROP TAG tag_name -- super table
* | MODIFY TAG tag_name tag_type -- super table
* | RENAME TAG old_tag_name new_tag_name -- super table
* | SET TAG tag_name = new_tag_value -- child table
* | RENAME COLUMN old_col_name new_col_name --
only
normal table
* | ADD TAG tag_name tag_type --
only
super table
* | DROP TAG tag_name --
only
super table
* | MODIFY TAG tag_name tag_type --
only
super table
* | RENAME TAG old_tag_name new_tag_name --
only
super table
* | SET TAG tag_name = new_tag_value --
only
child table
* }
*
* alter_table_options:
* alter_table_option ...
*
* alter_table_option: {
* TTL int_value -- child/normal table
* TTL int_value --
only
child/normal table
* | COMMENT 'string_value'
* }
*/
...
...
@@ -379,6 +417,7 @@ TEST_F(ParserInitialATest, alterSTable) {
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_ALTER_SUPER_TABLE_STMT
);
ASSERT_EQ
(
pQuery
->
pCmdMsg
->
msgType
,
TDMT_MND_ALTER_STB
);
SMAlterStbReq
req
=
{
0
};
ASSERT_EQ
(
tDeserializeSMAlterStbReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
std
::
string
(
req
.
name
),
std
::
string
(
expect
.
name
));
...
...
@@ -444,9 +483,35 @@ TEST_F(ParserInitialATest, alterSTableSemanticCheck) {
run
(
"ALTER STABLE st1 TTL 10"
,
TSDB_CODE_PAR_INVALID_ALTER_TABLE
);
}
/*
* ALTER TABLE [db_name.]tb_name alter_table_clause
*
* alter_table_clause: {
* alter_table_options
* | ADD COLUMN col_name column_type
* | DROP COLUMN col_name
* | MODIFY COLUMN col_name column_type
* | RENAME COLUMN old_col_name new_col_name -- only normal table
* | ADD TAG tag_name tag_type -- only super table
* | DROP TAG tag_name -- only super table
* | MODIFY TAG tag_name tag_type -- only super table
* | RENAME TAG old_tag_name new_tag_name -- only super table
* | SET TAG tag_name = new_tag_value -- only child table
* }
*
* alter_table_options:
* alter_table_option ...
*
* alter_table_option: {
* TTL int_value -- only child/normal table
* | COMMENT 'string_value'
* }
*/
TEST_F
(
ParserInitialATest
,
alterTable
)
{
useDb
(
"root"
,
"test"
);
// normal/child table
{
SVAlterTbReq
expect
=
{
0
};
auto
clearAlterTbReq
=
[
&
]()
{
...
...
@@ -574,6 +639,99 @@ TEST_F(ParserInitialATest, alterTable) {
setAlterTableTag
(
"st1s1"
,
"tag1"
,
(
uint8_t
*
)
&
val
,
sizeof
(
val
));
run
(
"ALTER TABLE st1s1 SET TAG tag1=10"
);
clearAlterTbReq
();
}
// super table
{
SMAlterStbReq
expect
=
{
0
};
auto
clearAlterStbReq
=
[
&
]()
{
tFreeSMAltertbReq
(
&
expect
);
memset
(
&
expect
,
0
,
sizeof
(
SMAlterStbReq
));
};
auto
setAlterStbReq
=
[
&
](
const
char
*
pTbname
,
int8_t
alterType
,
int32_t
numOfFields
=
0
,
const
char
*
pField1Name
=
nullptr
,
int8_t
field1Type
=
0
,
int32_t
field1Bytes
=
0
,
const
char
*
pField2Name
=
nullptr
,
const
char
*
pComment
=
nullptr
)
{
int32_t
len
=
snprintf
(
expect
.
name
,
sizeof
(
expect
.
name
),
"0.test.%s"
,
pTbname
);
expect
.
name
[
len
]
=
'\0'
;
expect
.
alterType
=
alterType
;
if
(
nullptr
!=
pComment
)
{
expect
.
comment
=
strdup
(
pComment
);
expect
.
commentLen
=
strlen
(
pComment
);
}
expect
.
numOfFields
=
numOfFields
;
if
(
NULL
==
expect
.
pFields
)
{
expect
.
pFields
=
taosArrayInit
(
2
,
sizeof
(
TAOS_FIELD
));
TAOS_FIELD
field
=
{
0
};
taosArrayPush
(
expect
.
pFields
,
&
field
);
taosArrayPush
(
expect
.
pFields
,
&
field
);
}
TAOS_FIELD
*
pField
=
(
TAOS_FIELD
*
)
taosArrayGet
(
expect
.
pFields
,
0
);
if
(
NULL
!=
pField1Name
)
{
strcpy
(
pField
->
name
,
pField1Name
);
pField
->
name
[
strlen
(
pField1Name
)]
=
'\0'
;
}
else
{
memset
(
pField
,
0
,
sizeof
(
TAOS_FIELD
));
}
pField
->
type
=
field1Type
;
pField
->
bytes
=
field1Bytes
>
0
?
field1Bytes
:
(
field1Type
>
0
?
tDataTypes
[
field1Type
].
bytes
:
0
);
pField
=
(
TAOS_FIELD
*
)
taosArrayGet
(
expect
.
pFields
,
1
);
if
(
NULL
!=
pField2Name
)
{
strcpy
(
pField
->
name
,
pField2Name
);
pField
->
name
[
strlen
(
pField2Name
)]
=
'\0'
;
}
else
{
memset
(
pField
,
0
,
sizeof
(
TAOS_FIELD
));
}
pField
->
type
=
0
;
pField
->
bytes
=
0
;
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_ALTER_TABLE_STMT
);
ASSERT_EQ
(
pQuery
->
pCmdMsg
->
msgType
,
TDMT_MND_ALTER_STB
);
SMAlterStbReq
req
=
{
0
};
ASSERT_EQ
(
tDeserializeSMAlterStbReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
std
::
string
(
req
.
name
),
std
::
string
(
expect
.
name
));
ASSERT_EQ
(
req
.
alterType
,
expect
.
alterType
);
ASSERT_EQ
(
req
.
numOfFields
,
expect
.
numOfFields
);
if
(
expect
.
numOfFields
>
0
)
{
TAOS_FIELD
*
pField
=
(
TAOS_FIELD
*
)
taosArrayGet
(
req
.
pFields
,
0
);
TAOS_FIELD
*
pExpectField
=
(
TAOS_FIELD
*
)
taosArrayGet
(
expect
.
pFields
,
0
);
ASSERT_EQ
(
std
::
string
(
pField
->
name
),
std
::
string
(
pExpectField
->
name
));
ASSERT_EQ
(
pField
->
type
,
pExpectField
->
type
);
ASSERT_EQ
(
pField
->
bytes
,
pExpectField
->
bytes
);
}
if
(
expect
.
numOfFields
>
1
)
{
TAOS_FIELD
*
pField
=
(
TAOS_FIELD
*
)
taosArrayGet
(
req
.
pFields
,
1
);
TAOS_FIELD
*
pExpectField
=
(
TAOS_FIELD
*
)
taosArrayGet
(
expect
.
pFields
,
1
);
ASSERT_EQ
(
std
::
string
(
pField
->
name
),
std
::
string
(
pExpectField
->
name
));
ASSERT_EQ
(
pField
->
type
,
pExpectField
->
type
);
ASSERT_EQ
(
pField
->
bytes
,
pExpectField
->
bytes
);
}
tFreeSMAltertbReq
(
&
req
);
});
setAlterStbReq
(
"st1"
,
TSDB_ALTER_TABLE_ADD_TAG
,
1
,
"tag11"
,
TSDB_DATA_TYPE_BIGINT
);
run
(
"ALTER TABLE st1 ADD TAG tag11 BIGINT"
);
clearAlterStbReq
();
setAlterStbReq
(
"st1"
,
TSDB_ALTER_TABLE_DROP_TAG
,
1
,
"tag1"
);
run
(
"ALTER TABLE st1 DROP TAG tag1"
);
clearAlterStbReq
();
setAlterStbReq
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_TAG_BYTES
,
1
,
"tag2"
,
TSDB_DATA_TYPE_VARCHAR
,
30
+
VARSTR_HEADER_SIZE
);
run
(
"ALTER TABLE st1 MODIFY TAG tag2 VARCHAR(30)"
);
clearAlterStbReq
();
setAlterStbReq
(
"st1"
,
TSDB_ALTER_TABLE_UPDATE_TAG_NAME
,
2
,
"tag1"
,
0
,
0
,
"tag11"
);
run
(
"ALTER TABLE st1 RENAME TAG tag1 tag11"
);
clearAlterStbReq
();
}
}
TEST_F
(
ParserInitialATest
,
alterTableSemanticCheck
)
{
...
...
@@ -588,7 +746,7 @@ TEST_F(ParserInitialATest, alterTableSemanticCheck) {
}
/*
* ALTER USER user_name
PASS str_valu
e
* ALTER USER user_name
alter_user_claus
e
*
* alter_user_clause: {
* PASS str_value
...
...
@@ -618,6 +776,7 @@ TEST_F(ParserInitialATest, alterUser) {
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_ALTER_USER_STMT
);
ASSERT_EQ
(
pQuery
->
pCmdMsg
->
msgType
,
TDMT_MND_ALTER_USER
);
SAlterUserReq
req
=
{
0
};
ASSERT_TRUE
(
TSDB_CODE_SUCCESS
==
tDeserializeSAlterUserReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
));
...
...
source/libs/parser/test/parExplainToSyncdbTest.cpp
浏览文件 @
8cafeb72
...
...
@@ -52,8 +52,8 @@ TEST_F(ParserExplainToSyncdbTest, grant) {
ASSERT_EQ
(
string
(
req
.
objname
),
string
(
expect
.
objname
));
});
setAlterUserReq
(
TSDB_ALTER_USER_ADD_ALL_DB
,
"wxy"
,
"0.
test
"
);
run
(
"GRANT ALL ON
test
.* TO wxy"
);
setAlterUserReq
(
TSDB_ALTER_USER_ADD_ALL_DB
,
"wxy"
,
"0.
*
"
);
run
(
"GRANT ALL ON
*
.* TO wxy"
);
setAlterUserReq
(
TSDB_ALTER_USER_ADD_READ_DB
,
"wxy"
,
"0.test"
);
run
(
"GRANT READ ON test.* TO wxy"
);
...
...
@@ -138,10 +138,38 @@ TEST_F(ParserExplainToSyncdbTest, redistributeVgroup) {
TEST_F
(
ParserExplainToSyncdbTest
,
revoke
)
{
useDb
(
"root"
,
"test"
);
run
(
"REVOKE ALL ON test.* FROM wxy"
);
SAlterUserReq
expect
=
{
0
};
auto
setAlterUserReq
=
[
&
](
int8_t
alterType
,
const
string
&
user
,
const
string
&
obj
)
{
expect
.
alterType
=
alterType
;
snprintf
(
expect
.
user
,
sizeof
(
expect
.
user
),
"%s"
,
user
.
c_str
());
snprintf
(
expect
.
objname
,
sizeof
(
expect
.
objname
),
"%s"
,
obj
.
c_str
());
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_REVOKE_STMT
);
ASSERT_EQ
(
pQuery
->
pCmdMsg
->
msgType
,
TDMT_MND_ALTER_USER
);
SAlterUserReq
req
=
{
0
};
ASSERT_EQ
(
tDeserializeSAlterUserReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
),
TSDB_CODE_SUCCESS
);
ASSERT_EQ
(
req
.
alterType
,
expect
.
alterType
);
ASSERT_EQ
(
string
(
req
.
user
),
string
(
expect
.
user
));
ASSERT_EQ
(
string
(
req
.
objname
),
string
(
expect
.
objname
));
});
setAlterUserReq
(
TSDB_ALTER_USER_REMOVE_ALL_DB
,
"wxy"
,
"0.*"
);
run
(
"REVOKE ALL ON *.* FROM wxy"
);
setAlterUserReq
(
TSDB_ALTER_USER_REMOVE_READ_DB
,
"wxy"
,
"0.test"
);
run
(
"REVOKE READ ON test.* FROM wxy"
);
setAlterUserReq
(
TSDB_ALTER_USER_REMOVE_WRITE_DB
,
"wxy"
,
"0.test"
);
run
(
"REVOKE WRITE ON test.* FROM wxy"
);
setAlterUserReq
(
TSDB_ALTER_USER_REMOVE_ALL_DB
,
"wxy"
,
"0.test"
);
run
(
"REVOKE READ, WRITE ON test.* FROM wxy"
);
setAlterUserReq
(
TSDB_ALTER_USER_REMOVE_SUBSCRIBE_TOPIC
,
"wxy"
,
"0.tp1"
);
run
(
"REVOKE SUBSCRIBE ON tp1 FROM wxy"
);
}
// todo syncdb
...
...
source/libs/parser/test/parInitialCTest.cpp
浏览文件 @
8cafeb72
此差异已折叠。
点击以展开。
source/libs/parser/test/parInitialDTest.cpp
浏览文件 @
8cafeb72
...
...
@@ -99,7 +99,7 @@ TEST_F(ParserInitialDTest, dropDnode) {
expect
.
force
=
force
;
};
auto
setDropDnodeReqByEndpoint
=
[
&
](
const
char
*
pFqdn
,
int32_t
port
,
bool
force
=
false
)
{
auto
setDropDnodeReqByEndpoint
=
[
&
](
const
char
*
pFqdn
,
int32_t
port
=
tsServerPort
,
bool
force
=
false
)
{
strcpy
(
expect
.
fqdn
,
pFqdn
);
expect
.
port
=
port
;
expect
.
force
=
force
;
...
...
@@ -131,6 +131,14 @@ TEST_F(ParserInitialDTest, dropDnode) {
setDropDnodeReqByEndpoint
(
"host2"
,
8030
,
true
);
run
(
"DROP DNODE 'host2:8030' FORCE"
);
clearDropDnodeReq
();
setDropDnodeReqByEndpoint
(
"host1"
);
run
(
"DROP DNODE host1"
);
clearDropDnodeReq
();
setDropDnodeReqByEndpoint
(
"host2"
,
tsServerPort
,
true
);
run
(
"DROP DNODE host2 FORCE"
);
clearDropDnodeReq
();
}
// todo DROP function
...
...
@@ -174,7 +182,21 @@ TEST_F(ParserInitialDTest, dropMnode) {
TEST_F
(
ParserInitialDTest
,
dropQnode
)
{
useDb
(
"root"
,
"test"
);
run
(
"DROP qnode on dnode 1"
);
SMDropQnodeReq
expect
=
{
0
};
auto
setDropQnodeReq
=
[
&
](
int32_t
dnodeId
)
{
expect
.
dnodeId
=
dnodeId
;
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_DROP_QNODE_STMT
);
SMDropQnodeReq
req
=
{
0
};
ASSERT_TRUE
(
TSDB_CODE_SUCCESS
==
tDeserializeSCreateDropMQSNodeReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
));
ASSERT_EQ
(
req
.
dnodeId
,
expect
.
dnodeId
);
});
setDropQnodeReq
(
1
);
run
(
"DROP QNODE ON DNODE 1"
);
}
TEST_F
(
ParserInitialDTest
,
dropSnode
)
{
...
...
@@ -237,7 +259,20 @@ TEST_F(ParserInitialDTest, dropUser) {
login
(
"root"
);
useDb
(
"root"
,
"test"
);
run
(
"DROP user wxy"
);
SDropUserReq
expect
=
{
0
};
auto
setDropUserReq
=
[
&
](
const
char
*
pUser
)
{
sprintf
(
expect
.
user
,
"%s"
,
pUser
);
};
setCheckDdlFunc
([
&
](
const
SQuery
*
pQuery
,
ParserStage
stage
)
{
ASSERT_EQ
(
nodeType
(
pQuery
->
pRoot
),
QUERY_NODE_DROP_USER_STMT
);
SDropUserReq
req
=
{
0
};
ASSERT_TRUE
(
TSDB_CODE_SUCCESS
==
tDeserializeSDropUserReq
(
pQuery
->
pCmdMsg
->
pMsg
,
pQuery
->
pCmdMsg
->
msgLen
,
&
req
));
ASSERT_EQ
(
std
::
string
(
req
.
user
),
std
::
string
(
expect
.
user
));
});
setDropUserReq
(
"wxy"
);
run
(
"DROP USER wxy"
);
}
}
// namespace ParserTest
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录