Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
milvus
提交
95c8e602
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,发现更多精彩内容 >>
提交
95c8e602
编写于
9月 10, 2019
作者:
Y
Yu Kun
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MS-532 Add grpc server unittest
Former-commit-id: ddcefe343872ab6b5b4e29c23b1544393d1524cb
上级
429ef693
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
72 addition
and
15 deletion
+72
-15
cpp/src/sdk/examples/grpcsimple/src/ClientTest.cpp
cpp/src/sdk/examples/grpcsimple/src/ClientTest.cpp
+3
-3
cpp/src/server/grpc_impl/GrpcMilvusServer.cpp
cpp/src/server/grpc_impl/GrpcMilvusServer.cpp
+1
-0
cpp/src/server/grpc_impl/GrpcRequestHandler.cpp
cpp/src/server/grpc_impl/GrpcRequestHandler.cpp
+3
-6
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
+0
-1
cpp/unittest/server/rpc_test.cpp
cpp/unittest/server/rpc_test.cpp
+65
-5
未找到文件。
cpp/src/sdk/examples/grpcsimple/src/ClientTest.cpp
浏览文件 @
95c8e602
...
...
@@ -23,11 +23,11 @@ std::string GetTableName();
const
std
::
string
TABLE_NAME
=
GetTableName
();
constexpr
int64_t
TABLE_DIMENSION
=
512
;
constexpr
int64_t
TABLE_INDEX_FILE_SIZE
=
1024
;
constexpr
int64_t
BATCH_ROW_COUNT
=
100000
0
;
constexpr
int64_t
BATCH_ROW_COUNT
=
100000
;
constexpr
int64_t
NQ
=
100
;
constexpr
int64_t
TOP_K
=
1
;
constexpr
int64_t
SEARCH_TARGET
=
5000
;
//change this value, result is different
constexpr
int64_t
ADD_VECTOR_LOOP
=
1
0
;
constexpr
int64_t
ADD_VECTOR_LOOP
=
1
;
constexpr
int64_t
SECONDS_EACH_HOUR
=
3600
;
#define BLOCK_SPLITER std::cout << "===========================================" << std::endl;
...
...
@@ -164,7 +164,7 @@ void DoSearch(std::shared_ptr<Connection> conn,
const
std
::
string
&
phase_name
)
{
std
::
vector
<
Range
>
query_range_array
;
Range
rg
;
rg
.
start_value
=
CurrentTmDate
();
rg
.
start_value
=
CurrentTmDate
(
1
);
rg
.
end_value
=
CurrentTmDate
(
1
);
query_range_array
.
emplace_back
(
rg
);
...
...
cpp/src/server/grpc_impl/GrpcMilvusServer.cpp
浏览文件 @
95c8e602
...
...
@@ -78,6 +78,7 @@ GrpcMilvusServer::StartService() {
builder
.
RegisterService
(
&
service
);
server
=
builder
.
BuildAndStart
();
// builder.addTransportFilter();
server
->
Wait
();
}
...
...
cpp/src/server/grpc_impl/GrpcRequestHandler.cpp
浏览文件 @
95c8e602
...
...
@@ -79,12 +79,9 @@ GrpcRequestHandler::Search(::grpc::ServerContext *context,
BaseTaskPtr
task_ptr
=
SearchTask
::
Create
(
request
,
file_id_array
,
response
);
::
milvus
::
grpc
::
Status
grpc_status
;
GrpcRequestScheduler
::
ExecTask
(
task_ptr
,
&
grpc_status
);
if
(
grpc_status
.
error_code
()
!=
SERVER_SUCCESS
)
{
::
grpc
::
Status
status
(
::
grpc
::
INVALID_ARGUMENT
,
grpc_status
.
reason
());
return
status
;
}
else
{
return
::
grpc
::
Status
::
OK
;
}
response
->
mutable_status
()
->
set_error_code
(
grpc_status
.
error_code
());
response
->
mutable_status
()
->
set_reason
(
grpc_status
.
reason
());
return
::
grpc
::
Status
::
OK
;
}
::
grpc
::
Status
...
...
cpp/src/server/grpc_impl/GrpcRequestTask.cpp
浏览文件 @
95c8e602
...
...
@@ -412,7 +412,6 @@ InsertTask::InsertTask(const ::milvus::grpc::InsertParam *insert_param,
:
GrpcBaseTask
(
DDL_DML_TASK_GROUP
),
insert_param_
(
insert_param
),
record_ids_
(
record_ids
)
{
record_ids_
->
Clear
();
}
BaseTaskPtr
...
...
cpp/unittest/server/rpc_test.cpp
浏览文件 @
95c8e602
...
...
@@ -165,10 +165,18 @@ TEST_F(RpcHandlerTest, IndexTest) {
// ASSERT_EQ(error_code, ::milvus::grpc::ErrorCode::SUCCESS);
::
milvus
::
grpc
::
TableName
table_name
;
table_name
.
set_table_name
(
TABLE_NAME
);
::
milvus
::
grpc
::
IndexParam
index_param
;
handler
->
DescribeIndex
(
&
context
,
&
table_name
,
&
index_param
);
table_name
.
set_table_name
(
"test4"
);
handler
->
DescribeIndex
(
&
context
,
&
table_name
,
&
index_param
);
table_name
.
set_table_name
(
TABLE_NAME
);
handler
->
DescribeIndex
(
&
context
,
&
table_name
,
&
index_param
);
::
milvus
::
grpc
::
Status
status
;
table_name
.
Clear
();
handler
->
DropIndex
(
&
context
,
&
table_name
,
&
status
);
table_name
.
set_table_name
(
"test5"
);
handler
->
DropIndex
(
&
context
,
&
table_name
,
&
status
);
table_name
.
set_table_name
(
TABLE_NAME
);
handler
->
DropIndex
(
&
context
,
&
table_name
,
&
status
);
}
...
...
@@ -195,9 +203,31 @@ TEST_F(RpcHandlerTest, SearchTest) {
::
grpc
::
ServerContext
context
;
::
milvus
::
grpc
::
SearchParam
request
;
::
milvus
::
grpc
::
TopKQueryResultList
response
;
//test null input
handler
->
Search
(
&
context
,
nullptr
,
&
response
);
//test invalid table name
handler
->
Search
(
&
context
,
&
request
,
&
response
);
//test table not exist
request
.
set_table_name
(
"test3"
);
handler
->
Search
(
&
context
,
&
request
,
&
response
);
//test invalid topk
request
.
set_table_name
(
TABLE_NAME
);
handler
->
Search
(
&
context
,
&
request
,
&
response
);
//test invalid nprobe
request
.
set_topk
(
10
);
handler
->
Search
(
&
context
,
&
request
,
&
response
);
//test empty query record array
request
.
set_nprobe
(
32
);
handler
->
Search
(
&
context
,
&
request
,
&
response
);
//test search with range
::
milvus
::
grpc
::
Range
*
range
=
request
.
mutable_query_range_array
()
->
Add
();
std
::
vector
<
std
::
vector
<
float
>>
record_array
;
BuildVectors
(
0
,
VECTOR_COUNT
,
record_array
);
for
(
auto
&
record
:
record_array
)
{
...
...
@@ -206,8 +236,14 @@ TEST_F(RpcHandlerTest, SearchTest) {
row_record
->
add_vector_data
(
rec
);
}
}
request
.
set_table_name
(
"test2"
);
handler
->
Search
(
&
context
,
&
request
,
&
response
);
request
.
set_table_name
(
TABLE_NAME
);
handler
->
Search
(
&
context
,
&
request
,
&
response
);
::
milvus
::
grpc
::
SearchInFilesParam
search_in_files_param
;
std
::
string
*
file_id
=
search_in_files_param
.
add_file_id_array
();
*
file_id
=
"test_tbl"
;
handler
->
SearchInFiles
(
&
context
,
&
search_in_files_param
,
&
response
);
}
...
...
@@ -264,22 +300,35 @@ TEST_F(RpcHandlerTest, TablesTest) {
}
}
//test vector_id size not equal to row record size
vector_ids
.
set_vector_id_array
(
0
,
1
);
vector_ids
.
clear_vector_id_array
();
vector_ids
.
add_vector_id_array
(
1
);
handler
->
Insert
(
&
context
,
&
request
,
&
vector_ids
);
//normally test
vector_ids
.
clear_vector_id_array
();
handler
->
Insert
(
&
context
,
&
request
,
&
vector_ids
);
//Show table
::
milvus
::
grpc
::
Command
cmd
;
::
grpc
::
ServerWriter
<::
milvus
::
grpc
::
TableName
>
*
writer
;
request
.
clear_row_record_array
();
vector_ids
.
clear_vector_id_array
();
for
(
uint64_t
i
=
0
;
i
<
10
;
++
i
)
{
::
milvus
::
grpc
::
RowRecord
*
grpc_record
=
request
.
add_row_record_array
();
for
(
size_t
j
=
0
;
j
<
10
;
j
++
)
{
grpc_record
->
add_vector_data
(
record_array
[
i
][
j
]);
}
}
handler
->
Insert
(
&
context
,
&
request
,
&
vector_ids
);
//Show table
// ::milvus::grpc::Command cmd;
// ::grpc::ServerWriter<::milvus::grpc::TableName> *writer;
// status = handler->ShowTables(&context, &cmd, writer);
// ASSERT_EQ(status.error_code(), ::grpc::Status::OK.error_code());
//Count Table
::
milvus
::
grpc
::
TableRowCount
count
;
table_name
.
Clear
();
status
=
handler
->
CountTable
(
&
context
,
&
table_name
,
&
count
);
table_name
.
set_table_name
(
tablename
);
status
=
handler
->
CountTable
(
&
context
,
&
table_name
,
&
count
);
ASSERT_EQ
(
status
.
error_code
(),
::
grpc
::
Status
::
OK
.
error_code
());
...
...
@@ -287,6 +336,9 @@ TEST_F(RpcHandlerTest, TablesTest) {
//Preload Table
table_name
.
Clear
();
status
=
handler
->
PreloadTable
(
&
context
,
&
table_name
,
&
response
);
table_name
.
set_table_name
(
TABLE_NAME
);
status
=
handler
->
PreloadTable
(
&
context
,
&
table_name
,
&
response
);
ASSERT_EQ
(
status
.
error_code
(),
::
grpc
::
Status
::
OK
.
error_code
());
...
...
@@ -307,6 +359,11 @@ TEST_F(RpcHandlerTest, CmdTest) {
command
.
set_cmd
(
"version"
);
::
milvus
::
grpc
::
StringReply
reply
;
handler
->
Cmd
(
&
context
,
&
command
,
&
reply
);
command
.
set_cmd
(
"tasktable"
);
handler
->
Cmd
(
&
context
,
&
command
,
&
reply
);
command
.
set_cmd
(
"test"
);
handler
->
Cmd
(
&
context
,
&
command
,
&
reply
);
ASSERT_EQ
(
reply
.
string_reply
(),
MILVUS_VERSION
);
}
...
...
@@ -315,6 +372,9 @@ TEST_F(RpcHandlerTest, DeleteByRangeTest) {
::
grpc
::
ServerContext
context
;
::
milvus
::
grpc
::
DeleteByRangeParam
request
;
::
milvus
::
grpc
::
Status
status
;
handler
->
DeleteByRange
(
&
context
,
nullptr
,
&
status
);
handler
->
DeleteByRange
(
&
context
,
&
request
,
&
status
);
request
.
set_table_name
(
TABLE_NAME
);
request
.
mutable_range
()
->
set_start_value
(
CurrentTmDate
(
-
2
));
request
.
mutable_range
()
->
set_end_value
(
CurrentTmDate
(
-
3
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录