Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
c402a6e3
milvus
项目概览
BaiXuePrincess
/
milvus
与 Fork 源项目一致
从无法访问的项目Fork
通知
7
Star
4
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
milvus
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
c402a6e3
编写于
9月 11, 2019
作者:
G
groot
浏览文件
操作
浏览文件
下载
差异文件
refine unittest code
Former-commit-id: f7219774edc8f0a0af8f997bcadf36a6d3c95353
上级
c2949d16
ef3daec8
变更
16
隐藏空白更改
内联
并排
Showing
16 changed file
with
113 addition
and
82 deletion
+113
-82
cpp/src/utils/LogUtil.cpp
cpp/src/utils/LogUtil.cpp
+2
-2
cpp/src/utils/LogUtil.h
cpp/src/utils/LogUtil.h
+1
-0
cpp/unittest/knowhere/knowhere_test.cpp
cpp/unittest/knowhere/knowhere_test.cpp
+6
-6
cpp/unittest/metrics/metrics_test.cpp
cpp/unittest/metrics/metrics_test.cpp
+2
-2
cpp/unittest/scheduler/algorithm_test.cpp
cpp/unittest/scheduler/algorithm_test.cpp
+1
-1
cpp/unittest/scheduler/event_test.cpp
cpp/unittest/scheduler/event_test.cpp
+4
-4
cpp/unittest/scheduler/node_test.cpp
cpp/unittest/scheduler/node_test.cpp
+4
-4
cpp/unittest/scheduler/normal_test.cpp
cpp/unittest/scheduler/normal_test.cpp
+1
-1
cpp/unittest/scheduler/resource_factory_test.cpp
cpp/unittest/scheduler/resource_factory_test.cpp
+1
-1
cpp/unittest/scheduler/resource_mgr_test.cpp
cpp/unittest/scheduler/resource_mgr_test.cpp
+16
-16
cpp/unittest/scheduler/resource_test.cpp
cpp/unittest/scheduler/resource_test.cpp
+10
-10
cpp/unittest/scheduler/schedinst_test.cpp
cpp/unittest/scheduler/schedinst_test.cpp
+1
-1
cpp/unittest/scheduler/scheduler_test.cpp
cpp/unittest/scheduler/scheduler_test.cpp
+3
-3
cpp/unittest/scheduler/task_test.cpp
cpp/unittest/scheduler/task_test.cpp
+1
-1
cpp/unittest/scheduler/tasktable_test.cpp
cpp/unittest/scheduler/tasktable_test.cpp
+30
-30
cpp/unittest/server/util_test.cpp
cpp/unittest/server/util_test.cpp
+30
-0
未找到文件。
cpp/src/utils/LogUtil.cpp
浏览文件 @
c402a6e3
...
...
@@ -27,7 +27,7 @@ static int fatal_idx = 0;
}
// TODO(yzb) : change the easylogging library to get the log level from parameter rather than filename
void
r
olloutHandler
(
const
char
*
filename
,
std
::
size_t
size
)
{
void
R
olloutHandler
(
const
char
*
filename
,
std
::
size_t
size
)
{
char
*
dirc
=
strdup
(
filename
);
char
*
basec
=
strdup
(
filename
);
char
*
dir
=
dirname
(
dirc
);
...
...
@@ -112,7 +112,7 @@ int32_t InitLog(const std::string &log_config_file) {
el
::
Loggers
::
reconfigureAllLoggers
(
conf
);
el
::
Loggers
::
addFlag
(
el
::
LoggingFlag
::
StrictLogFileSizeCheck
);
el
::
Helpers
::
installPreRollOutCallback
(
r
olloutHandler
);
el
::
Helpers
::
installPreRollOutCallback
(
R
olloutHandler
);
return
0
;
}
...
...
cpp/src/utils/LogUtil.h
浏览文件 @
c402a6e3
...
...
@@ -16,6 +16,7 @@ inline std::string GetFileName(std::string filename) {
int
pos
=
filename
.
find_last_of
(
'/'
);
return
filename
.
substr
(
pos
+
1
);
}
void
RolloutHandler
(
const
char
*
filename
,
std
::
size_t
size
);
#define SHOW_LOCATION
#ifdef SHOW_LOCATION
...
...
cpp/unittest/knowhere/knowhere_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -142,7 +142,7 @@ INSTANTIATE_TEST_CASE_P(WrapperParam, KnowhereWrapperTest,
)
);
TEST_P
(
KnowhereWrapperTest
,
base_test
)
{
TEST_P
(
KnowhereWrapperTest
,
BASE_TEST
)
{
EXPECT_EQ
(
index_
->
GetType
(),
index_type
);
auto
elems
=
nq
*
k
;
...
...
@@ -154,7 +154,7 @@ TEST_P(KnowhereWrapperTest, base_test) {
AssertResult
(
res_ids
,
res_dis
);
}
TEST_P
(
KnowhereWrapperTest
,
to_gpu_test
)
{
TEST_P
(
KnowhereWrapperTest
,
TO_GPU_TEST
)
{
EXPECT_EQ
(
index_
->
GetType
(),
index_type
);
auto
elems
=
nq
*
k
;
...
...
@@ -174,7 +174,7 @@ TEST_P(KnowhereWrapperTest, to_gpu_test) {
}
{
std
::
string
file_location
=
"/tmp/
test
_gpu_file"
;
std
::
string
file_location
=
"/tmp/
knowhere
_gpu_file"
;
write_index
(
index_
,
file_location
);
auto
new_index
=
read_index
(
file_location
);
...
...
@@ -186,11 +186,11 @@ TEST_P(KnowhereWrapperTest, to_gpu_test) {
}
}
TEST_P
(
KnowhereWrapperTest
,
to_cpu_test
)
{
TEST_P
(
KnowhereWrapperTest
,
TO_CPU_TEST
)
{
// dev
}
TEST_P
(
KnowhereWrapperTest
,
serialize
)
{
TEST_P
(
KnowhereWrapperTest
,
SERIALIZE_TEST
)
{
EXPECT_EQ
(
index_
->
GetType
(),
index_type
);
auto
elems
=
nq
*
k
;
...
...
@@ -215,7 +215,7 @@ TEST_P(KnowhereWrapperTest, serialize) {
}
{
std
::
string
file_location
=
"/tmp/
whatever
"
;
std
::
string
file_location
=
"/tmp/
knowhere
"
;
write_index
(
index_
,
file_location
);
auto
new_index
=
read_index
(
file_location
);
EXPECT_EQ
(
new_index
->
GetType
(),
ConvertToCpuIndexType
(
index_type
));
...
...
cpp/unittest/metrics/metrics_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -24,7 +24,7 @@
using
namespace
zilliz
::
milvus
;
TEST_F
(
MetricTest
,
M
etric_Tes
)
{
TEST_F
(
MetricTest
,
M
ETRIC_TEST
)
{
server
::
ConfigNode
&
configNode
=
server
::
ServerConfig
::
GetInstance
().
GetConfig
(
server
::
CONFIG_METRIC
);
configNode
.
SetValue
(
server
::
CONFIG_METRIC_COLLECTOR
,
"zabbix"
);
server
::
Metrics
::
GetInstance
();
...
...
@@ -122,7 +122,7 @@ TEST_F(MetricTest, Metric_Tes) {
delete
[]
qxb
;
};
TEST_F
(
MetricTest
,
C
ollector_Metrics_Test
){
TEST_F
(
MetricTest
,
C
OLLECTOR_METRICS_TEST
){
engine
::
Status
status
=
engine
::
Status
::
OK
();
server
::
CollectInsertMetrics
insert_metrics0
(
0
,
status
);
status
=
engine
::
Status
(
DB_ERROR
,
"error"
);
...
...
cpp/unittest/scheduler/algorithm_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -53,7 +53,7 @@ class AlgorithmTest : public testing::Test {
ResourceMgrPtr
res_mgr_
;
};
TEST_F
(
AlgorithmTest
,
S
hortestPath_test
)
{
TEST_F
(
AlgorithmTest
,
S
HORTESTPATH_TEST
)
{
std
::
vector
<
std
::
string
>
sp
;
uint64_t
cost
;
cost
=
ShortestPath
(
disk_
.
lock
(),
gpu_0_
.
lock
(),
res_mgr_
,
sp
);
...
...
cpp/unittest/scheduler/event_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -15,7 +15,7 @@ namespace zilliz {
namespace
milvus
{
namespace
engine
{
TEST
(
EventTest
,
start_up_event
)
{
TEST
(
EventTest
,
START_UP_EVENT
)
{
ResourceWPtr
res
(
ResourcePtr
(
nullptr
));
auto
event
=
std
::
make_shared
<
StartUpEvent
>
(
res
);
ASSERT_FALSE
(
event
->
Dump
().
empty
());
...
...
@@ -23,7 +23,7 @@ TEST(EventTest, start_up_event) {
std
::
cout
<<
*
EventPtr
(
event
);
}
TEST
(
EventTest
,
load_completed_event
)
{
TEST
(
EventTest
,
LOAD_COMPLETED_EVENT
)
{
ResourceWPtr
res
(
ResourcePtr
(
nullptr
));
auto
event
=
std
::
make_shared
<
LoadCompletedEvent
>
(
res
,
nullptr
);
ASSERT_FALSE
(
event
->
Dump
().
empty
());
...
...
@@ -31,7 +31,7 @@ TEST(EventTest, load_completed_event) {
std
::
cout
<<
*
EventPtr
(
event
);
}
TEST
(
EventTest
,
finish_task_event
)
{
TEST
(
EventTest
,
FINISH_TASK_EVENT
)
{
ResourceWPtr
res
(
ResourcePtr
(
nullptr
));
auto
event
=
std
::
make_shared
<
FinishTaskEvent
>
(
res
,
nullptr
);
ASSERT_FALSE
(
event
->
Dump
().
empty
());
...
...
@@ -40,7 +40,7 @@ TEST(EventTest, finish_task_event) {
}
TEST
(
EventTest
,
tasktable_updated_event
)
{
TEST
(
EventTest
,
TASKTABLE_UPDATED_EVENT
)
{
ResourceWPtr
res
(
ResourcePtr
(
nullptr
));
auto
event
=
std
::
make_shared
<
TaskTableUpdatedEvent
>
(
res
);
ASSERT_FALSE
(
event
->
Dump
().
empty
());
...
...
cpp/unittest/scheduler/node_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -28,7 +28,7 @@ protected:
NodePtr
isolated_node2_
;
};
TEST_F
(
NodeTest
,
add_neighbour
)
{
TEST_F
(
NodeTest
,
ADD_NEIGHBOUR
)
{
ASSERT_EQ
(
isolated_node1_
->
GetNeighbours
().
size
(),
0
);
ASSERT_EQ
(
isolated_node2_
->
GetNeighbours
().
size
(),
0
);
auto
pcie
=
Connection
(
"PCIe"
,
11.0
);
...
...
@@ -37,7 +37,7 @@ TEST_F(NodeTest, add_neighbour) {
ASSERT_EQ
(
isolated_node2_
->
GetNeighbours
().
size
(),
0
);
}
TEST_F
(
NodeTest
,
repeat_add_neighbour
)
{
TEST_F
(
NodeTest
,
REPEAT_ADD_NEIGHBOUR
)
{
ASSERT_EQ
(
isolated_node1_
->
GetNeighbours
().
size
(),
0
);
ASSERT_EQ
(
isolated_node2_
->
GetNeighbours
().
size
(),
0
);
auto
pcie
=
Connection
(
"PCIe"
,
11.0
);
...
...
@@ -47,7 +47,7 @@ TEST_F(NodeTest, repeat_add_neighbour) {
ASSERT_EQ
(
isolated_node2_
->
GetNeighbours
().
size
(),
0
);
}
TEST_F
(
NodeTest
,
get_neighbours
)
{
TEST_F
(
NodeTest
,
GET_NEIGHBOURS
)
{
{
bool
n2
=
false
,
n3
=
false
;
auto
node1_neighbours
=
node1_
->
GetNeighbours
();
...
...
@@ -72,7 +72,7 @@ TEST_F(NodeTest, get_neighbours) {
}
}
TEST_F
(
NodeTest
,
dump
)
{
TEST_F
(
NodeTest
,
DUMP
)
{
std
::
cout
<<
node1_
->
Dump
();
ASSERT_FALSE
(
node1_
->
Dump
().
empty
());
...
...
cpp/unittest/scheduler/normal_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -11,7 +11,7 @@
using
namespace
zilliz
::
milvus
::
engine
;
TEST
(
normal_test
,
inst_test
)
{
TEST
(
NormalTest
,
INST_TEST
)
{
// ResourceMgr only compose resources, provide unified event
auto
res_mgr
=
ResMgrInst
::
GetInstance
();
...
...
cpp/unittest/scheduler/resource_factory_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -4,7 +4,7 @@
using
namespace
zilliz
::
milvus
::
engine
;
TEST
(
resource_factory_test
,
create
)
{
TEST
(
ResourceFactoryTest
,
CREATE
)
{
auto
disk
=
ResourceFactory
::
Create
(
"ssd"
,
"DISK"
,
0
);
auto
cpu
=
ResourceFactory
::
Create
(
"cpu"
,
"CPU"
,
0
);
auto
gpu
=
ResourceFactory
::
Create
(
"gpu"
,
"GPU"
,
0
);
...
...
cpp/unittest/scheduler/resource_mgr_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -44,19 +44,19 @@ protected:
ResourcePtr
gpu_res
;
};
TEST_F
(
ResourceMgrBaseTest
,
add
)
{
TEST_F
(
ResourceMgrBaseTest
,
ADD
)
{
auto
resource
=
std
::
make_shared
<
TestResource
>
(
"test"
,
0
,
true
,
true
);
auto
ret
=
empty_mgr_
->
Add
(
ResourcePtr
(
resource
));
ASSERT_EQ
(
ret
.
lock
(),
resource
);
}
TEST_F
(
ResourceMgrBaseTest
,
add_disk
)
{
TEST_F
(
ResourceMgrBaseTest
,
ADD_DISK
)
{
auto
resource
=
std
::
make_shared
<
DiskResource
>
(
"disk"
,
0
,
true
,
true
);
auto
ret
=
empty_mgr_
->
Add
(
ResourcePtr
(
resource
));
ASSERT_EQ
(
ret
.
lock
(),
resource
);
}
TEST_F
(
ResourceMgrBaseTest
,
connect
)
{
TEST_F
(
ResourceMgrBaseTest
,
CONNECT
)
{
auto
resource1
=
std
::
make_shared
<
TestResource
>
(
"resource1"
,
0
,
true
,
true
);
auto
resource2
=
std
::
make_shared
<
TestResource
>
(
"resource2"
,
2
,
true
,
true
);
empty_mgr_
->
Add
(
resource1
);
...
...
@@ -66,7 +66,7 @@ TEST_F(ResourceMgrBaseTest, connect) {
}
TEST_F
(
ResourceMgrBaseTest
,
invalid_connect
)
{
TEST_F
(
ResourceMgrBaseTest
,
INVALID_CONNECT
)
{
auto
resource1
=
std
::
make_shared
<
TestResource
>
(
"resource1"
,
0
,
true
,
true
);
auto
resource2
=
std
::
make_shared
<
TestResource
>
(
"resource2"
,
2
,
true
,
true
);
empty_mgr_
->
Add
(
resource1
);
...
...
@@ -76,19 +76,19 @@ TEST_F(ResourceMgrBaseTest, invalid_connect) {
}
TEST_F
(
ResourceMgrBaseTest
,
clear
)
{
TEST_F
(
ResourceMgrBaseTest
,
CLEAR
)
{
ASSERT_EQ
(
mgr1_
->
GetNumOfResource
(),
3
);
mgr1_
->
Clear
();
ASSERT_EQ
(
mgr1_
->
GetNumOfResource
(),
0
);
}
TEST_F
(
ResourceMgrBaseTest
,
get_disk_resources
)
{
TEST_F
(
ResourceMgrBaseTest
,
GET_DISK_RESOURCES
)
{
auto
disks
=
mgr1_
->
GetDiskResources
();
ASSERT_EQ
(
disks
.
size
(),
1
);
ASSERT_EQ
(
disks
[
0
].
lock
(),
disk_res
);
}
TEST_F
(
ResourceMgrBaseTest
,
get_all_resources
)
{
TEST_F
(
ResourceMgrBaseTest
,
GET_ALL_RESOURCES
)
{
bool
disk
=
false
,
cpu
=
false
,
gpu
=
false
;
auto
resources
=
mgr1_
->
GetAllResources
();
ASSERT_EQ
(
resources
.
size
(),
3
);
...
...
@@ -103,13 +103,13 @@ TEST_F(ResourceMgrBaseTest, get_all_resources) {
ASSERT_TRUE
(
gpu
);
}
TEST_F
(
ResourceMgrBaseTest
,
get_compute_resources
)
{
TEST_F
(
ResourceMgrBaseTest
,
GET_COMPUTE_RESOURCES
)
{
auto
compute_resources
=
mgr1_
->
GetComputeResources
();
ASSERT_EQ
(
compute_resources
.
size
(),
1
);
ASSERT_EQ
(
compute_resources
[
0
],
gpu_res
);
}
TEST_F
(
ResourceMgrBaseTest
,
get_resource_by_type_and_deviceid
)
{
TEST_F
(
ResourceMgrBaseTest
,
GET_RESOURCE_BY_TYPE_AND_DEVICEID
)
{
auto
cpu
=
mgr1_
->
GetResource
(
ResourceType
::
CPU
,
1
);
ASSERT_EQ
(
cpu
,
cpu_res
);
...
...
@@ -117,7 +117,7 @@ TEST_F(ResourceMgrBaseTest, get_resource_by_type_and_deviceid) {
ASSERT_EQ
(
invalid
,
nullptr
);
}
TEST_F
(
ResourceMgrBaseTest
,
get_resource_by_name
)
{
TEST_F
(
ResourceMgrBaseTest
,
GET_RESOURCE_BY_NAME
)
{
auto
disk
=
mgr1_
->
GetResource
(
"disk"
);
ASSERT_EQ
(
disk
,
disk_res
);
...
...
@@ -125,26 +125,26 @@ TEST_F(ResourceMgrBaseTest, get_resource_by_name) {
ASSERT_EQ
(
invalid
,
nullptr
);
}
TEST_F
(
ResourceMgrBaseTest
,
get_num_of_resource
)
{
TEST_F
(
ResourceMgrBaseTest
,
GET_NUM_OF_RESOURCE
)
{
ASSERT_EQ
(
empty_mgr_
->
GetNumOfResource
(),
0
);
ASSERT_EQ
(
mgr1_
->
GetNumOfResource
(),
3
);
}
TEST_F
(
ResourceMgrBaseTest
,
get_num_of_compute_resource
)
{
TEST_F
(
ResourceMgrBaseTest
,
GET_NUM_OF_COMPUTE_RESOURCE
)
{
ASSERT_EQ
(
empty_mgr_
->
GetNumOfComputeResource
(),
0
);
ASSERT_EQ
(
mgr1_
->
GetNumOfComputeResource
(),
1
);
}
TEST_F
(
ResourceMgrBaseTest
,
get_num_of_gpu_resource
)
{
TEST_F
(
ResourceMgrBaseTest
,
GET_NUM_OF_GPU_RESOURCE
)
{
ASSERT_EQ
(
empty_mgr_
->
GetNumGpuResource
(),
0
);
ASSERT_EQ
(
mgr1_
->
GetNumGpuResource
(),
1
);
}
TEST_F
(
ResourceMgrBaseTest
,
dump
)
{
TEST_F
(
ResourceMgrBaseTest
,
DUMP
)
{
ASSERT_FALSE
(
mgr1_
->
Dump
().
empty
());
}
TEST_F
(
ResourceMgrBaseTest
,
dump_tasktables
)
{
TEST_F
(
ResourceMgrBaseTest
,
DUMP_TASKTABLES
)
{
ASSERT_FALSE
(
mgr1_
->
DumpTaskTables
().
empty
());
}
...
...
@@ -169,7 +169,7 @@ class ResourceMgrAdvanceTest : public testing::Test {
ResourcePtr
disk_res
;
};
TEST_F
(
ResourceMgrAdvanceTest
,
register_subscriber
)
{
TEST_F
(
ResourceMgrAdvanceTest
,
REGISTER_SUBSCRIBER
)
{
bool
flag
=
false
;
auto
callback
=
[
&
](
EventPtr
event
)
{
flag
=
true
;
...
...
cpp/unittest/scheduler/resource_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -46,42 +46,42 @@ protected:
ResourcePtr
both_disable_
=
nullptr
;
};
TEST_F
(
ResourceBaseTest
,
name
)
{
TEST_F
(
ResourceBaseTest
,
NAME
)
{
ASSERT_EQ
(
only_loader_
->
name
(),
name1
);
ASSERT_EQ
(
only_executor_
->
name
(),
name2
);
ASSERT_EQ
(
both_enable_
->
name
(),
name3
);
ASSERT_EQ
(
both_disable_
->
name
(),
name4
);
}
TEST_F
(
ResourceBaseTest
,
type
)
{
TEST_F
(
ResourceBaseTest
,
TYPE
)
{
ASSERT_EQ
(
only_loader_
->
type
(),
ResourceType
::
DISK
);
ASSERT_EQ
(
only_executor_
->
type
(),
ResourceType
::
CPU
);
ASSERT_EQ
(
both_enable_
->
type
(),
ResourceType
::
GPU
);
ASSERT_EQ
(
both_disable_
->
type
(),
ResourceType
::
TEST
);
}
TEST_F
(
ResourceBaseTest
,
device_id
)
{
TEST_F
(
ResourceBaseTest
,
DEVICE_ID
)
{
ASSERT_EQ
(
only_loader_
->
device_id
(),
id1
);
ASSERT_EQ
(
only_executor_
->
device_id
(),
id2
);
ASSERT_EQ
(
both_enable_
->
device_id
(),
id3
);
ASSERT_EQ
(
both_disable_
->
device_id
(),
id4
);
}
TEST_F
(
ResourceBaseTest
,
has_loader
)
{
TEST_F
(
ResourceBaseTest
,
HAS_LOADER
)
{
ASSERT_TRUE
(
only_loader_
->
HasLoader
());
ASSERT_FALSE
(
only_executor_
->
HasLoader
());
ASSERT_TRUE
(
both_enable_
->
HasLoader
());
ASSERT_FALSE
(
both_disable_
->
HasLoader
());
}
TEST_F
(
ResourceBaseTest
,
has_executor
)
{
TEST_F
(
ResourceBaseTest
,
HAS_EXECUTOR
)
{
ASSERT_FALSE
(
only_loader_
->
HasExecutor
());
ASSERT_TRUE
(
only_executor_
->
HasExecutor
());
ASSERT_TRUE
(
both_enable_
->
HasExecutor
());
ASSERT_FALSE
(
both_disable_
->
HasExecutor
());
}
TEST_F
(
ResourceBaseTest
,
dump
)
{
TEST_F
(
ResourceBaseTest
,
DUMP
)
{
ASSERT_FALSE
(
only_loader_
->
Dump
().
empty
());
ASSERT_FALSE
(
only_executor_
->
Dump
().
empty
());
ASSERT_FALSE
(
both_enable_
->
Dump
().
empty
());
...
...
@@ -165,7 +165,7 @@ protected:
std
::
condition_variable
cv_
;
};
TEST_F
(
ResourceAdvanceTest
,
disk_resource_test
)
{
TEST_F
(
ResourceAdvanceTest
,
DISK_RESOURCE_TEST
)
{
const
uint64_t
NUM
=
100
;
std
::
vector
<
std
::
shared_ptr
<
TestTask
>>
tasks
;
TableFileSchemaPtr
dummy
=
nullptr
;
...
...
@@ -190,7 +190,7 @@ TEST_F(ResourceAdvanceTest, disk_resource_test) {
}
}
TEST_F
(
ResourceAdvanceTest
,
cpu_resource_test
)
{
TEST_F
(
ResourceAdvanceTest
,
CPU_RESOURCE_TEST
)
{
const
uint64_t
NUM
=
100
;
std
::
vector
<
std
::
shared_ptr
<
TestTask
>>
tasks
;
TableFileSchemaPtr
dummy
=
nullptr
;
...
...
@@ -215,7 +215,7 @@ TEST_F(ResourceAdvanceTest, cpu_resource_test) {
}
}
TEST_F
(
ResourceAdvanceTest
,
gpu_resource_test
)
{
TEST_F
(
ResourceAdvanceTest
,
GPU_RESOURCE_TEST
)
{
const
uint64_t
NUM
=
100
;
std
::
vector
<
std
::
shared_ptr
<
TestTask
>>
tasks
;
TableFileSchemaPtr
dummy
=
nullptr
;
...
...
@@ -240,7 +240,7 @@ TEST_F(ResourceAdvanceTest, gpu_resource_test) {
}
}
TEST_F
(
ResourceAdvanceTest
,
test_resource_test
)
{
TEST_F
(
ResourceAdvanceTest
,
TEST_RESOURCE_TEST
)
{
const
uint64_t
NUM
=
100
;
std
::
vector
<
std
::
shared_ptr
<
TestTask
>>
tasks
;
TableFileSchemaPtr
dummy
=
nullptr
;
...
...
cpp/unittest/scheduler/schedinst_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -68,7 +68,7 @@ protected:
const
std
::
string
CONFIG_FILE
=
"/tmp/milvus_sched_test/config.yaml"
;
};
TEST_F
(
SchedInstTest
,
simple_gpu
)
{
TEST_F
(
SchedInstTest
,
SIMPLE_GPU
)
{
StartSchedulerService
();
}
...
...
cpp/unittest/scheduler/scheduler_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -138,7 +138,7 @@ insert_dummy_index_into_gpu_cache(uint64_t device_id) {
cache
::
GpuCacheMgr
::
GetInstance
(
device_id
)
->
InsertItem
(
"location"
,
obj
);
}
TEST_F
(
SchedulerTest
,
O
nLoadCompleted
)
{
TEST_F
(
SchedulerTest
,
O
N_LOAD_COMPLETED
)
{
const
uint64_t
NUM
=
10
;
std
::
vector
<
std
::
shared_ptr
<
TestTask
>>
tasks
;
TableFileSchemaPtr
dummy
=
std
::
make_shared
<
meta
::
TableFileSchema
>
();
...
...
@@ -158,7 +158,7 @@ TEST_F(SchedulerTest, OnLoadCompleted) {
}
TEST_F
(
SchedulerTest
,
P
ushTaskToNeighbourRandomlyTest
)
{
TEST_F
(
SchedulerTest
,
P
USH_TASK_TO_NEIGHBOUR_RANDOMLY_TEST
)
{
const
uint64_t
NUM
=
10
;
std
::
vector
<
std
::
shared_ptr
<
TestTask
>>
tasks
;
TableFileSchemaPtr
dummy1
=
std
::
make_shared
<
meta
::
TableFileSchema
>
();
...
...
@@ -229,7 +229,7 @@ protected:
};
TEST_F
(
SchedulerTest2
,
S
pecifiedResourceTest
)
{
TEST_F
(
SchedulerTest2
,
S
PECIFIED_RESOURCE_TEST
)
{
const
uint64_t
NUM
=
10
;
std
::
vector
<
std
::
shared_ptr
<
TestTask
>>
tasks
;
TableFileSchemaPtr
dummy
=
std
::
make_shared
<
meta
::
TableFileSchema
>
();
...
...
cpp/unittest/scheduler/task_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -13,7 +13,7 @@ namespace milvus {
namespace
engine
{
TEST
(
TaskTest
,
invalid_index
)
{
TEST
(
TaskTest
,
INVALID_INDEX
)
{
auto
search_task
=
std
::
make_shared
<
XSearchTask
>
(
nullptr
);
search_task
->
Load
(
LoadType
::
TEST
,
10
);
}
...
...
cpp/unittest/scheduler/tasktable_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -32,18 +32,18 @@ protected:
std
::
vector
<
TaskTableItemPtr
>
items_
;
};
TEST_F
(
TaskTableItemTest
,
construct
)
{
TEST_F
(
TaskTableItemTest
,
CONSTRUCT
)
{
ASSERT_EQ
(
default_
.
id
,
0
);
ASSERT_EQ
(
default_
.
task
,
nullptr
);
ASSERT_EQ
(
default_
.
state
,
TaskTableItemState
::
INVALID
);
}
TEST_F
(
TaskTableItemTest
,
destruct
)
{
TEST_F
(
TaskTableItemTest
,
DESTRUCT
)
{
auto
p_item
=
new
TaskTableItem
();
delete
p_item
;
}
TEST_F
(
TaskTableItemTest
,
is_finish
)
{
TEST_F
(
TaskTableItemTest
,
IS_FINISH
)
{
for
(
auto
&
item
:
items_
)
{
if
(
item
->
state
==
TaskTableItemState
::
EXECUTED
||
item
->
state
==
TaskTableItemState
::
MOVED
)
{
...
...
@@ -54,13 +54,13 @@ TEST_F(TaskTableItemTest, is_finish) {
}
}
TEST_F
(
TaskTableItemTest
,
dump
)
{
TEST_F
(
TaskTableItemTest
,
DUMP
)
{
for
(
auto
&
item
:
items_
)
{
ASSERT_FALSE
(
item
->
Dump
().
empty
());
}
}
TEST_F
(
TaskTableItemTest
,
load
)
{
TEST_F
(
TaskTableItemTest
,
LOAD
)
{
for
(
auto
&
item
:
items_
)
{
auto
before_state
=
item
->
state
;
auto
ret
=
item
->
Load
();
...
...
@@ -74,7 +74,7 @@ TEST_F(TaskTableItemTest, load) {
}
}
TEST_F
(
TaskTableItemTest
,
loaded
)
{
TEST_F
(
TaskTableItemTest
,
LOADED
)
{
for
(
auto
&
item
:
items_
)
{
auto
before_state
=
item
->
state
;
auto
ret
=
item
->
Loaded
();
...
...
@@ -88,7 +88,7 @@ TEST_F(TaskTableItemTest, loaded) {
}
}
TEST_F
(
TaskTableItemTest
,
execute
)
{
TEST_F
(
TaskTableItemTest
,
EXECUTE
)
{
for
(
auto
&
item
:
items_
)
{
auto
before_state
=
item
->
state
;
auto
ret
=
item
->
Execute
();
...
...
@@ -103,7 +103,7 @@ TEST_F(TaskTableItemTest, execute) {
}
TEST_F
(
TaskTableItemTest
,
executed
)
{
TEST_F
(
TaskTableItemTest
,
EXECUTED
)
{
for
(
auto
&
item
:
items_
)
{
auto
before_state
=
item
->
state
;
auto
ret
=
item
->
Executed
();
...
...
@@ -117,7 +117,7 @@ TEST_F(TaskTableItemTest, executed) {
}
}
TEST_F
(
TaskTableItemTest
,
move
)
{
TEST_F
(
TaskTableItemTest
,
MOVE
)
{
for
(
auto
&
item
:
items_
)
{
auto
before_state
=
item
->
state
;
auto
ret
=
item
->
Move
();
...
...
@@ -131,7 +131,7 @@ TEST_F(TaskTableItemTest, move) {
}
}
TEST_F
(
TaskTableItemTest
,
moved
)
{
TEST_F
(
TaskTableItemTest
,
MOVED
)
{
for
(
auto
&
item
:
items_
)
{
auto
before_state
=
item
->
state
;
auto
ret
=
item
->
Moved
();
...
...
@@ -163,7 +163,7 @@ protected:
TaskTable
empty_table_
;
};
TEST_F
(
TaskTableBaseTest
,
subscriber
)
{
TEST_F
(
TaskTableBaseTest
,
SUBSCRIBER
)
{
bool
flag
=
false
;
auto
callback
=
[
&
]()
{
flag
=
true
;
...
...
@@ -174,46 +174,46 @@ TEST_F(TaskTableBaseTest, subscriber) {
}
TEST_F
(
TaskTableBaseTest
,
put_task
)
{
TEST_F
(
TaskTableBaseTest
,
PUT_TASK
)
{
empty_table_
.
Put
(
task1_
);
ASSERT_EQ
(
empty_table_
.
Get
(
0
)
->
task
,
task1_
);
}
TEST_F
(
TaskTableBaseTest
,
put_invalid_test
)
{
TEST_F
(
TaskTableBaseTest
,
PUT_INVALID_TEST
)
{
empty_table_
.
Put
(
invalid_task_
);
ASSERT_EQ
(
empty_table_
.
Get
(
0
)
->
task
,
invalid_task_
);
}
TEST_F
(
TaskTableBaseTest
,
put_batch
)
{
TEST_F
(
TaskTableBaseTest
,
PUT_BATCH
)
{
std
::
vector
<
TaskPtr
>
tasks
{
task1_
,
task2_
};
empty_table_
.
Put
(
tasks
);
ASSERT_EQ
(
empty_table_
.
Get
(
0
)
->
task
,
task1_
);
ASSERT_EQ
(
empty_table_
.
Get
(
1
)
->
task
,
task2_
);
}
TEST_F
(
TaskTableBaseTest
,
put_empty_batch
)
{
TEST_F
(
TaskTableBaseTest
,
PUT_EMPTY_BATCH
)
{
std
::
vector
<
TaskPtr
>
tasks
{};
empty_table_
.
Put
(
tasks
);
}
TEST_F
(
TaskTableBaseTest
,
empty
)
{
TEST_F
(
TaskTableBaseTest
,
EMPTY
)
{
ASSERT_TRUE
(
empty_table_
.
Empty
());
empty_table_
.
Put
(
task1_
);
ASSERT_FALSE
(
empty_table_
.
Empty
());
}
TEST_F
(
TaskTableBaseTest
,
size
)
{
TEST_F
(
TaskTableBaseTest
,
SIZE
)
{
ASSERT_EQ
(
empty_table_
.
Size
(),
0
);
empty_table_
.
Put
(
task1_
);
ASSERT_EQ
(
empty_table_
.
Size
(),
1
);
}
TEST_F
(
TaskTableBaseTest
,
operator_
)
{
TEST_F
(
TaskTableBaseTest
,
OPERATOR
)
{
empty_table_
.
Put
(
task1_
);
ASSERT_EQ
(
empty_table_
.
Get
(
0
),
empty_table_
[
0
]);
}
TEST_F
(
TaskTableBaseTest
,
pick_to_load
)
{
TEST_F
(
TaskTableBaseTest
,
PICK_TO_LOAD
)
{
const
size_t
NUM_TASKS
=
10
;
for
(
size_t
i
=
0
;
i
<
NUM_TASKS
;
++
i
)
{
empty_table_
.
Put
(
task1_
);
...
...
@@ -226,7 +226,7 @@ TEST_F(TaskTableBaseTest, pick_to_load) {
ASSERT_EQ
(
indexes
[
0
],
2
);
}
TEST_F
(
TaskTableBaseTest
,
pick_to_load_limit
)
{
TEST_F
(
TaskTableBaseTest
,
PICK_TO_LOAD_LIMIT
)
{
const
size_t
NUM_TASKS
=
10
;
for
(
size_t
i
=
0
;
i
<
NUM_TASKS
;
++
i
)
{
empty_table_
.
Put
(
task1_
);
...
...
@@ -241,7 +241,7 @@ TEST_F(TaskTableBaseTest, pick_to_load_limit) {
ASSERT_EQ
(
indexes
[
2
],
4
);
}
TEST_F
(
TaskTableBaseTest
,
pick_to_load_cache
)
{
TEST_F
(
TaskTableBaseTest
,
PICK_TO_LOAD_CACHE
)
{
const
size_t
NUM_TASKS
=
10
;
for
(
size_t
i
=
0
;
i
<
NUM_TASKS
;
++
i
)
{
empty_table_
.
Put
(
task1_
);
...
...
@@ -262,7 +262,7 @@ TEST_F(TaskTableBaseTest, pick_to_load_cache) {
ASSERT_EQ
(
indexes
[
0
],
2
);
}
TEST_F
(
TaskTableBaseTest
,
pick_to_execute
)
{
TEST_F
(
TaskTableBaseTest
,
PICK_TO_EXECUTE
)
{
const
size_t
NUM_TASKS
=
10
;
for
(
size_t
i
=
0
;
i
<
NUM_TASKS
;
++
i
)
{
empty_table_
.
Put
(
task1_
);
...
...
@@ -276,7 +276,7 @@ TEST_F(TaskTableBaseTest, pick_to_execute) {
ASSERT_EQ
(
indexes
[
0
],
2
);
}
TEST_F
(
TaskTableBaseTest
,
pick_to_execute_limit
)
{
TEST_F
(
TaskTableBaseTest
,
PICK_TO_EXECUTE_LIMIT
)
{
const
size_t
NUM_TASKS
=
10
;
for
(
size_t
i
=
0
;
i
<
NUM_TASKS
;
++
i
)
{
empty_table_
.
Put
(
task1_
);
...
...
@@ -292,7 +292,7 @@ TEST_F(TaskTableBaseTest, pick_to_execute_limit) {
ASSERT_EQ
(
indexes
[
1
],
3
);
}
TEST_F
(
TaskTableBaseTest
,
pick_to_execute_cache
)
{
TEST_F
(
TaskTableBaseTest
,
PICK_TO_EXECUTE_CACHE
)
{
const
size_t
NUM_TASKS
=
10
;
for
(
size_t
i
=
0
;
i
<
NUM_TASKS
;
++
i
)
{
empty_table_
.
Put
(
task1_
);
...
...
@@ -340,7 +340,7 @@ protected:
TaskTable
table1_
;
};
TEST_F
(
TaskTableAdvanceTest
,
load
)
{
TEST_F
(
TaskTableAdvanceTest
,
LOAD
)
{
std
::
vector
<
TaskTableItemState
>
before_state
;
for
(
auto
&
task
:
table1_
)
{
before_state
.
push_back
(
task
->
state
);
...
...
@@ -359,7 +359,7 @@ TEST_F(TaskTableAdvanceTest, load) {
}
}
TEST_F
(
TaskTableAdvanceTest
,
loaded
)
{
TEST_F
(
TaskTableAdvanceTest
,
LOADED
)
{
std
::
vector
<
TaskTableItemState
>
before_state
;
for
(
auto
&
task
:
table1_
)
{
before_state
.
push_back
(
task
->
state
);
...
...
@@ -378,7 +378,7 @@ TEST_F(TaskTableAdvanceTest, loaded) {
}
}
TEST_F
(
TaskTableAdvanceTest
,
execute
)
{
TEST_F
(
TaskTableAdvanceTest
,
EXECUTE
)
{
std
::
vector
<
TaskTableItemState
>
before_state
;
for
(
auto
&
task
:
table1_
)
{
before_state
.
push_back
(
task
->
state
);
...
...
@@ -397,7 +397,7 @@ TEST_F(TaskTableAdvanceTest, execute) {
}
}
TEST_F
(
TaskTableAdvanceTest
,
executed
)
{
TEST_F
(
TaskTableAdvanceTest
,
EXECUTED
)
{
std
::
vector
<
TaskTableItemState
>
before_state
;
for
(
auto
&
task
:
table1_
)
{
before_state
.
push_back
(
task
->
state
);
...
...
@@ -416,7 +416,7 @@ TEST_F(TaskTableAdvanceTest, executed) {
}
}
TEST_F
(
TaskTableAdvanceTest
,
move
)
{
TEST_F
(
TaskTableAdvanceTest
,
MOVE
)
{
std
::
vector
<
TaskTableItemState
>
before_state
;
for
(
auto
&
task
:
table1_
)
{
before_state
.
push_back
(
task
->
state
);
...
...
@@ -435,7 +435,7 @@ TEST_F(TaskTableAdvanceTest, move) {
}
}
TEST_F
(
TaskTableAdvanceTest
,
moved
)
{
TEST_F
(
TaskTableAdvanceTest
,
MOVED
)
{
std
::
vector
<
TaskTableItemState
>
before_state
;
for
(
auto
&
task
:
table1_
)
{
before_state
.
push_back
(
task
->
state
);
...
...
cpp/unittest/server/util_test.cpp
浏览文件 @
c402a6e3
...
...
@@ -6,6 +6,9 @@
#include <gtest/gtest.h>
#include <thread>
#include <easylogging++.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <boost/filesystem.hpp>
#include "utils/CommonUtil.h"
#include "utils/Error.h"
...
...
@@ -282,3 +285,30 @@ TEST(ValidationUtilTest, VALIDATE_DBURI_TEST) {
ASSERT_EQ
(
server
::
ValidationUtil
::
ValidateDbURI
(
"mysql://root:123456@127.0.0.1:3303/milvus"
),
SERVER_SUCCESS
);
ASSERT_NE
(
server
::
ValidationUtil
::
ValidateDbURI
(
"mysql://root:123456@127.0.0.1:port/milvus"
),
SERVER_SUCCESS
);
}
TEST
(
UtilTest
,
ROLLOUTHANDLER_TEST
){
std
::
string
dir1
=
"/tmp/milvus_test"
;
std
::
string
dir2
=
"/tmp/milvus_test/log_test"
;
std
::
string
filename
[
6
]
=
{
"log_global.log"
,
"log_debug.log"
,
"log_warning.log"
,
"log_trace.log"
,
"log_error.log"
,
"log_fatal.log"
};
mkdir
(
dir1
.
c_str
(),
S_IRWXU
);
mkdir
(
dir2
.
c_str
(),
S_IRWXU
);
for
(
int
i
=
0
;
i
<
6
;
++
i
)
{
std
::
string
tmp
=
dir2
+
"/"
+
filename
[
i
];
std
::
ofstream
file
;
file
.
open
(
tmp
.
c_str
());
file
<<
"zilliz"
<<
std
::
endl
;
server
::
RolloutHandler
(
tmp
.
c_str
(),
0
);
tmp
.
append
(
".1"
);
std
::
ifstream
file2
;
file2
.
open
(
tmp
);
std
::
string
tmp2
;
file2
>>
tmp2
;
ASSERT_EQ
(
tmp2
,
"zilliz"
);
}
boost
::
filesystem
::
remove_all
(
dir2
);
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录