Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
taosdata
TDengine
提交
f8921199
TDengine
项目概览
taosdata
/
TDengine
1 年多 前同步成功
通知
1185
Star
22016
Fork
4786
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
TDengine
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
f8921199
编写于
6月 28, 2023
作者:
M
Minglei Jin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
tdb/test: cases for ofp recycling
上级
4d021995
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
89 addition
and
16 deletion
+89
-16
source/libs/tdb/test/tdbPageRecycleTest.cpp
source/libs/tdb/test/tdbPageRecycleTest.cpp
+89
-16
未找到文件。
source/libs/tdb/test/tdbPageRecycleTest.cpp
浏览文件 @
f8921199
...
@@ -120,16 +120,6 @@ static int tDefaultKeyCmpr(const void *pKey1, int keyLen1, const void *pKey2, in
...
@@ -120,16 +120,6 @@ static int tDefaultKeyCmpr(const void *pKey1, int keyLen1, const void *pKey2, in
return
cret
;
return
cret
;
}
}
static
void
generateBigVal
(
char
*
val
,
int
valLen
)
{
for
(
int
i
=
0
;
i
<
valLen
;
++
i
)
{
char
c
=
char
(
i
&
0xff
);
if
(
c
==
0
)
{
c
=
1
;
}
val
[
i
]
=
c
;
}
}
static
TDB
*
openEnv
(
char
const
*
envName
,
int
const
pageSize
,
int
const
pageNum
)
{
static
TDB
*
openEnv
(
char
const
*
envName
,
int
const
pageSize
,
int
const
pageNum
)
{
TDB
*
pEnv
=
NULL
;
TDB
*
pEnv
=
NULL
;
...
@@ -141,11 +131,19 @@ static TDB *openEnv(char const *envName, int const pageSize, int const pageNum)
...
@@ -141,11 +131,19 @@ static TDB *openEnv(char const *envName, int const pageSize, int const pageNum)
return
pEnv
;
return
pEnv
;
}
}
static
void
generateBigVal
(
char
*
val
,
int
valLen
)
{
for
(
int
i
=
0
;
i
<
valLen
;
++
i
)
{
char
c
=
char
(
i
&
0xff
);
if
(
c
==
0
)
{
c
=
1
;
}
val
[
i
]
=
c
;
}
}
static
void
insertOfp
(
void
)
{
static
void
insertOfp
(
void
)
{
int
ret
=
0
;
int
ret
=
0
;
taosRemoveDir
(
"tdb"
);
// open Env
// open Env
int
const
pageSize
=
4096
;
int
const
pageSize
=
4096
;
int
const
pageNum
=
64
;
int
const
pageNum
=
64
;
...
@@ -156,7 +154,7 @@ static void insertOfp(void) {
...
@@ -156,7 +154,7 @@ static void insertOfp(void) {
TTB
*
pDb
=
NULL
;
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
=
tKeyCmpr
;
tdb_cmpr_fn_t
compFunc
=
tKeyCmpr
;
// ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb, 0);
// ret = tdbTbOpen("ofp_insert.db", -1, -1, compFunc, pEnv, &pDb, 0);
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
12
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// open the pool
// open the pool
...
@@ -176,22 +174,35 @@ static void insertOfp(void) {
...
@@ -176,22 +174,35 @@ static void insertOfp(void) {
// insert the generated big data
// insert the generated big data
// char const *key = "key1";
// char const *key = "key1";
char
const
*
key
=
"key123456789"
;
char
const
*
key
=
"key123456789"
;
ret
=
tdbTbInsert
(
pDb
,
key
,
strlen
(
key
),
val
,
valLen
,
txn
);
ret
=
tdbTbInsert
(
pDb
,
key
,
strlen
(
key
)
+
1
,
val
,
valLen
,
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// commit current transaction
// commit current transaction
tdbCommit
(
pEnv
,
txn
);
tdbCommit
(
pEnv
,
txn
);
tdbPostCommit
(
pEnv
,
txn
);
tdbPostCommit
(
pEnv
,
txn
);
closePool
(
pPool
);
// Close a database
tdbTbClose
(
pDb
);
// Close Env
ret
=
tdbClose
(
pEnv
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
}
static
void
clearDb
(
char
const
*
db
)
{
taosRemoveDir
(
db
);
}
TEST
(
TdbPageRecycleTest
,
DISABLED_TbInsertTest
)
{
TEST
(
TdbPageRecycleTest
,
DISABLED_TbInsertTest
)
{
// TEST(TdbPageRecycleTest, TbInsertTest) {
// TEST(TdbPageRecycleTest, TbInsertTest) {
// ofp inserting
// ofp inserting
clearDb
(
"tdb"
);
insertOfp
();
insertOfp
();
}
}
TEST
(
TdbPageRecycleTest
,
DISABLED_TbGetTest
)
{
TEST
(
TdbPageRecycleTest
,
DISABLED_TbGetTest
)
{
// TEST(TdbPageRecycleTest, TbGetTest) {
// TEST(TdbPageRecycleTest, TbGetTest) {
clearDb
(
"tdb"
);
insertOfp
();
insertOfp
();
// open Env
// open Env
...
@@ -464,8 +475,6 @@ TEST(TdbPageRecycleTest, DISABLED_simple_insert1) {
...
@@ -464,8 +475,6 @@ TEST(TdbPageRecycleTest, DISABLED_simple_insert1) {
GTEST_ASSERT_EQ
(
ret
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
}
static
void
clearDb
(
char
const
*
db
)
{
taosRemoveDir
(
db
);
}
static
void
insertDb
(
int
nData
)
{
static
void
insertDb
(
int
nData
)
{
int
ret
=
0
;
int
ret
=
0
;
TDB
*
pEnv
=
NULL
;
TDB
*
pEnv
=
NULL
;
...
@@ -617,3 +626,67 @@ TEST(TdbPageRecycleTest, seq_delete) { deleteDb(nDataConst); }
...
@@ -617,3 +626,67 @@ TEST(TdbPageRecycleTest, seq_delete) { deleteDb(nDataConst); }
// TEST(TdbPageRecycleTest, DISABLED_recycly_insert) {
// TEST(TdbPageRecycleTest, DISABLED_recycly_insert) {
TEST
(
TdbPageRecycleTest
,
recycly_insert
)
{
insertDb
(
nDataConst
);
}
TEST
(
TdbPageRecycleTest
,
recycly_insert
)
{
insertDb
(
nDataConst
);
}
// TEST(TdbPageRecycleTest, DISABLED_recycly_seq_insert_ofp) {
TEST
(
TdbPageRecycleTest
,
recycly_seq_insert_ofp
)
{
clearDb
(
"tdb"
);
insertOfp
();
system
(
"ls -l ./tdb"
);
}
static
void
deleteOfp
(
void
)
{
// open Env
int
ret
=
0
;
int
const
pageSize
=
4096
;
int
const
pageNum
=
64
;
TDB
*
pEnv
=
openEnv
(
"tdb"
,
pageSize
,
pageNum
);
GTEST_ASSERT_NE
(
pEnv
,
nullptr
);
// open db
TTB
*
pDb
=
NULL
;
tdb_cmpr_fn_t
compFunc
=
tKeyCmpr
;
ret
=
tdbTbOpen
(
"ofp_insert.db"
,
-
1
,
-
1
,
compFunc
,
pEnv
,
&
pDb
,
0
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// open the pool
SPoolMem
*
pPool
=
openPool
();
// start a transaction
TXN
*
txn
;
tdbBegin
(
pEnv
,
&
txn
,
poolMalloc
,
poolFree
,
pPool
,
TDB_TXN_WRITE
|
TDB_TXN_READ_UNCOMMITTED
);
{
// delete the data
char
const
*
key
=
"key123456789"
;
ret
=
tdbTbDelete
(
pDb
,
key
,
strlen
(
key
)
+
1
,
txn
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
// commit current transaction
tdbCommit
(
pEnv
,
txn
);
tdbPostCommit
(
pEnv
,
txn
);
closePool
(
pPool
);
ret
=
tdbTbDrop
(
pDb
);
GTEST_ASSERT_EQ
(
ret
,
0
);
// Close a database
tdbTbClose
(
pDb
);
// Close Env
ret
=
tdbClose
(
pEnv
);
GTEST_ASSERT_EQ
(
ret
,
0
);
}
// TEST(TdbPageRecycleTest, DISABLED_seq_delete_ofp) {
TEST
(
TdbPageRecycleTest
,
seq_delete_ofp
)
{
deleteOfp
();
system
(
"ls -l ./tdb"
);
}
// TEST(TdbPageRecycleTest, DISABLED_recycly_seq_insert_ofp_again) {
TEST
(
TdbPageRecycleTest
,
recycly_seq_insert_ofp_again
)
{
insertOfp
();
system
(
"ls -l ./tdb"
);
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录