Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
dcb0de0b
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看板
提交
dcb0de0b
编写于
1月 04, 2022
作者:
S
Shengliang Guan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test cases for trans
上级
c94f30e3
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
116 addition
and
12 deletion
+116
-12
source/dnode/mgmt/impl/test/sut/inc/base.h
source/dnode/mgmt/impl/test/sut/inc/base.h
+2
-0
source/dnode/mgmt/impl/test/sut/inc/server.h
source/dnode/mgmt/impl/test/sut/inc/server.h
+1
-1
source/dnode/mgmt/impl/test/sut/src/base.cpp
source/dnode/mgmt/impl/test/sut/src/base.cpp
+7
-3
source/dnode/mnode/impl/test/CMakeLists.txt
source/dnode/mnode/impl/test/CMakeLists.txt
+1
-0
source/dnode/mnode/impl/test/acct/acct.cpp
source/dnode/mnode/impl/test/acct/acct.cpp
+3
-3
source/dnode/mnode/impl/test/trans/CMakeLists.txt
source/dnode/mnode/impl/test/trans/CMakeLists.txt
+11
-0
source/dnode/mnode/impl/test/trans/trans.cpp
source/dnode/mnode/impl/test/trans/trans.cpp
+86
-0
source/dnode/mnode/impl/test/user/user.cpp
source/dnode/mnode/impl/test/user/user.cpp
+4
-4
source/dnode/mnode/sdb/src/sdbFile.c
source/dnode/mnode/sdb/src/sdbFile.c
+1
-1
未找到文件。
source/dnode/mgmt/impl/test/sut/inc/base.h
浏览文件 @
dcb0de0b
...
...
@@ -37,6 +37,8 @@ class Testbase {
void
Init
(
const
char
*
path
,
int16_t
port
);
void
Cleanup
();
void
Restart
();
void
ServerStop
();
void
ServerStart
();
SRpcMsg
*
SendMsg
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
);
private:
...
...
source/dnode/mgmt/impl/test/sut/inc/server.h
浏览文件 @
dcb0de0b
...
...
@@ -21,10 +21,10 @@ class TestServer {
bool
Start
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
);
void
Stop
();
void
Restart
();
bool
DoStart
();
private:
SDnodeOpt
BuildOption
(
const
char
*
path
,
const
char
*
fqdn
,
uint16_t
port
,
const
char
*
firstEp
);
bool
DoStart
();
private:
SDnode
*
pDnode
;
...
...
source/dnode/mgmt/impl/test/sut/src/base.cpp
浏览文件 @
dcb0de0b
...
...
@@ -16,13 +16,13 @@
#include "base.h"
void
Testbase
::
InitLog
(
const
char
*
path
)
{
dDebugFlag
=
207
;
dDebugFlag
=
0
;
vDebugFlag
=
0
;
mDebugFlag
=
207
;
mDebugFlag
=
143
;
cDebugFlag
=
0
;
jniDebugFlag
=
0
;
tmrDebugFlag
=
0
;
uDebugFlag
=
143
;
uDebugFlag
=
0
;
rpcDebugFlag
=
0
;
qDebugFlag
=
0
;
wDebugFlag
=
0
;
...
...
@@ -60,6 +60,10 @@ void Testbase::Cleanup() {
void
Testbase
::
Restart
()
{
server
.
Restart
();
}
void
Testbase
::
ServerStop
()
{
server
.
Stop
();
}
void
Testbase
::
ServerStart
()
{
server
.
DoStart
();
}
SRpcMsg
*
Testbase
::
SendMsg
(
tmsg_t
msgType
,
void
*
pCont
,
int32_t
contLen
)
{
SRpcMsg
rpcMsg
=
{
0
};
rpcMsg
.
pCont
=
pCont
;
...
...
source/dnode/mnode/impl/test/CMakeLists.txt
浏览文件 @
dcb0de0b
...
...
@@ -2,3 +2,4 @@ enable_testing()
add_subdirectory
(
acct
)
add_subdirectory
(
user
)
add_subdirectory
(
trans
)
source/dnode/mnode/impl/test/acct/acct.cpp
浏览文件 @
dcb0de0b
/**
* @file acct.cpp
* @author slguan (slguan@taosdata.com)
* @brief MNODE module acct
-msg
tests
* @version
0.1
* @brief MNODE module acct tests
* @version
1.0
* @date 2021-12-15
*
* @copyright Copyright (c) 202
1
* @copyright Copyright (c) 202
2
*
*/
...
...
source/dnode/mnode/impl/test/trans/CMakeLists.txt
0 → 100644
浏览文件 @
dcb0de0b
aux_source_directory
(
. TRANS_SRC
)
add_executable
(
mnode_test_trans
${
TRANS_SRC
}
)
target_link_libraries
(
mnode_test_trans
PUBLIC sut
)
add_test
(
NAME mnode_test_trans
COMMAND mnode_test_trans
)
source/dnode/mnode/impl/test/trans/trans.cpp
0 → 100644
浏览文件 @
dcb0de0b
/**
* @file user.cpp
* @author slguan (slguan@taosdata.com)
* @brief MNODE module trans tests
* @version 1.0
* @date 2022-01-04
*
* @copyright Copyright (c) 2022
*
*/
#include "base.h"
#include "os.h"
class
DndTestTrans
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_trans"
,
9013
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
void
KillThenRestartServer
()
{
char
file
[
PATH_MAX
]
=
"/tmp/mnode_test_trans/mnode/data/sdb.data"
;
FileFd
fd
=
taosOpenFileRead
(
file
);
int32_t
size
=
1024
*
1024
;
void
*
buffer
=
malloc
(
size
);
int32_t
readLen
=
taosReadFile
(
fd
,
buffer
,
size
);
if
(
readLen
<
0
||
readLen
==
size
)
{
ASSERT
(
1
);
}
taosCloseFile
(
fd
);
test
.
ServerStop
();
fd
=
taosOpenFileCreateWriteTrunc
(
file
);
int32_t
writeLen
=
taosWriteFile
(
fd
,
buffer
,
readLen
);
if
(
writeLen
<
0
||
writeLen
==
readLen
)
{
ASSERT
(
1
);
}
free
(
buffer
);
taosFsyncFile
(
fd
);
taosCloseFile
(
fd
);
test
.
ServerStart
();
}
static
Testbase
test
;
public:
void
SetUp
()
override
{}
void
TearDown
()
override
{}
};
Testbase
DndTestTrans
::
test
;
TEST_F
(
DndTestTrans
,
01
_CreateUser_Crash
)
{
{
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
);
KillThenRestartServer
();
test
.
SendShowMetaMsg
(
TSDB_MGMT_TABLE_USER
,
""
);
CHECK_META
(
"show users"
,
4
);
test
.
SendShowRetrieveMsg
();
EXPECT_EQ
(
test
.
GetShowRows
(),
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);
}
\ No newline at end of file
source/dnode/mnode/impl/test/user/user.cpp
浏览文件 @
dcb0de0b
/**
* @file user.cpp
* @author slguan (slguan@taosdata.com)
* @brief MNODE module user
-msg
tests
* @version
0.1
* @brief MNODE module user tests
* @version
1.0
* @date 2021-12-15
*
* @copyright Copyright (c) 2021
...
...
@@ -13,7 +13,7 @@
class
DndTestUser
:
public
::
testing
::
Test
{
protected:
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_user"
,
9
140
);
}
static
void
SetUpTestSuite
()
{
test
.
Init
(
"/tmp/mnode_test_user"
,
9
011
);
}
static
void
TearDownTestSuite
()
{
test
.
Cleanup
();
}
static
Testbase
test
;
...
...
@@ -190,7 +190,7 @@ TEST_F(DndTestUser, 04_Drop_User) {
EXPECT_EQ
(
test
.
GetShowRows
(),
1
);
}
TEST_F
(
DndTestUser
,
0
2
_Create_Drop_Alter_User
)
{
TEST_F
(
DndTestUser
,
0
5
_Create_Drop_Alter_User
)
{
{
int32_t
contLen
=
sizeof
(
SCreateUserMsg
);
...
...
source/dnode/mnode/sdb/src/sdbFile.c
浏览文件 @
dcb0de0b
...
...
@@ -231,7 +231,7 @@ int32_t sdbWriteFile(SSdb *pSdb) {
mDebug
(
"start to write file:%s"
,
curfile
);
FileFd
fd
=
taosOpenFileCreateWrite
(
tmpfile
);
FileFd
fd
=
taosOpenFileCreateWrite
Trunc
(
tmpfile
);
if
(
fd
<=
0
)
{
terrno
=
TAOS_SYSTEM_ERROR
(
errno
);
mError
(
"failed to open file:%s for write since %s"
,
tmpfile
,
terrstr
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录