Unverified Commit 28810ad0 authored by Jin Hai's avatar Jin Hai Committed by GitHub
Browse files

Merge pull request #219 from cydrain/caiyd_opt_unittest

#208 optimize unittest to support run single test more easily
parents c462c7e6 2deba2dc
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -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

+10 −4
Original line number Diff line number Diff line
@@ -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<std::string> sequence = GetConfigNode(parent_key).GetSequence(child_key);
        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<std::string>& 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);
}
+2 −1
Original line number Diff line number Diff line
@@ -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 */
+10 −2
Original line number Diff line number Diff line
@@ -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}
+2 −2
Original line number Diff line number Diff line
@@ -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"
Loading