diff --git a/CHANGELOG.md b/CHANGELOG.md index 88b2a69e6434bc4fc0faa9f6506f5de33684ed86..d49922b25999b8d191de8801d24c51aebace908b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ Please mark all change in change log and use the ticket from JIRA. ## Improvement - \#207 - Add more unittest for config set/get +- \#208 - optimize unittest to support run single test more easily ## Task diff --git a/core/src/server/Config.cpp b/core/src/server/Config.cpp index 20bcb937e7d7e593bff821a4c38f7e7c4e806a25..ccc518cac36f3178f730f42509d482357af3f77a 100644 --- a/core/src/server/Config.cpp +++ b/core/src/server/Config.cpp @@ -795,11 +795,16 @@ Config::GetConfigStr(const std::string& parent_key, const std::string& child_key } 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; if (!GetConfigValueInMem(parent_key, child_key, value).ok()) { std::vector sequence = GetConfigNode(parent_key).GetSequence(child_key); - server::StringHelpFunctions::MergeStringWithDelimeter(sequence, delim, value); + if (sequence.empty()) { + value = default_value; + } else { + server::StringHelpFunctions::MergeStringWithDelimeter(sequence, delim, value); + } SetConfigValueInMem(parent_key, child_key, value); } return value; @@ -1028,8 +1033,9 @@ Config::GetResourceConfigMode(std::string& value) { Status Config::GetResourceConfigSearchResources(std::vector& value) { - std::string str = GetConfigSequenceStr(CONFIG_RESOURCE, CONFIG_RESOURCE_SEARCH_RESOURCES, - CONFIG_RESOURCE_SEARCH_RESOURCES_DELIMITER); + std::string str = + 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); return CheckResourceConfigSearchResources(value); } diff --git a/core/src/server/Config.h b/core/src/server/Config.h index df43f040777540883a0e82efc120e2f42a7022aa..e466b70a3b7f129977a4345a359e55856669b297 100644 --- a/core/src/server/Config.h +++ b/core/src/server/Config.h @@ -186,7 +186,8 @@ class Config { std::string GetConfigStr(const std::string& parent_key, const std::string& child_key, const std::string& default_value = ""); 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: /* server config */ diff --git a/core/unittest/db/CMakeLists.txt b/core/unittest/db/CMakeLists.txt index 3954dd8656f9573a0effb1fb1ba7ecab9c8cbbac..92ddc910af5ad3699f2d923b9865ad73beff5c7a 100644 --- a/core/unittest/db/CMakeLists.txt +++ b/core/unittest/db/CMakeLists.txt @@ -17,8 +17,16 @@ # under the License. #------------------------------------------------------------------------------- - -aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files) +set(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 ${common_files} diff --git a/core/unittest/db/utils.cpp b/core/unittest/db/utils.cpp index 16e195079cae03ee15a9f63b2a44e845ecc1553e..9dce779737a897abc91aab4c5f1f12bad4c99134 100644 --- a/core/unittest/db/utils.cpp +++ b/core/unittest/db/utils.cpp @@ -60,8 +60,8 @@ static const char " port: 8080 # port prometheus used to fetch metrics\n" "\n" "cache_config:\n" - " cpu_mem_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_capacity: 16 # GB, CPU memory used for cache\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" "\n" "engine_config:\n" diff --git a/core/unittest/metrics/CMakeLists.txt b/core/unittest/metrics/CMakeLists.txt index eba8146baa7b0a5b225aed8f16976830b29e0c60..ad9d4e3943a33cb962e08cc12bdb85819c4e5068 100644 --- a/core/unittest/metrics/CMakeLists.txt +++ b/core/unittest/metrics/CMakeLists.txt @@ -17,7 +17,11 @@ # 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 ${common_files} diff --git a/core/unittest/scheduler/CMakeLists.txt b/core/unittest/scheduler/CMakeLists.txt index 087f93f017c38f7b9858f46f17abe0f03bc0b7ad..6a48d40191d588f21544d8b2e8d212e7eb85bb28 100644 --- a/core/unittest/scheduler/CMakeLists.txt +++ b/core/unittest/scheduler/CMakeLists.txt @@ -17,7 +17,17 @@ # 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 ${common_files} diff --git a/core/unittest/scheduler/task_test.cpp b/core/unittest/scheduler/test_task.cpp similarity index 100% rename from core/unittest/scheduler/task_test.cpp rename to core/unittest/scheduler/test_task.cpp diff --git a/core/unittest/server/CMakeLists.txt b/core/unittest/server/CMakeLists.txt index 1f89de8d3f0bba81f9c0a40b156654c4b50499d3..742b1fad5a6bce395a4f484dd3a21ce7d0889629 100644 --- a/core/unittest/server/CMakeLists.txt +++ b/core/unittest/server/CMakeLists.txt @@ -17,7 +17,12 @@ # 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") link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") diff --git a/core/unittest/wrapper/CMakeLists.txt b/core/unittest/wrapper/CMakeLists.txt index ef145a9f504a98005a4d0e9925f6601da3e3fd16..3f2be064c2ea0f1a57a17ddca9ba92393b539a18 100644 --- a/core/unittest/wrapper/CMakeLists.txt +++ b/core/unittest/wrapper/CMakeLists.txt @@ -17,7 +17,11 @@ # 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 ${MILVUS_ENGINE_SRC}/wrapper/DataTransfer.cpp diff --git a/core/unittest/wrapper/utils.cpp b/core/unittest/wrapper/utils.cpp index b397a35d7c00d58938a02990603a2101ed5e82b4..e17077aece20645bb7e4f6b1d020cf60322bb3d6 100644 --- a/core/unittest/wrapper/utils.cpp +++ b/core/unittest/wrapper/utils.cpp @@ -50,8 +50,8 @@ static const char " port: 8080 # port prometheus used to fetch metrics\n" "\n" "cache_config:\n" - " cpu_mem_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_capacity: 16 # GB, CPU memory used for cache\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" "\n" "engine_config:\n"