From 6c836b451fe552f8749228d46a6c703ed14c31a9 Mon Sep 17 00:00:00 2001 From: jinhai Date: Wed, 19 Jun 2019 15:46:14 +0800 Subject: [PATCH 1/4] MS-98 Install unit test to installation directory Former-commit-id: 26e87924a3a67cf766e471af5d7ee4b84de1b191 --- cpp/CHANGELOG.md | 1 + cpp/src/CMakeLists.txt | 9 --------- cpp/src/sdk/CMakeLists.txt | 2 ++ cpp/src/sdk/examples/simple/CMakeLists.txt | 2 ++ cpp/unittest/db/CMakeLists.txt | 4 +++- cpp/unittest/faiss_wrapper/CMakeLists.txt | 5 ++--- cpp/unittest/main.cpp | 6 ------ cpp/unittest/metrics/CMakeLists.txt | 9 ++++----- cpp/unittest/server/CMakeLists.txt | 4 +++- cpp/unittest/storage/CMakeLists.txt | 4 +++- .../storage/{s3_client_test.cpp => S3ClientTest.cpp} | 0 11 files changed, 20 insertions(+), 26 deletions(-) rename cpp/unittest/storage/{s3_client_test.cpp => S3ClientTest.cpp} (100%) diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 0b257f2a03..f9de15f20d 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -15,6 +15,7 @@ Please mark all change in change log and use the ticket from JIRA. - MS-77 - Performance issue of post-search action - MS-22 - Enhancement for MemVector size control - MS-92 - Unify behavior of debug and release build +- MS-98 - Install all unit test to installation directory ## New Feature diff --git a/cpp/src/CMakeLists.txt b/cpp/src/CMakeLists.txt index 4645ffcbe6..47d4d97bd1 100644 --- a/cpp/src/CMakeLists.txt +++ b/cpp/src/CMakeLists.txt @@ -152,7 +152,6 @@ add_executable(milvus_server ${utils_files} ${service_files} ${metrics_files} - #${EASYLOGGINGPP_INCLUDE_DIR}/easylogging++.cc ) if (ENABLE_LICENSE STREQUAL "ON") @@ -175,11 +174,3 @@ endif () install(TARGETS milvus_server DESTINATION bin) add_subdirectory(sdk) -#target_link_libraries( -# libprometheus-cpp-push.a -# libprometheus-cpp-pull.a -# libprometheus-cpp-core.a -# pthread -# z -# ${CURL_LIBRARIES}) - diff --git a/cpp/src/sdk/CMakeLists.txt b/cpp/src/sdk/CMakeLists.txt index 093e2243a9..a43f0b85de 100644 --- a/cpp/src/sdk/CMakeLists.txt +++ b/cpp/src/sdk/CMakeLists.txt @@ -31,3 +31,5 @@ target_link_libraries(milvus_sdk ) add_subdirectory(examples) + +install(TARGETS milvus_sdk DESTINATION bin) diff --git a/cpp/src/sdk/examples/simple/CMakeLists.txt b/cpp/src/sdk/examples/simple/CMakeLists.txt index cad08d856c..a288965aa3 100644 --- a/cpp/src/sdk/examples/simple/CMakeLists.txt +++ b/cpp/src/sdk/examples/simple/CMakeLists.txt @@ -20,3 +20,5 @@ target_link_libraries(sdk_simple milvus_sdk pthread ) + +install(TARGETS sdk_simple DESTINATION bin) diff --git a/cpp/unittest/db/CMakeLists.txt b/cpp/unittest/db/CMakeLists.txt index 67ef5fccec..9367f53d67 100644 --- a/cpp/unittest/db/CMakeLists.txt +++ b/cpp/unittest/db/CMakeLists.txt @@ -29,7 +29,7 @@ set(db_test_src cuda_add_executable(db_test ${db_test_src}) set(db_libs - gpufaiss + libgpufaiss.a faiss cudart cublas @@ -40,3 +40,5 @@ set(db_libs ) target_link_libraries(db_test ${db_libs} ${unittest_libs}) + +install(TARGETS db_test DESTINATION bin) \ No newline at end of file diff --git a/cpp/unittest/faiss_wrapper/CMakeLists.txt b/cpp/unittest/faiss_wrapper/CMakeLists.txt index b0830d5a87..f044df8d8c 100644 --- a/cpp/unittest/faiss_wrapper/CMakeLists.txt +++ b/cpp/unittest/faiss_wrapper/CMakeLists.txt @@ -24,7 +24,7 @@ set(wrapper_libs stdc++ boost_system boost_filesystem - gpufaiss + libgpufaiss.a faiss cudart cublas @@ -41,5 +41,4 @@ set(topk_test_src topk_test.cpp ${CMAKE_SOURCE_DIR}/src/wrapper/gpu/Topk.cu) -#cuda_add_executable(topk_test ${topk_test_src}) -#target_link_libraries(topk_test ${unittest_libs} ${faiss_libs}) +install(TARGETS wrapper_test DESTINATION bin) diff --git a/cpp/unittest/main.cpp b/cpp/unittest/main.cpp index 930310fd93..dac5bc7013 100644 --- a/cpp/unittest/main.cpp +++ b/cpp/unittest/main.cpp @@ -15,12 +15,6 @@ INITIALIZE_EASYLOGGINGPP using namespace zilliz::milvus; int main(int argc, char **argv) { - std::string exe_path = server::CommonUtil::GetExePath(); - std::string config_filename = exe_path + "/../../../conf/server_config.yaml"; - zilliz::milvus::server::ServerConfig& config = zilliz::milvus::server::ServerConfig::GetInstance(); - config.LoadConfigFile(config_filename); - std::cout << "Load config file form: " << config_filename << std::endl; - ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/cpp/unittest/metrics/CMakeLists.txt b/cpp/unittest/metrics/CMakeLists.txt index 2f07cbed24..b138dcecac 100644 --- a/cpp/unittest/metrics/CMakeLists.txt +++ b/cpp/unittest/metrics/CMakeLists.txt @@ -55,7 +55,7 @@ set(count_test_src add_executable(metrics_test ${count_test_src} ${require_files} ) target_link_libraries(metrics_test - gpufaiss + libgpufaiss.a faiss cudart cublas @@ -65,10 +65,9 @@ target_link_libraries(metrics_test lz4 metrics gtest -# prometheus-cpp-pull -# prometheus-cpp-push -# prometheus-cpp-core pthread z ${unittest_libs} - ) \ No newline at end of file + ) + +install(TARGETS metrics_test DESTINATION bin) \ No newline at end of file diff --git a/cpp/unittest/server/CMakeLists.txt b/cpp/unittest/server/CMakeLists.txt index 40677d23c9..d844b7a9a3 100644 --- a/cpp/unittest/server/CMakeLists.txt +++ b/cpp/unittest/server/CMakeLists.txt @@ -31,7 +31,7 @@ cuda_add_executable(server_test set(require_libs stdc++ - gpufaiss + libgpufaiss.a faiss cudart cublas @@ -51,3 +51,5 @@ target_link_libraries(server_test ${cuda_library} ${unittest_libs} ) + +install(TARGETS server_test DESTINATION bin) diff --git a/cpp/unittest/storage/CMakeLists.txt b/cpp/unittest/storage/CMakeLists.txt index 019f3d3635..de55596f05 100644 --- a/cpp/unittest/storage/CMakeLists.txt +++ b/cpp/unittest/storage/CMakeLists.txt @@ -13,7 +13,7 @@ set(s3_client_test_src ${unittest_srcs} ${s3_client_src} ${require_files} - s3_client_test.cpp + S3ClientTest.cpp ${MILVUS_ENGINE_SRC}/db/Status.cpp ) @@ -35,3 +35,5 @@ target_link_libraries(s3_test ${unittest_libs} curl crypto) + +install(TARGETS s3_test DESTINATION bin) \ No newline at end of file diff --git a/cpp/unittest/storage/s3_client_test.cpp b/cpp/unittest/storage/S3ClientTest.cpp similarity index 100% rename from cpp/unittest/storage/s3_client_test.cpp rename to cpp/unittest/storage/S3ClientTest.cpp From 60498c5cb5cc8a8616b563ac30abb8676b0424f2 Mon Sep 17 00:00:00 2001 From: jinhai Date: Wed, 19 Jun 2019 16:35:12 +0800 Subject: [PATCH 2/4] MS-99 Fix compilation bug Former-commit-id: 805fe0a9b9b1521c4423d1ab3abb0a0c0f7dac16 --- cpp/unittest/storage/S3ClientTest.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/unittest/storage/S3ClientTest.cpp b/cpp/unittest/storage/S3ClientTest.cpp index 6955232638..c83209ecf6 100644 --- a/cpp/unittest/storage/S3ClientTest.cpp +++ b/cpp/unittest/storage/S3ClientTest.cpp @@ -8,7 +8,6 @@ #include "storage/s3/S3ClientWrapper.h" #include #include -#include #include From 03b79aba6468a3618cf2982ec7737e23616c26cd Mon Sep 17 00:00:00 2001 From: jinhai Date: Wed, 19 Jun 2019 16:35:12 +0800 Subject: [PATCH 3/4] MS-99 Fix compilation bug Former-commit-id: d6f1c84398057572bfb6004935dbec6f1fb7117a --- cpp/unittest/storage/S3ClientTest.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/cpp/unittest/storage/S3ClientTest.cpp b/cpp/unittest/storage/S3ClientTest.cpp index 6955232638..c83209ecf6 100644 --- a/cpp/unittest/storage/S3ClientTest.cpp +++ b/cpp/unittest/storage/S3ClientTest.cpp @@ -8,7 +8,6 @@ #include "storage/s3/S3ClientWrapper.h" #include #include -#include #include From b33165f6c9c3b91538003234ccf0bbcaf14e4bac Mon Sep 17 00:00:00 2001 From: zhiru Date: Thu, 20 Jun 2019 11:54:47 +0800 Subject: [PATCH 4/4] cmake: fix AWS build issue Former-commit-id: 5a7e5b182441a5780d95914ee40b138ea25abac2 --- cpp/CHANGELOG.md | 1 + cpp/cmake/ThirdPartyPackages.cmake | 37 ++++++++++++++++++++++------- cpp/unittest/storage/CMakeLists.txt | 11 ++++----- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/cpp/CHANGELOG.md b/cpp/CHANGELOG.md index 19bea4b97e..94a9479ed4 100644 --- a/cpp/CHANGELOG.md +++ b/cpp/CHANGELOG.md @@ -51,6 +51,7 @@ Please mark all change in change log and use the ticket from JIRA. - MS-34 - Fix prometheus-cpp thirdparty - MS-67 - Fix license check bug - MS-76 - Fix pipeline crash bug +- MS-100 - cmake: fix AWS build issue ## Improvement diff --git a/cpp/cmake/ThirdPartyPackages.cmake b/cpp/cmake/ThirdPartyPackages.cmake index 429d6c9d44..daffe72ec0 100644 --- a/cpp/cmake/ThirdPartyPackages.cmake +++ b/cpp/cmake/ThirdPartyPackages.cmake @@ -1762,7 +1762,10 @@ macro(build_aws) -DENABLE_UNITY_BUILD=on -DNO_ENCRYPTION=off) - set(AWS_STATIC_LIB "${AWS_PREFIX}/lib/libs3.a") + set(AWS_CPP_SDK_CORE_STATIC_LIB + "${AWS_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}aws-cpp-sdk-core${CMAKE_STATIC_LIBRARY_SUFFIX}") + set(AWS_CPP_SDK_S3_STATIC_LIB + "${AWS_PREFIX}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}aws-cpp-sdk-s3${CMAKE_STATIC_LIBRARY_SUFFIX}") # Only pass our C flags on Unix as on MSVC it leads to a # "incompatible command-line options" error set(AWS_CMAKE_ARGS @@ -1788,24 +1791,40 @@ macro(build_aws) URL ${AWS_SOURCE_URL} BUILD_BYPRODUCTS - "${AWS_STATIC_LIB}") + "${AWS_CPP_SDK_S3_STATIC_LIB}" + "${AWS_CPP_SDK_CORE_STATIC_LIB}") file(MAKE_DIRECTORY "${AWS_PREFIX}/include") - add_library(aws STATIC IMPORTED) - set_target_properties(aws - PROPERTIES IMPORTED_LOCATION "${AWS_STATIC_LIB}" - INTERFACE_INCLUDE_DIRECTORIES "${AWS_PREFIX}/include") + add_library(aws-cpp-sdk-s3 STATIC IMPORTED) + set_target_properties(aws-cpp-sdk-s3 + PROPERTIES + IMPORTED_LOCATION "${AWS_CPP_SDK_S3_STATIC_LIB}" + INTERFACE_INCLUDE_DIRECTORIES "${AWS_PREFIX}/include" + INTERFACE_LINK_LIBRARIES "${AWS_PREFIX}/lib/libaws-c-event-stream.a;${AWS_PREFIX}/lib/libaws-checksums.a;${AWS_PREFIX}/lib/libaws-c-common.a") + + add_library(aws-cpp-sdk-core STATIC IMPORTED) + set_target_properties(aws-cpp-sdk-core + PROPERTIES IMPORTED_LOCATION "${AWS_CPP_SDK_CORE_STATIC_LIB}" + INTERFACE_INCLUDE_DIRECTORIES "${AWS_PREFIX}/include" + INTERFACE_LINK_LIBRARIES "${AWS_PREFIX}/lib/libaws-c-event-stream.a;${AWS_PREFIX}/lib/libaws-checksums.a;${AWS_PREFIX}/lib/libaws-c-common.a") + + add_dependencies(aws-cpp-sdk-s3 aws_ep) + add_dependencies(aws-cpp-sdk-core aws_ep) - add_dependencies(aws aws_ep) endmacro() if(MILVUS_WITH_AWS) resolve_dependency(AWS) # TODO: Don't use global includes but rather target_include_directories - get_target_property(AWS_INCLUDE_DIR aws INTERFACE_INCLUDE_DIRECTORIES) link_directories(SYSTEM ${AWS_PREFIX}/lib) - include_directories(SYSTEM ${AWS_INCLUDE_DIR}) + + get_target_property(AWS_CPP_SDK_S3_INCLUDE_DIR aws-cpp-sdk-s3 INTERFACE_INCLUDE_DIRECTORIES) + include_directories(SYSTEM ${AWS_CPP_SDK_S3_INCLUDE_DIR}) + + get_target_property(AWS_CPP_SDK_CORE_INCLUDE_DIR aws-cpp-sdk-core INTERFACE_INCLUDE_DIRECTORIES) + include_directories(SYSTEM ${AWS_CPP_SDK_CORE_INCLUDE_DIR}) + endif() diff --git a/cpp/unittest/storage/CMakeLists.txt b/cpp/unittest/storage/CMakeLists.txt index de55596f05..6b4303b70a 100644 --- a/cpp/unittest/storage/CMakeLists.txt +++ b/cpp/unittest/storage/CMakeLists.txt @@ -6,8 +6,8 @@ aux_source_directory(${MILVUS_ENGINE_SRC}/storage/s3 s3_client_src) # Make sure that your call to link_directories takes place before your call to the relevant add_executable. -include_directories(/usr/local/cuda/include) -link_directories("/usr/local/cuda/lib64") +include_directories("${CUDA_TOOLKIT_ROOT_DIR}/include") +link_directories("${CUDA_TOOLKIT_ROOT_DIR}/lib64") set(s3_client_test_src ${unittest_srcs} @@ -23,11 +23,8 @@ add_executable(s3_test set(s3_client_libs stdc++ - libaws-cpp-sdk-s3.a - libaws-cpp-sdk-core.a - libaws-c-event-stream.a - libaws-checksums.a - libaws-c-common.a + aws-cpp-sdk-s3 + aws-cpp-sdk-core boost_filesystem ) target_link_libraries(s3_test