diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 33d34fcd34cbf02a3d583bab74c4556f150f1ac3..a41bc23484a5c290302d8fe06472dff625b1326f 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -33,6 +33,7 @@ Please mark all change in change log and use the ticket from JIRA. - MS-575 - Add Clang-format & Clang-tidy & Cpplint - MS-586 - Remove BUILD_FAISS_WITH_MKL option - MS-590 - Refine cmake code to support cpplint +- MS-600 - Reconstruct unittest code # Milvus 0.4.0 (2019-09-12) diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index 6ee3966c4ffdab88020a4fab70e345565ea4e61b..9810c6b7d83ddb26ce60b7df0443fbd4cd1eeebf 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -20,29 +20,24 @@ include_directories(${MILVUS_SOURCE_DIR}) include_directories(${MILVUS_ENGINE_SRC}) -add_subdirectory(core) +include_directories(${CUDA_TOOLKIT_ROOT_DIR}/include) +include_directories(${MILVUS_ENGINE_SRC}/grpc/gen-status) +include_directories(${MILVUS_ENGINE_SRC}/grpc/gen-milvus) +#this statement must put here, since the CORE_INCLUDE_DIRS is defined in code/CMakeList.txt +add_subdirectory(core) set(CORE_INCLUDE_DIRS ${CORE_INCLUDE_DIRS} PARENT_SCOPE) foreach (dir ${CORE_INCLUDE_DIRS}) include_directories(${dir}) endforeach () aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_files) - aux_source_directory(${MILVUS_ENGINE_SRC}/config config_files) - +aux_source_directory(${MILVUS_ENGINE_SRC}/metrics metrics_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db db_main_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db/engine db_engine_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db/insert db_insert_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db/meta db_meta_files) -aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler db_scheduler_files) -aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler/context db_scheduler_context_files) -aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler/task db_scheduler_task_files) -set(db_scheduler_files - ${db_scheduler_files} - ${db_scheduler_context_files} - ${db_scheduler_task_files} - ) set(grpc_service_files ${MILVUS_ENGINE_SRC}/grpc/gen-milvus/milvus.grpc.pb.cc @@ -51,8 +46,6 @@ set(grpc_service_files ${MILVUS_ENGINE_SRC}/grpc/gen-status/status.pb.cc ) -aux_source_directory(${MILVUS_ENGINE_SRC}/metrics metrics_files) - aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler scheduler_main_files) aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/action scheduler_action_files) aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/event scheduler_event_files) @@ -70,9 +63,7 @@ set(scheduler_files aux_source_directory(${MILVUS_ENGINE_SRC}/server server_files) aux_source_directory(${MILVUS_ENGINE_SRC}/server/grpc_impl grpc_server_files) - aux_source_directory(${MILVUS_ENGINE_SRC}/utils utils_files) - aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper wrapper_files) set(engine_files @@ -82,16 +73,11 @@ set(engine_files ${db_engine_files} ${db_insert_files} ${db_meta_files} - ${db_scheduler_files} ${metrics_files} ${utils_files} ${wrapper_files} ) -include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include") -include_directories(${MILVUS_ENGINE_SRC}/grpc/gen-status) -include_directories(${MILVUS_ENGINE_SRC}/grpc/gen-milvus) - set(client_grpc_lib grpcpp_channelz grpc++ @@ -112,6 +98,12 @@ set(boost_lib boost_serialization_static ) +set(cuda_lib + ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs/libnvidia-ml.so + cudart + cublas + ) + set(third_party_libs sqlite ${client_grpc_lib} @@ -123,17 +115,15 @@ set(third_party_libs snappy zlib zstd - cudart - cublas + ${cuda_lib} mysqlpp - ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs/libnvidia-ml.so - cudart ) + if (MILVUS_ENABLE_PROFILING STREQUAL "ON") set(third_party_libs ${third_party_libs} - gperftools - libunwind - ) + gperftools + libunwind + ) endif () link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") @@ -141,7 +131,6 @@ set(engine_libs pthread libgomp.a libgfortran.a - ${CUDA_TOOLKIT_ROOT_DIR}/lib64/stubs/libnvidia-ml.so ) if (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") @@ -152,7 +141,11 @@ if (NOT ${CMAKE_SYSTEM_PROCESSOR} MATCHES "aarch64") endif () cuda_add_library(milvus_engine STATIC ${engine_files}) -target_link_libraries(milvus_engine ${engine_libs} knowhere ${third_party_libs}) +target_link_libraries(milvus_engine + knowhere + ${engine_libs} + ${third_party_libs} + ) add_library(metrics STATIC ${metrics_files}) @@ -180,7 +173,9 @@ add_executable(milvus_server ${utils_files} ) -target_link_libraries(milvus_server ${server_libs}) +target_link_libraries(milvus_server + ${server_libs} + ) install(TARGETS milvus_server DESTINATION bin) diff --git a/cpp/src/sdk/CMakeLists.txt b/cpp/src/sdk/CMakeLists.txt index e7bf989e96ad75533898c060afc877884f2cb469..a2991a49b4a4a305bf80d8cd5074218689b23bbd 100644 --- a/cpp/src/sdk/CMakeLists.txt +++ b/cpp/src/sdk/CMakeLists.txt @@ -17,11 +17,9 @@ # under the License. #------------------------------------------------------------------------------- - -aux_source_directory(interface interface_files) - include_directories(include) +aux_source_directory(interface interface_files) aux_source_directory(grpc grpc_client_files) add_library(milvus_sdk STATIC diff --git a/cpp/src/sdk/examples/grpcsimple/src/ClientTest.cpp b/cpp/src/sdk/examples/grpcsimple/src/ClientTest.cpp index 45ea70797522de1532a55fe82d0483af4da44258..ce511714b2882312b6e417fa65b27ec3df61877d 100644 --- a/cpp/src/sdk/examples/grpcsimple/src/ClientTest.cpp +++ b/cpp/src/sdk/examples/grpcsimple/src/ClientTest.cpp @@ -17,7 +17,6 @@ #include "sdk/examples/grpcsimple/src/ClientTest.h" #include "MilvusApi.h" -#include "cache/CpuCacheMgr.h" #include #include diff --git a/cpp/unittest/CMakeLists.txt b/cpp/unittest/CMakeLists.txt index 0f454ccc4336ca15120c56f7dd7b07e57792105e..6c9aeadcd123683abb6c846c6d815e6a4b1e647a 100644 --- a/cpp/unittest/CMakeLists.txt +++ b/cpp/unittest/CMakeLists.txt @@ -17,25 +17,25 @@ # under the License. #------------------------------------------------------------------------------- +include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include") + +foreach(dir ${CORE_INCLUDE_DIRS}) + include_directories(${dir}) +endforeach() + include_directories(${MILVUS_SOURCE_DIR}) include_directories(${MILVUS_ENGINE_SRC}) +include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_files) +link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") +aux_source_directory(${MILVUS_ENGINE_SRC}/cache cache_files) aux_source_directory(${MILVUS_ENGINE_SRC}/config config_files) - +aux_source_directory(${MILVUS_ENGINE_SRC}/metrics metrics_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db db_main_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db/engine db_engine_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db/insert db_insert_files) aux_source_directory(${MILVUS_ENGINE_SRC}/db/meta db_meta_files) -aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler db_scheduler_files) -aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler/context db_scheduler_context_files) -aux_source_directory(${MILVUS_ENGINE_SRC}/db/scheduler/task db_scheduler_task_files) -set(db_scheduler_files - ${db_scheduler_files} - ${db_scheduler_context_files} - ${db_scheduler_task_files} - ) set(grpc_service_files ${MILVUS_ENGINE_SRC}/grpc/gen-milvus/milvus.grpc.pb.cc @@ -44,8 +44,6 @@ set(grpc_service_files ${MILVUS_ENGINE_SRC}/grpc/gen-status/status.pb.cc ) -aux_source_directory(${MILVUS_ENGINE_SRC}/metrics metrics_files) - aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler scheduler_main_files) aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/action scheduler_action_files) aux_source_directory(${MILVUS_ENGINE_SRC}/scheduler/event scheduler_event_files) @@ -63,12 +61,10 @@ set(scheduler_files aux_source_directory(${MILVUS_ENGINE_SRC}/server server_files) aux_source_directory(${MILVUS_ENGINE_SRC}/server/grpc_impl grpc_server_files) - aux_source_directory(${MILVUS_ENGINE_SRC}/utils utils_files) - aux_source_directory(${MILVUS_ENGINE_SRC}/wrapper wrapper_files) -set(unittest_files +set(entry_file ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp) set(helper_files @@ -87,7 +83,6 @@ set(common_files ${db_engine_files} ${db_insert_files} ${db_meta_files} - ${db_scheduler_files} ${metrics_files} ${scheduler_files} ${wrapper_files} @@ -118,12 +113,6 @@ set(unittest_libs cublas ) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) -message(STATUS "CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}") -foreach(dir ${CORE_INCLUDE_DIRS}) - include_directories(${dir}) -endforeach() - add_subdirectory(db) add_subdirectory(wrapper) add_subdirectory(metrics) diff --git a/cpp/unittest/db/CMakeLists.txt b/cpp/unittest/db/CMakeLists.txt index 91a51e484b46651931b101be2f6bbd54b5d19700..2cbf55a208d79b8a59be9c48a34f5908b5bd35b4 100644 --- a/cpp/unittest/db/CMakeLists.txt +++ b/cpp/unittest/db/CMakeLists.txt @@ -20,18 +20,14 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files) -include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include") -link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") - - -set(db_test_files +cuda_add_executable(test_db ${common_files} ${test_files} - ) - -cuda_add_executable(db_test ${db_test_files}) + ) -target_link_libraries(db_test knowhere ${unittest_libs}) +target_link_libraries(test_db + knowhere + ${unittest_libs}) -install(TARGETS db_test DESTINATION unittest) +install(TARGETS test_db DESTINATION unittest) diff --git a/cpp/unittest/db/db_tests.cpp b/cpp/unittest/db/test_db.cpp similarity index 100% rename from cpp/unittest/db/db_tests.cpp rename to cpp/unittest/db/test_db.cpp diff --git a/cpp/unittest/db/mysql_db_test.cpp b/cpp/unittest/db/test_db_mysql.cpp similarity index 100% rename from cpp/unittest/db/mysql_db_test.cpp rename to cpp/unittest/db/test_db_mysql.cpp diff --git a/cpp/unittest/db/engine_test.cpp b/cpp/unittest/db/test_engine.cpp similarity index 100% rename from cpp/unittest/db/engine_test.cpp rename to cpp/unittest/db/test_engine.cpp diff --git a/cpp/unittest/db/mem_test.cpp b/cpp/unittest/db/test_mem.cpp similarity index 100% rename from cpp/unittest/db/mem_test.cpp rename to cpp/unittest/db/test_mem.cpp diff --git a/cpp/unittest/db/meta_tests.cpp b/cpp/unittest/db/test_meta.cpp similarity index 100% rename from cpp/unittest/db/meta_tests.cpp rename to cpp/unittest/db/test_meta.cpp diff --git a/cpp/unittest/db/mysql_meta_test.cpp b/cpp/unittest/db/test_meta_mysql.cpp similarity index 100% rename from cpp/unittest/db/mysql_meta_test.cpp rename to cpp/unittest/db/test_meta_mysql.cpp diff --git a/cpp/unittest/db/misc_test.cpp b/cpp/unittest/db/test_misc.cpp similarity index 100% rename from cpp/unittest/db/misc_test.cpp rename to cpp/unittest/db/test_misc.cpp diff --git a/cpp/unittest/db/search_test.cpp b/cpp/unittest/db/test_search.cpp similarity index 100% rename from cpp/unittest/db/search_test.cpp rename to cpp/unittest/db/test_search.cpp diff --git a/cpp/unittest/metrics/CMakeLists.txt b/cpp/unittest/metrics/CMakeLists.txt index 04eab826bc3f3451516cba92965f4219fb571011..eba8146baa7b0a5b225aed8f16976830b29e0c60 100644 --- a/cpp/unittest/metrics/CMakeLists.txt +++ b/cpp/unittest/metrics/CMakeLists.txt @@ -19,16 +19,13 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files) -include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include") -link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") - -set(metrics_test_files +add_executable(test_metrics ${common_files} ${test_files} ) -add_executable(metrics_test ${metrics_test_files}) - -target_link_libraries(metrics_test knowhere ${unittest_libs}) +target_link_libraries(test_metrics + knowhere + ${unittest_libs}) -install(TARGETS metrics_test DESTINATION unittest) \ No newline at end of file +install(TARGETS test_metrics DESTINATION unittest) \ No newline at end of file diff --git a/cpp/unittest/metrics/metricbase_test.cpp b/cpp/unittest/metrics/test_metricbase.cpp similarity index 100% rename from cpp/unittest/metrics/metricbase_test.cpp rename to cpp/unittest/metrics/test_metricbase.cpp diff --git a/cpp/unittest/metrics/metrics_test.cpp b/cpp/unittest/metrics/test_metrics.cpp similarity index 100% rename from cpp/unittest/metrics/metrics_test.cpp rename to cpp/unittest/metrics/test_metrics.cpp diff --git a/cpp/unittest/metrics/prometheus_test.cpp b/cpp/unittest/metrics/test_prometheus.cpp similarity index 100% rename from cpp/unittest/metrics/prometheus_test.cpp rename to cpp/unittest/metrics/test_prometheus.cpp diff --git a/cpp/unittest/scheduler/CMakeLists.txt b/cpp/unittest/scheduler/CMakeLists.txt index 27ee11775c2420c8ab25ebfaef84c920c43b8603..087f93f017c38f7b9858f46f17abe0f03bc0b7ad 100644 --- a/cpp/unittest/scheduler/CMakeLists.txt +++ b/cpp/unittest/scheduler/CMakeLists.txt @@ -19,18 +19,15 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files) -include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include") -link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") - -set(scheduler_test_files +cuda_add_executable(test_scheduler ${common_files} - ${unittest_files} + ${entry_file} ${test_files} ) -cuda_add_executable(scheduler_test ${scheduler_test_files}) - -target_link_libraries(scheduler_test knowhere ${unittest_libs}) +target_link_libraries(test_scheduler + knowhere + ${unittest_libs}) -install(TARGETS scheduler_test DESTINATION unittest) +install(TARGETS test_scheduler DESTINATION unittest) diff --git a/cpp/unittest/scheduler/algorithm_test.cpp b/cpp/unittest/scheduler/test_algorithm.cpp similarity index 100% rename from cpp/unittest/scheduler/algorithm_test.cpp rename to cpp/unittest/scheduler/test_algorithm.cpp diff --git a/cpp/unittest/scheduler/event_test.cpp b/cpp/unittest/scheduler/test_event.cpp similarity index 100% rename from cpp/unittest/scheduler/event_test.cpp rename to cpp/unittest/scheduler/test_event.cpp diff --git a/cpp/unittest/scheduler/node_test.cpp b/cpp/unittest/scheduler/test_node.cpp similarity index 100% rename from cpp/unittest/scheduler/node_test.cpp rename to cpp/unittest/scheduler/test_node.cpp diff --git a/cpp/unittest/scheduler/normal_test.cpp b/cpp/unittest/scheduler/test_normal.cpp similarity index 100% rename from cpp/unittest/scheduler/normal_test.cpp rename to cpp/unittest/scheduler/test_normal.cpp diff --git a/cpp/unittest/scheduler/resource_test.cpp b/cpp/unittest/scheduler/test_resource.cpp similarity index 100% rename from cpp/unittest/scheduler/resource_test.cpp rename to cpp/unittest/scheduler/test_resource.cpp diff --git a/cpp/unittest/scheduler/resource_factory_test.cpp b/cpp/unittest/scheduler/test_resource_factory.cpp similarity index 100% rename from cpp/unittest/scheduler/resource_factory_test.cpp rename to cpp/unittest/scheduler/test_resource_factory.cpp diff --git a/cpp/unittest/scheduler/resource_mgr_test.cpp b/cpp/unittest/scheduler/test_resource_mgr.cpp similarity index 100% rename from cpp/unittest/scheduler/resource_mgr_test.cpp rename to cpp/unittest/scheduler/test_resource_mgr.cpp diff --git a/cpp/unittest/scheduler/schedinst_test.cpp b/cpp/unittest/scheduler/test_schedinst.cpp similarity index 100% rename from cpp/unittest/scheduler/schedinst_test.cpp rename to cpp/unittest/scheduler/test_schedinst.cpp diff --git a/cpp/unittest/scheduler/scheduler_test.cpp b/cpp/unittest/scheduler/test_scheduler.cpp similarity index 100% rename from cpp/unittest/scheduler/scheduler_test.cpp rename to cpp/unittest/scheduler/test_scheduler.cpp diff --git a/cpp/unittest/scheduler/tasktable_test.cpp b/cpp/unittest/scheduler/test_tasktable.cpp similarity index 100% rename from cpp/unittest/scheduler/tasktable_test.cpp rename to cpp/unittest/scheduler/test_tasktable.cpp diff --git a/cpp/unittest/server/CMakeLists.txt b/cpp/unittest/server/CMakeLists.txt index d5bbd6cc47f5783f89b4ffac7c30b3c5788a36e5..4420e2a1a7777c6e9261799f7a0a7b2abfe1fc79 100644 --- a/cpp/unittest/server/CMakeLists.txt +++ b/cpp/unittest/server/CMakeLists.txt @@ -43,11 +43,11 @@ set(server_test_files ${grpc_server_files} ${grpc_service_files} ${util_files} - ${unittest_files} + ${entry_file} ${test_files} ) -cuda_add_executable(server_test ${server_test_files}) +cuda_add_executable(test_server ${server_test_files}) set(client_grpc_lib grpcpp_channelz @@ -56,7 +56,7 @@ set(client_grpc_lib grpc_protobuf grpc_protoc) -target_link_libraries(server_test +target_link_libraries(test_server knowhere stdc++ snappy @@ -66,7 +66,7 @@ target_link_libraries(server_test ${unittest_libs} ) -install(TARGETS server_test DESTINATION unittest) +install(TARGETS test_server DESTINATION unittest) configure_file(appendix/server_config.yaml "${CMAKE_CURRENT_BINARY_DIR}/milvus/conf/server_config.yaml" diff --git a/cpp/unittest/server/cache_test.cpp b/cpp/unittest/server/test_cache.cpp similarity index 100% rename from cpp/unittest/server/cache_test.cpp rename to cpp/unittest/server/test_cache.cpp diff --git a/cpp/unittest/server/config_test.cpp b/cpp/unittest/server/test_config.cpp similarity index 100% rename from cpp/unittest/server/config_test.cpp rename to cpp/unittest/server/test_config.cpp diff --git a/cpp/unittest/server/rpc_test.cpp b/cpp/unittest/server/test_rpc.cpp similarity index 100% rename from cpp/unittest/server/rpc_test.cpp rename to cpp/unittest/server/test_rpc.cpp diff --git a/cpp/unittest/wrapper/CMakeLists.txt b/cpp/unittest/wrapper/CMakeLists.txt index 633cbaf0534a9eba5ad3b66c5061236a8ab2634d..8eae47b3d4c710249b311b727939ab3765a41eab 100644 --- a/cpp/unittest/wrapper/CMakeLists.txt +++ b/cpp/unittest/wrapper/CMakeLists.txt @@ -17,8 +17,7 @@ # under the License. #------------------------------------------------------------------------------- -include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include") -link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") +aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} test_files) set(wrapper_files ${MILVUS_ENGINE_SRC}/wrapper/DataTransfer.cpp @@ -31,13 +30,13 @@ set(util_files ${MILVUS_ENGINE_SRC}/utils/Status.cpp ) -set(knowhere_libs - knowhere - cudart - cublas - ) +add_executable(test_wrapper + ${test_files} + ${wrapper_files} + ${util_files}) -add_executable(wrapper_test wrapper_test.cpp ${wrapper_files} ${util_files}) -target_link_libraries(wrapper_test ${knowhere_libs} ${unittest_libs}) +target_link_libraries(test_wrapper + knowhere + ${unittest_libs}) -install(TARGETS wrapper_test DESTINATION unittest) \ No newline at end of file +install(TARGETS test_wrapper DESTINATION unittest) \ No newline at end of file diff --git a/cpp/unittest/wrapper/wrapper_test.cpp b/cpp/unittest/wrapper/test_wrapper.cpp similarity index 99% rename from cpp/unittest/wrapper/wrapper_test.cpp rename to cpp/unittest/wrapper/test_wrapper.cpp index 432739e482e7fbc3a0f76023467e0791c6ece6e8..b97b96d2052de071f46165ff90f31ca5366811fb 100644 --- a/cpp/unittest/wrapper/wrapper_test.cpp +++ b/cpp/unittest/wrapper/test_wrapper.cpp @@ -16,7 +16,7 @@ // under the License. #include "utils/easylogging++.h" -#include "src/wrapper/VecIndex.h" +#include "wrapper/VecIndex.h" #include "knowhere/index/vector_index/helpers/FaissGpuResourceMgr.h" #include "knowhere/index/vector_index/helpers/IndexParameter.h" #include "wrapper/utils.h"