Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_35024513
milvus
提交
6d54d884
milvus
项目概览
qq_35024513
/
milvus
与 Fork 源项目一致
Fork自
milvus / milvus
通知
14
Star
0
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,发现更多精彩内容 >>
提交
6d54d884
编写于
12月 17, 2019
作者:
Q
quicksilver
浏览文件
操作
浏览文件
下载
差异文件
Merge remote-tracking branch 'upstream/master'
上级
6ee32c9a
7c02c376
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
96 addition
and
109 deletion
+96
-109
CHANGELOG.md
CHANGELOG.md
+1
-0
core/src/sdk/examples/simple/src/ClientTest.cpp
core/src/sdk/examples/simple/src/ClientTest.cpp
+17
-0
core/src/sdk/grpc/ClientProxy.cpp
core/src/sdk/grpc/ClientProxy.cpp
+7
-13
core/src/sdk/grpc/ClientProxy.h
core/src/sdk/grpc/ClientProxy.h
+1
-4
core/src/sdk/include/MilvusApi.h
core/src/sdk/include/MilvusApi.h
+6
-18
core/src/sdk/interface/ConnectionImpl.cpp
core/src/sdk/interface/ConnectionImpl.cpp
+3
-6
core/src/sdk/interface/ConnectionImpl.h
core/src/sdk/interface/ConnectionImpl.h
+1
-4
core/src/server/Config.cpp
core/src/server/Config.cpp
+17
-26
core/src/server/Config.h
core/src/server/Config.h
+3
-5
core/src/server/delivery/request/CmdRequest.cpp
core/src/server/delivery/request/CmdRequest.cpp
+4
-2
core/unittest/server/test_config.cpp
core/unittest/server/test_config.cpp
+36
-31
未找到文件。
CHANGELOG.md
浏览文件 @
6d54d884
...
...
@@ -10,6 +10,7 @@ Please mark all change in change log and use the issue from GitHub
## Feature
-
\#
343 - Add Opentracing
-
\#
665 - Support get/set config via CLI
-
\#
771 - Add server build commit info interface
## Improvement
...
...
core/src/sdk/examples/simple/src/ClientTest.cpp
浏览文件 @
6d54d884
...
...
@@ -76,6 +76,23 @@ ClientTest::Test(const std::string& address, const std::string& port) {
std
::
cout
<<
"SDK version: "
<<
version
<<
std
::
endl
;
}
{
// build commit
std
::
string
build_commit_str
;
std
::
vector
<
std
::
string
>
params
;
stat
=
conn
->
ProcessCommand
(
build_commit_str
,
"build_commit_id"
,
params
);
std
::
cout
<<
"ProcessCommand status: "
<<
stat
.
message
()
<<
std
::
endl
;
std
::
cout
<<
"Milvus build commit id: "
<<
build_commit_str
<<
std
::
endl
;
}
{
// build commit
std
::
string
config_str
;
std
::
vector
<
std
::
string
>
params
;
params
.
push_back
(
"*"
);
stat
=
conn
->
ProcessCommand
(
config_str
,
"get_config"
,
params
);
std
::
cout
<<
"ProcessCommand status: "
<<
stat
.
message
()
<<
std
::
endl
;
std
::
cout
<<
"Milvus config json: "
<<
config_str
<<
std
::
endl
;
}
{
// show tables
std
::
vector
<
std
::
string
>
tables
;
stat
=
conn
->
ShowTables
(
tables
);
...
...
core/src/sdk/grpc/ClientProxy.cpp
浏览文件 @
6d54d884
...
...
@@ -457,21 +457,15 @@ ClientProxy::DropPartition(const PartitionParam& partition_param) {
}
Status
ClientProxy
::
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
{
ClientProxy
::
ProcessCommand
(
std
::
string
&
result
,
const
std
::
string
&
cmd
,
const
std
::
vector
<
std
::
string
>&
params
)
const
{
try
{
return
client_ptr_
->
Cmd
(
value
,
"get "
+
node_name
);
}
catch
(
std
::
exception
&
ex
)
{
return
Status
(
StatusCode
::
UnknownError
,
"Fail to get config: "
+
node_name
);
}
}
Status
ClientProxy
::
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
{
try
{
std
::
string
dummy
;
return
client_ptr_
->
Cmd
(
dummy
,
"set "
+
node_name
+
" "
+
value
);
std
::
string
cmd_line
=
cmd
;
for
(
const
std
::
string
&
param
:
params
)
{
cmd_line
+=
" "
+
param
;
}
return
client_ptr_
->
Cmd
(
result
,
cmd_line
);
}
catch
(
std
::
exception
&
ex
)
{
return
Status
(
StatusCode
::
UnknownError
,
"Fail to
set config: "
+
node_name
);
return
Status
(
StatusCode
::
UnknownError
,
"Fail to
process command: "
+
cmd
);
}
}
...
...
core/src/sdk/grpc/ClientProxy.h
浏览文件 @
6d54d884
...
...
@@ -105,10 +105,7 @@ class ClientProxy : public Connection {
DropPartition
(
const
PartitionParam
&
partition_param
)
override
;
Status
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
override
;
Status
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
override
;
ProcessCommand
(
std
::
string
&
result
,
const
std
::
string
&
cmd
,
const
std
::
vector
<
std
::
string
>&
params
)
const
override
;
private:
std
::
shared_ptr
<::
grpc
::
Channel
>
channel_
;
...
...
core/src/sdk/include/MilvusApi.h
浏览文件 @
6d54d884
...
...
@@ -446,30 +446,18 @@ class Connection {
DropPartition
(
const
PartitionParam
&
param
)
=
0
;
/**
* @brief
Get config metho
d
* @brief
Process comman
d
*
* This method is used to
set config
.
* This method is used to
process pre-defined commands
.
*
* @param node_name, config node name.
* @param value, config value.
* @param result, result string.
* @param cmd, command string.
* @param params, command parameters.
*
* @return Indicate if this operation is successful.
*/
virtual
Status
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
=
0
;
/**
* @brief Set config method
*
* This method is used to set config.
*
* @param node_name, config node name.
* @param value, config value.
*
* @return Indicate if this operation is successful.
*/
virtual
Status
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
=
0
;
ProcessCommand
(
std
::
string
&
result
,
const
std
::
string
&
cmd
,
const
std
::
vector
<
std
::
string
>&
params
)
const
=
0
;
};
}
// namespace milvus
core/src/sdk/interface/ConnectionImpl.cpp
浏览文件 @
6d54d884
...
...
@@ -162,12 +162,9 @@ ConnectionImpl::DropPartition(const PartitionParam& param) {
}
Status
ConnectionImpl
::
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
{
return
client_proxy_
->
GetConfig
(
node_name
,
value
);
ConnectionImpl
::
ProcessCommand
(
std
::
string
&
result
,
const
std
::
string
&
cmd
,
const
std
::
vector
<
std
::
string
>&
params
)
const
{
return
client_proxy_
->
ProcessCommand
(
result
,
cmd
,
params
);
}
Status
ConnectionImpl
::
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
{
return
client_proxy_
->
SetConfig
(
node_name
,
value
);
}
}
// namespace milvus
core/src/sdk/interface/ConnectionImpl.h
浏览文件 @
6d54d884
...
...
@@ -107,10 +107,7 @@ class ConnectionImpl : public Connection {
DropPartition
(
const
PartitionParam
&
param
)
override
;
Status
GetConfig
(
const
std
::
string
&
node_name
,
std
::
string
&
value
)
const
override
;
Status
SetConfig
(
const
std
::
string
&
node_name
,
const
std
::
string
&
value
)
const
override
;
ProcessCommand
(
std
::
string
&
result
,
const
std
::
string
&
cmd
,
const
std
::
vector
<
std
::
string
>&
params
)
const
override
;
private:
std
::
shared_ptr
<
ClientProxy
>
client_proxy_
;
...
...
core/src/server/Config.cpp
浏览文件 @
6d54d884
...
...
@@ -26,6 +26,7 @@
#include "config/YamlConfigMgr.h"
#include "server/Config.h"
#include "thirdparty/nlohmann/json.hpp"
#include "utils/CommonUtil.h"
#include "utils/StringHelpFunctions.h"
#include "utils/ValidationUtil.h"
...
...
@@ -380,28 +381,13 @@ Config::ResetDefaultConfig() {
}
void
Config
::
PrintConfigSection
(
const
std
::
string
&
config_node_name
)
{
std
::
cout
<<
std
::
endl
;
std
::
cout
<<
config_node_name
<<
":"
<<
std
::
endl
;
if
(
config_map_
.
find
(
config_node_name
)
!=
config_map_
.
end
())
{
for
(
auto
item
:
config_map_
[
config_node_name
])
{
std
::
cout
<<
item
.
first
<<
": "
<<
item
.
second
<<
std
::
endl
;
}
}
}
void
Config
::
PrintAll
()
{
PrintConfigSection
(
CONFIG_SERVER
);
PrintConfigSection
(
CONFIG_DB
);
PrintConfigSection
(
CONFIG_CACHE
);
PrintConfigSection
(
CONFIG_METRIC
);
PrintConfigSection
(
CONFIG_ENGINE
);
PrintConfigSection
(
CONFIG_GPU_RESOURCE
);
Config
::
GetConfigJsonStr
(
std
::
string
&
result
)
{
nlohmann
::
json
config_json
(
config_map_
);
result
=
config_json
.
dump
();
}
Status
Config
::
GetConfigCli
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
std
::
string
&
value
)
{
Config
::
GetConfigCli
(
std
::
string
&
value
,
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
)
{
if
(
!
ConfigNodeValid
(
parent_key
,
child_key
))
{
std
::
string
str
=
"Config node invalid: "
+
parent_key
+
CONFIG_NODE_DELIMITER
+
child_key
;
return
Status
(
SERVER_UNEXPECTED_ERROR
,
str
);
...
...
@@ -459,20 +445,25 @@ Config::SetConfigCli(const std::string& parent_key, const std::string& child_key
}
Status
Config
::
Handle
ConfigCli
(
std
::
string
&
result
,
const
std
::
string
&
cmd
)
{
Config
::
Process
ConfigCli
(
std
::
string
&
result
,
const
std
::
string
&
cmd
)
{
std
::
vector
<
std
::
string
>
tokens
;
std
::
vector
<
std
::
string
>
nodes
;
server
::
StringHelpFunctions
::
SplitStringByDelimeter
(
cmd
,
" "
,
tokens
);
if
(
tokens
[
0
]
==
"get"
)
{
if
(
tokens
[
0
]
==
"get
_config
"
)
{
if
(
tokens
.
size
()
!=
2
)
{
return
Status
(
SERVER_UNEXPECTED_ERROR
,
"Invalid command: "
+
cmd
);
}
server
::
StringHelpFunctions
::
SplitStringByDelimeter
(
tokens
[
1
],
CONFIG_NODE_DELIMITER
,
nodes
);
if
(
nodes
.
size
()
!=
2
)
{
return
Status
(
SERVER_UNEXPECTED_ERROR
,
"Invalid command: "
+
cmd
);
if
(
tokens
[
1
]
==
"*"
)
{
GetConfigJsonStr
(
result
);
return
Status
::
OK
();
}
else
{
server
::
StringHelpFunctions
::
SplitStringByDelimeter
(
tokens
[
1
],
CONFIG_NODE_DELIMITER
,
nodes
);
if
(
nodes
.
size
()
!=
2
)
{
return
Status
(
SERVER_UNEXPECTED_ERROR
,
"Invalid command: "
+
cmd
);
}
return
GetConfigCli
(
result
,
nodes
[
0
],
nodes
[
1
]);
}
return
GetConfigCli
(
nodes
[
0
],
nodes
[
1
],
result
);
}
else
if
(
tokens
[
0
]
==
"set"
)
{
}
else
if
(
tokens
[
0
]
==
"set_config"
)
{
if
(
tokens
.
size
()
!=
3
)
{
return
Status
(
SERVER_UNEXPECTED_ERROR
,
"Invalid command: "
+
cmd
);
}
...
...
core/src/server/Config.h
浏览文件 @
6d54d884
...
...
@@ -121,9 +121,9 @@ class Config {
Status
ResetDefaultConfig
();
void
PrintAll
(
);
GetConfigJsonStr
(
std
::
string
&
result
);
Status
Handle
ConfigCli
(
std
::
string
&
result
,
const
std
::
string
&
cmd
);
Process
ConfigCli
(
std
::
string
&
result
,
const
std
::
string
&
cmd
);
private:
ConfigNode
&
...
...
@@ -136,10 +136,8 @@ class Config {
GetConfigValueInMem
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
std
::
string
&
value
);
Status
SetConfigValueInMem
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
const
std
::
string
&
value
);
void
PrintConfigSection
(
const
std
::
string
&
config_node_name
);
Status
GetConfigCli
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
std
::
string
&
value
);
GetConfigCli
(
std
::
string
&
value
,
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
);
Status
SetConfigCli
(
const
std
::
string
&
parent_key
,
const
std
::
string
&
child_key
,
const
std
::
string
&
value
);
...
...
core/src/server/delivery/request/CmdRequest.cpp
浏览文件 @
6d54d884
...
...
@@ -52,9 +52,11 @@ CmdRequest::OnExecute() {
#else
result_
=
"CPU"
;
#endif
}
else
if
(
cmd_
.
substr
(
0
,
3
)
==
"set"
||
cmd_
.
substr
(
0
,
3
)
==
"get"
)
{
}
else
if
(
cmd_
==
"build_commit_id"
)
{
result_
=
LAST_COMMIT_ID
;
}
else
if
(
cmd_
.
substr
(
0
,
10
)
==
"set_config"
||
cmd_
.
substr
(
0
,
10
)
==
"get_config"
)
{
server
::
Config
&
config
=
server
::
Config
::
GetInstance
();
stat
=
config
.
Handle
ConfigCli
(
result_
,
cmd_
);
stat
=
config
.
Process
ConfigCli
(
result_
,
cmd_
);
}
else
{
result_
=
"Unknown command"
;
}
...
...
core/unittest/server/test_config.cpp
浏览文件 @
6d54d884
...
...
@@ -311,12 +311,12 @@ TEST_F(ConfigTest, SERVER_CONFIG_VALID_TEST) {
}
std
::
string
gen_get_command
(
const
std
::
string
&
parent_node
,
const
std
::
string
&
child_node
)
{
std
::
string
cmd
=
"get "
+
parent_node
+
ms
::
CONFIG_NODE_DELIMITER
+
child_node
;
std
::
string
cmd
=
"get
_config
"
+
parent_node
+
ms
::
CONFIG_NODE_DELIMITER
+
child_node
;
return
cmd
;
}
std
::
string
gen_set_command
(
const
std
::
string
&
parent_node
,
const
std
::
string
&
child_node
,
const
std
::
string
&
value
)
{
std
::
string
cmd
=
"set "
+
parent_node
+
ms
::
CONFIG_NODE_DELIMITER
+
child_node
+
" "
+
value
;
std
::
string
cmd
=
"set
_config
"
+
parent_node
+
ms
::
CONFIG_NODE_DELIMITER
+
child_node
+
" "
+
value
;
return
cmd
;
}
...
...
@@ -328,75 +328,78 @@ TEST_F(ConfigTest, SERVER_CONFIG_CLI_TEST) {
std
::
string
get_cmd
,
set_cmd
;
std
::
string
result
,
dummy
;
s
=
config
.
ProcessConfigCli
(
result
,
"get_config *"
);
ASSERT_TRUE
(
s
.
ok
());
/* server config */
std
::
string
server_addr
=
"192.168.1.155"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_SERVER
,
ms
::
CONFIG_SERVER_ADDRESS
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_SERVER
,
ms
::
CONFIG_SERVER_ADDRESS
,
server_addr
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
/* db config */
std
::
string
db_primary_path
=
"/home/zilliz"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_DB
,
ms
::
CONFIG_DB_PRIMARY_PATH
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_DB
,
ms
::
CONFIG_DB_PRIMARY_PATH
,
db_primary_path
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
/* metric config */
std
::
string
metric_enable_monitor
=
"false"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_METRIC
,
ms
::
CONFIG_METRIC_ENABLE_MONITOR
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_METRIC
,
ms
::
CONFIG_METRIC_ENABLE_MONITOR
,
metric_enable_monitor
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_FALSE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
/* cache config */
std
::
string
cache_cpu_cache_capacity
=
"5"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_CACHE
,
ms
::
CONFIG_CACHE_CPU_CACHE_CAPACITY
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_CACHE
,
ms
::
CONFIG_CACHE_CPU_CACHE_CAPACITY
,
cache_cpu_cache_capacity
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
result
==
cache_cpu_cache_capacity
);
std
::
string
cache_cpu_cache_threshold
=
"0.1"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_CACHE
,
ms
::
CONFIG_CACHE_CPU_CACHE_THRESHOLD
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_CACHE
,
ms
::
CONFIG_CACHE_CPU_CACHE_THRESHOLD
,
cache_cpu_cache_threshold
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
result
==
cache_cpu_cache_threshold
);
std
::
string
cache_insert_data
=
"true"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_CACHE
,
ms
::
CONFIG_CACHE_CACHE_INSERT_DATA
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_CACHE
,
ms
::
CONFIG_CACHE_CACHE_INSERT_DATA
,
cache_insert_data
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
result
==
cache_insert_data
);
/* engine config */
std
::
string
engine_use_blas_threshold
=
"50"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_ENGINE
,
ms
::
CONFIG_ENGINE_USE_BLAS_THRESHOLD
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_ENGINE
,
ms
::
CONFIG_ENGINE_USE_BLAS_THRESHOLD
,
engine_use_blas_threshold
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
result
==
engine_use_blas_threshold
);
std
::
string
engine_omp_thread_num
=
"8"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_ENGINE
,
ms
::
CONFIG_ENGINE_OMP_THREAD_NUM
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_ENGINE
,
ms
::
CONFIG_ENGINE_OMP_THREAD_NUM
,
engine_omp_thread_num
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
result
==
engine_omp_thread_num
);
...
...
@@ -404,9 +407,9 @@ TEST_F(ConfigTest, SERVER_CONFIG_CLI_TEST) {
std
::
string
engine_gpu_search_threshold
=
"800"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_ENGINE
,
ms
::
CONFIG_ENGINE_GPU_SEARCH_THRESHOLD
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_ENGINE
,
ms
::
CONFIG_ENGINE_GPU_SEARCH_THRESHOLD
,
engine_gpu_search_threshold
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
result
==
engine_gpu_search_threshold
);
...
...
@@ -414,35 +417,35 @@ TEST_F(ConfigTest, SERVER_CONFIG_CLI_TEST) {
std
::
string
resource_enable_gpu
=
"true"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_GPU_RESOURCE
,
ms
::
CONFIG_GPU_RESOURCE_ENABLE
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_GPU_RESOURCE
,
ms
::
CONFIG_GPU_RESOURCE_ENABLE
,
resource_enable_gpu
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
result
==
resource_enable_gpu
);
std
::
string
gpu_cache_capacity
=
"1"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_GPU_RESOURCE
,
ms
::
CONFIG_GPU_RESOURCE_CACHE_CAPACITY
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_GPU_RESOURCE
,
ms
::
CONFIG_GPU_RESOURCE_CACHE_CAPACITY
,
gpu_cache_capacity
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
result
==
gpu_cache_capacity
);
std
::
string
gpu_cache_threshold
=
"0.2"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_GPU_RESOURCE
,
ms
::
CONFIG_GPU_RESOURCE_CACHE_THRESHOLD
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_GPU_RESOURCE
,
ms
::
CONFIG_GPU_RESOURCE_CACHE_THRESHOLD
,
gpu_cache_threshold
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
result
==
gpu_cache_threshold
);
std
::
string
search_resources
=
"gpu0"
;
get_cmd
=
gen_get_command
(
ms
::
CONFIG_GPU_RESOURCE
,
ms
::
CONFIG_GPU_RESOURCE_SEARCH_RESOURCES
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_GPU_RESOURCE
,
ms
::
CONFIG_GPU_RESOURCE_SEARCH_RESOURCES
,
search_resources
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
result
==
search_resources
);
...
...
@@ -450,9 +453,9 @@ TEST_F(ConfigTest, SERVER_CONFIG_CLI_TEST) {
get_cmd
=
gen_get_command
(
ms
::
CONFIG_GPU_RESOURCE
,
ms
::
CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES
);
set_cmd
=
gen_set_command
(
ms
::
CONFIG_GPU_RESOURCE
,
ms
::
CONFIG_GPU_RESOURCE_BUILD_INDEX_RESOURCES
,
build_index_resources
);
s
=
config
.
Handle
ConfigCli
(
dummy
,
set_cmd
);
s
=
config
.
Process
ConfigCli
(
dummy
,
set_cmd
);
ASSERT_TRUE
(
s
.
ok
());
s
=
config
.
Handle
ConfigCli
(
result
,
get_cmd
);
s
=
config
.
Process
ConfigCli
(
result
,
get_cmd
);
ASSERT_TRUE
(
s
.
ok
());
ASSERT_TRUE
(
result
==
build_index_resources
);
#endif
...
...
@@ -591,7 +594,9 @@ TEST_F(ConfigTest, SERVER_CONFIG_TEST) {
s
=
config
.
ValidateConfig
();
ASSERT_TRUE
(
s
.
ok
());
config
.
PrintAll
();
std
::
string
config_json_str
;
config
.
GetConfigJsonStr
(
config_json_str
);
std
::
cout
<<
config_json_str
<<
std
::
endl
;
s
=
config
.
ResetDefaultConfig
();
ASSERT_TRUE
(
s
.
ok
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录