Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
apache
Incubator Pegasus
提交
be2c6c2e
Incubator Pegasus
项目概览
apache
/
Incubator Pegasus
通知
9
Star
5
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Incubator Pegasus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
未验证
提交
be2c6c2e
编写于
10月 15, 2020
作者:
S
Smilencer
提交者:
GitHub
10月 15, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix: fix unit test of capacity_unit_calculator (#619)
上级
10da73af
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
23 deletion
+27
-23
rdsn
rdsn
+1
-1
src/server/test/capacity_unit_calculator_test.cpp
src/server/test/capacity_unit_calculator_test.cpp
+26
-22
未找到文件。
rdsn
@
91f9f4e4
比较
ccecd599
...
91f9f4e4
Subproject commit
ccecd5996a7b5c5b3281860186b30048a2ee4763
Subproject commit
91f9f4e4dc15f80de628820acf994f74a295ffee
src/server/test/capacity_unit_calculator_test.cpp
浏览文件 @
be2c6c2e
...
...
@@ -6,6 +6,7 @@
#include "server/capacity_unit_calculator.h"
#include <dsn/dist/replication/replica_base.h>
#include "pegasus_key_schema.h"
#include "server/hotkey_collector.h"
namespace
pegasus
{
...
...
@@ -50,11 +51,13 @@ protected:
std
::
unique_ptr
<
mock_capacity_unit_calculator
>
_cal
;
public:
const
dsn
::
blob
key
=
dsn
::
blob
::
create_from_bytes
(
"key"
)
;
dsn
::
blob
key
,
hash_key
;
capacity_unit_calculator_test
()
:
pegasus_server_test_base
()
{
_cal
=
dsn
::
make_unique
<
mock_capacity_unit_calculator
>
(
_server
.
get
());
pegasus_generate_key
(
key
,
dsn
::
blob
::
create_from_bytes
(
"h"
),
dsn
::
blob
());
hash_key
=
dsn
::
blob
::
create_from_bytes
(
"key"
);
}
void
test_init
()
...
...
@@ -142,26 +145,26 @@ TEST_F(capacity_unit_calculator_test, multi_get)
std
::
vector
<::
dsn
::
apps
::
key_value
>
kvs
;
generate_n_kvs
(
100
,
kvs
);
_cal
->
add_multi_get_cu
(
rocksdb
::
Status
::
kIncomplete
,
key
,
kvs
);
_cal
->
add_multi_get_cu
(
rocksdb
::
Status
::
kIncomplete
,
hash_
key
,
kvs
);
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
_cal
->
reset
();
generate_n_kvs
(
500
,
kvs
);
_cal
->
add_multi_get_cu
(
rocksdb
::
Status
::
kOk
,
key
,
kvs
);
_cal
->
add_multi_get_cu
(
rocksdb
::
Status
::
kOk
,
hash_
key
,
kvs
);
ASSERT_GT
(
_cal
->
read_cu
,
1
);
ASSERT_EQ
(
_cal
->
write_cu
,
0
);
_cal
->
reset
();
kvs
.
clear
();
_cal
->
add_multi_get_cu
(
rocksdb
::
Status
::
kNotFound
,
key
,
kvs
);
_cal
->
add_multi_get_cu
(
rocksdb
::
Status
::
kNotFound
,
hash_
key
,
kvs
);
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
_cal
->
reset
();
_cal
->
add_multi_get_cu
(
rocksdb
::
Status
::
kInvalidArgument
,
key
,
kvs
);
_cal
->
add_multi_get_cu
(
rocksdb
::
Status
::
kInvalidArgument
,
hash_
key
,
kvs
);
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
_cal
->
reset
();
_cal
->
add_multi_get_cu
(
rocksdb
::
Status
::
kCorruption
,
key
,
kvs
);
_cal
->
add_multi_get_cu
(
rocksdb
::
Status
::
kCorruption
,
hash_
key
,
kvs
);
ASSERT_EQ
(
_cal
->
read_cu
,
0
);
_cal
->
reset
();
}
...
...
@@ -202,7 +205,7 @@ TEST_F(capacity_unit_calculator_test, scan)
TEST_F
(
capacity_unit_calculator_test
,
sortkey_count
)
{
for
(
int
i
=
0
;
i
<
MAX_ROCKSDB_STATUS_CODE
;
i
++
)
{
_cal
->
add_sortkey_count_cu
(
i
,
key
);
_cal
->
add_sortkey_count_cu
(
i
,
hash_
key
);
if
(
i
==
rocksdb
::
Status
::
kOk
||
i
==
rocksdb
::
Status
::
kNotFound
)
{
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
}
else
{
...
...
@@ -260,13 +263,13 @@ TEST_F(capacity_unit_calculator_test, multi_put)
std
::
vector
<::
dsn
::
apps
::
key_value
>
kvs
;
generate_n_kvs
(
100
,
kvs
);
_cal
->
add_multi_put_cu
(
rocksdb
::
Status
::
kOk
,
key
,
kvs
);
_cal
->
add_multi_put_cu
(
rocksdb
::
Status
::
kOk
,
hash_
key
,
kvs
);
ASSERT_EQ
(
_cal
->
write_cu
,
1
);
_cal
->
reset
();
generate_n_kvs
(
500
,
kvs
);
for
(
int
i
=
0
;
i
<
MAX_ROCKSDB_STATUS_CODE
;
i
++
)
{
_cal
->
add_multi_put_cu
(
i
,
key
,
kvs
);
_cal
->
add_multi_put_cu
(
i
,
hash_
key
,
kvs
);
if
(
i
==
rocksdb
::
Status
::
kOk
)
{
ASSERT_GT
(
_cal
->
write_cu
,
1
);
}
else
{
...
...
@@ -282,13 +285,13 @@ TEST_F(capacity_unit_calculator_test, multi_remove)
std
::
vector
<::
dsn
::
blob
>
keys
;
generate_n_keys
(
100
,
keys
);
_cal
->
add_multi_remove_cu
(
rocksdb
::
Status
::
kOk
,
key
,
keys
);
_cal
->
add_multi_remove_cu
(
rocksdb
::
Status
::
kOk
,
hash_
key
,
keys
);
ASSERT_EQ
(
_cal
->
write_cu
,
1
);
_cal
->
reset
();
generate_n_keys
(
1000
,
keys
);
for
(
int
i
=
0
;
i
<
MAX_ROCKSDB_STATUS_CODE
;
i
++
)
{
_cal
->
add_multi_remove_cu
(
i
,
key
,
keys
);
_cal
->
add_multi_remove_cu
(
i
,
hash_
key
,
keys
);
if
(
i
==
rocksdb
::
Status
::
kOk
)
{
ASSERT_GT
(
_cal
->
write_cu
,
1
);
}
else
{
...
...
@@ -319,30 +322,31 @@ TEST_F(capacity_unit_calculator_test, incr)
TEST_F
(
capacity_unit_calculator_test
,
check_and_set
)
{
dsn
::
blob
hash_key
=
dsn
::
blob
::
create_from_bytes
(
"hash_key"
);
dsn
::
blob
cas_
hash_key
=
dsn
::
blob
::
create_from_bytes
(
"hash_key"
);
dsn
::
blob
check_sort_key
=
dsn
::
blob
::
create_from_bytes
(
"check_sort_key"
);
dsn
::
blob
set_sort_key
=
dsn
::
blob
::
create_from_bytes
(
"set_sort_key"
);
dsn
::
blob
value
=
dsn
::
blob
::
create_from_bytes
(
"value"
);
_cal
->
add_check_and_set_cu
(
rocksdb
::
Status
::
kOk
,
hash_key
,
check_sort_key
,
set_sort_key
,
value
);
_cal
->
add_check_and_set_cu
(
rocksdb
::
Status
::
kOk
,
cas_hash_key
,
check_sort_key
,
set_sort_key
,
value
);
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
ASSERT_EQ
(
_cal
->
write_cu
,
1
);
_cal
->
reset
();
_cal
->
add_check_and_set_cu
(
rocksdb
::
Status
::
kInvalidArgument
,
hash_key
,
check_sort_key
,
set_sort_key
,
value
);
rocksdb
::
Status
::
kInvalidArgument
,
cas_
hash_key
,
check_sort_key
,
set_sort_key
,
value
);
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
ASSERT_EQ
(
_cal
->
write_cu
,
0
);
_cal
->
reset
();
_cal
->
add_check_and_set_cu
(
rocksdb
::
Status
::
kTryAgain
,
hash_key
,
check_sort_key
,
set_sort_key
,
value
);
rocksdb
::
Status
::
kTryAgain
,
cas_
hash_key
,
check_sort_key
,
set_sort_key
,
value
);
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
ASSERT_EQ
(
_cal
->
write_cu
,
0
);
_cal
->
reset
();
_cal
->
add_check_and_set_cu
(
rocksdb
::
Status
::
kCorruption
,
hash_key
,
check_sort_key
,
set_sort_key
,
value
);
rocksdb
::
Status
::
kCorruption
,
cas_
hash_key
,
check_sort_key
,
set_sort_key
,
value
);
ASSERT_EQ
(
_cal
->
read_cu
,
0
);
ASSERT_EQ
(
_cal
->
write_cu
,
0
);
_cal
->
reset
();
...
...
@@ -350,36 +354,36 @@ TEST_F(capacity_unit_calculator_test, check_and_set)
TEST_F
(
capacity_unit_calculator_test
,
check_and_mutate
)
{
dsn
::
blob
hash_key
=
dsn
::
blob
::
create_from_bytes
(
"hash_key"
);
dsn
::
blob
cam_
hash_key
=
dsn
::
blob
::
create_from_bytes
(
"hash_key"
);
dsn
::
blob
check_sort_key
=
dsn
::
blob
::
create_from_bytes
(
"check_sort_key"
);
std
::
vector
<::
dsn
::
apps
::
mutate
>
mutate_list
;
generate_n_mutates
(
100
,
mutate_list
);
_cal
->
add_check_and_mutate_cu
(
rocksdb
::
Status
::
kOk
,
hash_key
,
check_sort_key
,
mutate_list
);
_cal
->
add_check_and_mutate_cu
(
rocksdb
::
Status
::
kOk
,
cam_
hash_key
,
check_sort_key
,
mutate_list
);
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
ASSERT_EQ
(
_cal
->
write_cu
,
1
);
_cal
->
reset
();
generate_n_mutates
(
1000
,
mutate_list
);
_cal
->
add_check_and_mutate_cu
(
rocksdb
::
Status
::
kOk
,
hash_key
,
check_sort_key
,
mutate_list
);
_cal
->
add_check_and_mutate_cu
(
rocksdb
::
Status
::
kOk
,
cam_
hash_key
,
check_sort_key
,
mutate_list
);
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
ASSERT_GT
(
_cal
->
write_cu
,
1
);
_cal
->
reset
();
_cal
->
add_check_and_mutate_cu
(
rocksdb
::
Status
::
kInvalidArgument
,
hash_key
,
check_sort_key
,
mutate_list
);
rocksdb
::
Status
::
kInvalidArgument
,
cam_
hash_key
,
check_sort_key
,
mutate_list
);
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
ASSERT_EQ
(
_cal
->
write_cu
,
0
);
_cal
->
reset
();
_cal
->
add_check_and_mutate_cu
(
rocksdb
::
Status
::
kTryAgain
,
hash_key
,
check_sort_key
,
mutate_list
);
rocksdb
::
Status
::
kTryAgain
,
cam_
hash_key
,
check_sort_key
,
mutate_list
);
ASSERT_EQ
(
_cal
->
read_cu
,
1
);
ASSERT_EQ
(
_cal
->
write_cu
,
0
);
_cal
->
reset
();
_cal
->
add_check_and_mutate_cu
(
rocksdb
::
Status
::
kCorruption
,
hash_key
,
check_sort_key
,
mutate_list
);
rocksdb
::
Status
::
kCorruption
,
cam_
hash_key
,
check_sort_key
,
mutate_list
);
ASSERT_EQ
(
_cal
->
read_cu
,
0
);
ASSERT_EQ
(
_cal
->
write_cu
,
0
);
_cal
->
reset
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录