未验证 提交 28810ad0 编写于 作者: J Jin Hai 提交者: GitHub

Merge pull request #219 from cydrain/caiyd_opt_unittest

#208 optimize unittest to support run single test more easily
...@@ -9,6 +9,7 @@ Please mark all change in change log and use the ticket from JIRA. ...@@ -9,6 +9,7 @@ Please mark all change in change log and use the ticket from JIRA.
## Improvement ## Improvement
- \#207 - Add more unittest for config set/get - \#207 - Add more unittest for config set/get
- \#208 - optimize unittest to support run single test more easily
## Task ## Task
......
...@@ -795,11 +795,16 @@ Config::GetConfigStr(const std::string& parent_key, const std::string& child_key ...@@ -795,11 +795,16 @@ Config::GetConfigStr(const std::string& parent_key, const std::string& child_key
} }
std::string std::string
Config::GetConfigSequenceStr(const std::string& parent_key, const std::string& child_key, const std::string& delim) { Config::GetConfigSequenceStr(const std::string& parent_key, const std::string& child_key, const std::string& delim,
const std::string& default_value) {
std::string value; std::string value;
if (!GetConfigValueInMem(parent_key, child_key, value).ok()) { if (!GetConfigValueInMem(parent_key, child_key, value).ok()) {
std::vector<std::string> sequence = GetConfigNode(parent_key).GetSequence(child_key); std::vector<std::string> sequence = GetConfigNode(parent_key).GetSequence(child_key);
if (sequence.empty()) {
value = default_value;
} else {
server::StringHelpFunctions::MergeStringWithDelimeter(sequence, delim, value); server::StringHelpFunctions::MergeStringWithDelimeter(sequence, delim, value);
}
SetConfigValueInMem(parent_key, child_key, value); SetConfigValueInMem(parent_key, child_key, value);
} }
return value; return value;
...@@ -1028,8 +1033,9 @@ Config::GetResourceConfigMode(std::string& value) { ...@@ -1028,8 +1033,9 @@ Config::GetResourceConfigMode(std::string& value) {
Status Status
Config::GetResourceConfigSearchResources(std::vector<std::string>& value) { Config::GetResourceConfigSearchResources(std::vector<std::string>& value) {
std::string str = GetConfigSequenceStr(CONFIG_RESOURCE, CONFIG_RESOURCE_SEARCH_RESOURCES, std::string str =
CONFIG_RESOURCE_SEARCH_RESOURCES_DELIMITER); GetConfigSequenceStr(CONFIG_RESOURCE, CONFIG_RESOURCE_SEARCH_RESOURCES,
CONFIG_RESOURCE_SEARCH_RESOURCES_DELIMITER, CONFIG_RESOURCE_SEARCH_RESOURCES_DEFAULT);
server::StringHelpFunctions::SplitStringByDelimeter(str, CONFIG_RESOURCE_SEARCH_RESOURCES_DELIMITER, value); server::StringHelpFunctions::SplitStringByDelimeter(str, CONFIG_RESOURCE_SEARCH_RESOURCES_DELIMITER, value);
return CheckResourceConfigSearchResources(value); return CheckResourceConfigSearchResources(value);
} }
......
...@@ -186,7 +186,8 @@ class Config { ...@@ -186,7 +186,8 @@ class Config {
std::string std::string
GetConfigStr(const std::string& parent_key, const std::string& child_key, const std::string& default_value = ""); GetConfigStr(const std::string& parent_key, const std::string& child_key, const std::string& default_value = "");
std::string std::string
GetConfigSequenceStr(const std::string& parent_key, const std::string& child_key, const std::string& delim); GetConfigSequenceStr(const std::string& parent_key, const std::string& child_key, const std::string& delim = ",",
const std::string& default_value = "");
public: public:
/* server config */ /* server config */
......
...@@ -17,8 +17,16 @@ ...@@ -17,8 +17,16 @@
# under the License. # under the License.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
set(test_files
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files) ${CMAKE_CURRENT_SOURCE_DIR}/test_db.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_db_mysql.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_engine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_mem.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_meta.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_meta_mysql.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_misc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_search.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp)
cuda_add_executable(test_db cuda_add_executable(test_db
${common_files} ${common_files}
......
...@@ -60,8 +60,8 @@ static const char ...@@ -60,8 +60,8 @@ static const char
" port: 8080 # port prometheus used to fetch metrics\n" " port: 8080 # port prometheus used to fetch metrics\n"
"\n" "\n"
"cache_config:\n" "cache_config:\n"
" cpu_mem_capacity: 16 # GB, CPU memory used for cache\n" " cpu_cache_capacity: 16 # GB, CPU memory used for cache\n"
" cpu_mem_threshold: 0.85 # percentage of data kept when cache cleanup triggered\n" " cpu_cache_threshold: 0.85 # percentage of data kept when cache cleanup triggered\n"
" cache_insert_data: false # whether load inserted data into cache\n" " cache_insert_data: false # whether load inserted data into cache\n"
"\n" "\n"
"engine_config:\n" "engine_config:\n"
......
...@@ -17,7 +17,11 @@ ...@@ -17,7 +17,11 @@
# under the License. # under the License.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files) set(test_files
${CMAKE_CURRENT_SOURCE_DIR}/test_metricbase.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_metrics.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_prometheus.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp)
add_executable(test_metrics add_executable(test_metrics
${common_files} ${common_files}
......
...@@ -17,7 +17,17 @@ ...@@ -17,7 +17,17 @@
# under the License. # under the License.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files) set(test_files
${CMAKE_CURRENT_SOURCE_DIR}/test_algorithm.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_event.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_node.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_normal.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_resource.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_resource_factory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_resource_mgr.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_scheduler.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_task.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_tasktable.cpp)
cuda_add_executable(test_scheduler cuda_add_executable(test_scheduler
${common_files} ${common_files}
......
...@@ -17,7 +17,12 @@ ...@@ -17,7 +17,12 @@
# under the License. # under the License.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files) set(test_files
${CMAKE_CURRENT_SOURCE_DIR}/test_cache.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_config.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_rpc.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_util.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp)
include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include") include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include")
link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64")
......
...@@ -17,7 +17,11 @@ ...@@ -17,7 +17,11 @@
# under the License. # under the License.
#------------------------------------------------------------------------------- #-------------------------------------------------------------------------------
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files) set(test_files
${CMAKE_CURRENT_SOURCE_DIR}/test_hybrid_index.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_knowhere.cpp
${CMAKE_CURRENT_SOURCE_DIR}/test_wrapper.cpp
${CMAKE_CURRENT_SOURCE_DIR}/utils.cpp)
set(wrapper_files set(wrapper_files
${MILVUS_ENGINE_SRC}/wrapper/DataTransfer.cpp ${MILVUS_ENGINE_SRC}/wrapper/DataTransfer.cpp
......
...@@ -50,8 +50,8 @@ static const char ...@@ -50,8 +50,8 @@ static const char
" port: 8080 # port prometheus used to fetch metrics\n" " port: 8080 # port prometheus used to fetch metrics\n"
"\n" "\n"
"cache_config:\n" "cache_config:\n"
" cpu_mem_capacity: 16 # GB, CPU memory used for cache\n" " cpu_cache_capacity: 16 # GB, CPU memory used for cache\n"
" cpu_mem_threshold: 0.85 # percentage of data kept when cache cleanup triggered\n" " cpu_cache_threshold: 0.85 # percentage of data kept when cache cleanup triggered\n"
" cache_insert_data: false # whether load inserted data into cache\n" " cache_insert_data: false # whether load inserted data into cache\n"
"\n" "\n"
"engine_config:\n" "engine_config:\n"
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册