diff --git a/core/CMakeLists.txt b/core/CMakeLists.txt index 79ae64f03b..dbed0fb41a 100644 --- a/core/CMakeLists.txt +++ b/core/CMakeLists.txt @@ -2,8 +2,7 @@ project(sulvim_core) cmake_minimum_required(VERSION 3.16) set( CMAKE_CXX_STANDARD 17 ) set( CMAKE_CXX_STANDARD_REQUIRED on ) - - +set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake") include_directories(src) add_subdirectory(src) add_subdirectory(unittest) diff --git a/core/cmake/FindGTest.cmake b/core/cmake/FindGTest.cmake new file mode 100644 index 0000000000..58a899b8b1 --- /dev/null +++ b/core/cmake/FindGTest.cmake @@ -0,0 +1,45 @@ +########################### GTEST +# Enable ExternalProject CMake module +INCLUDE(ExternalProject) + +# Set default ExternalProject root directory +SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/third_party) + +# Add gtest +# http://stackoverflow.com/questions/9689183/cmake-googletest +ExternalProject_Add( + googletest + URL http://ss2.fluorinedog.com/data/gtest_v1.10.x.zip + # TIMEOUT 10 + # # Force separate output paths for debug and release builds to allow easy + # # identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands + # CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs + # -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs + # -Dgtest_force_shared_crt=ON + # Disable install step + INSTALL_COMMAND "" + # Wrap download, configure and build steps in a script to log output + LOG_DOWNLOAD ON + LOG_CONFIGURE ON + LOG_BUILD ON) + +# Specify include dir +ExternalProject_Get_Property(googletest source_dir) +set(GTEST_INCLUDE_DIR ${source_dir}/include) + +# Library +ExternalProject_Get_Property(googletest binary_dir) + +# set(GTEST_LIBRARY_PATH ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a) +# set(GTEST_LIBRARY gtest) +# add_library(${GTEST_LIBRARY} UNKNOWN IMPORTED) +# set_property(TARGET ${GTEST_LIBRARY} PROPERTY IMPORTED_LOCATION +# ${GTEST_LIBRARY_PATH} ) +# add_dependencies(${GTEST_LIBRARY} googletest) +set(GTEST_LIBRARY_PATH ${binary_dir}/lib) +add_library(gtest UNKNOWN IMPORTED) +add_library(gtest_main UNKNOWN IMPORTED) +set_property(TARGET gtest PROPERTY IMPORTED_LOCATION ${GTEST_LIBRARY_PATH}/libgtest.a) +set_property(TARGET gtest_main PROPERTY IMPORTED_LOCATION ${GTEST_LIBRARY_PATH}/libgtest_main.a) +add_dependencies(gtest googletest) +add_dependencies(gtest_main googletest) diff --git a/core/src/dog_segment/CMakeLists.txt b/core/src/dog_segment/CMakeLists.txt index 4f0744641e..e258c28ba9 100644 --- a/core/src/dog_segment/CMakeLists.txt +++ b/core/src/dog_segment/CMakeLists.txt @@ -7,4 +7,4 @@ add_library(milvus_dog_segment ${DOG_SEGMENT_FILES} ) #add_dependencies( segment sqlite mysqlpp ) -target_link_libraries(milvus_dog_segment tbb milvus_utils) \ No newline at end of file +target_link_libraries(milvus_dog_segment tbb milvus_utils pthread) \ No newline at end of file diff --git a/core/unittest/CMakeLists.txt b/core/unittest/CMakeLists.txt index e69de29bb2..5c07c0d9b4 100644 --- a/core/unittest/CMakeLists.txt +++ b/core/unittest/CMakeLists.txt @@ -0,0 +1,15 @@ +enable_testing() +find_package(GTest REQUIRED) +set(MILVUS_TEST_FILES + test_dog_segment.cpp +) +add_executable(all_tests + ${MILVUS_TEST_FILES} +) + +target_link_libraries(all_tests + gtest + gtest_main + milvus_dog_segment + pthread +) \ No newline at end of file diff --git a/core/unittest/test_dog_segment.cpp b/core/unittest/test_dog_segment.cpp index 7a89a9f461..e8e9a957b5 100644 --- a/core/unittest/test_dog_segment.cpp +++ b/core/unittest/test_dog_segment.cpp @@ -26,14 +26,16 @@ // #include "segment/SegmentWriter.h" // #include "src/dog_segment/SegmentBase.h" // #include "utils/Json.h" +#include +#include #include "dog_segment/SegmentBase.h" using std::cin; using std::cout; using std::endl; -using SegmentVisitor = milvus::engine::SegmentVisitor; +// using SegmentVisitor = milvus::engine::SegmentVisitor; -namespace { +// namespace { // milvus::Status // CreateCollection(std::shared_ptr db, const std::string& collection_name, const LSN_TYPE& lsn) { // CreateCollectionContext context; @@ -73,7 +75,7 @@ namespace { // } // } // namespace -TEST_F(DogSegmentTest, TestABI) { +TEST(DogSegmentTest, TestABI) { using namespace milvus::engine; using namespace milvus::dog_segment; ASSERT_EQ(TestABI(), 42); @@ -135,7 +137,7 @@ TEST_F(DogSegmentTest, TestABI) { -TEST_F(DogSegmentTest, MockTest) { +TEST(DogSegmentTest, MockTest) { using namespace milvus::dog_segment; using namespace milvus::engine; auto schema = std::make_shared(); @@ -161,11 +163,12 @@ TEST_F(DogSegmentTest, MockTest) { auto line_sizeof = (sizeof(int) + sizeof(float) * 16); assert(raw_data.size() == line_sizeof * N); - auto segment = CreateSegment(schema); + auto segment = CreateSegment(schema).release(); DogDataChunk data_chunk{raw_data.data(), (int)line_sizeof, N}; segment->Insert(N, uids.data(), timestamps.data(), data_chunk); QueryResult query_result; segment->Query(nullptr, 0, query_result); + delete segment; int i = 0; i++; } diff --git a/proxy/CMakeLists.txt b/proxy/CMakeLists.txt index 581f5d5f7c..47159345c7 100644 --- a/proxy/CMakeLists.txt +++ b/proxy/CMakeLists.txt @@ -21,11 +21,11 @@ include( Utils ) get_current_time( BUILD_TIME ) message( STATUS "Build time = ${BUILD_TIME}" ) -get_build_type( TARGET BUILD_TYPE +get_build_type( TARGET BUILD_TYPE DEFAULT "Release" ) message( STATUS "Build type = ${BUILD_TYPE}" ) -get_milvus_version( TARGET MILVUS_VERSION +get_milvus_version( TARGET MILVUS_VERSION DEFAULT "0.10.0" ) message( STATUS "Build version = ${MILVUS_VERSION}" ) @@ -48,6 +48,7 @@ set( MILVUS_SOURCE_DIR ${PROJECT_SOURCE_DIR} ) set( MILVUS_BINARY_DIR ${PROJECT_BINARY_DIR} ) set( MILVUS_ENGINE_SRC ${PROJECT_SOURCE_DIR}/src ) set( MILVUS_THIRDPARTY_SRC ${PROJECT_SOURCE_DIR}/thirdparty ) +set(pulsar_ROOT "${MILVUS_BINARY_DIR}/thirdparty/pulsar" CACHE STRING "") # This will set RPATH to all excutable TARGET # self-installed dynamic libraries will be correctly linked by excutable diff --git a/proxy/src/CMakeLists.txt b/proxy/src/CMakeLists.txt index 85e7a2a6dc..f32199a222 100644 --- a/proxy/src/CMakeLists.txt +++ b/proxy/src/CMakeLists.txt @@ -18,6 +18,9 @@ include_directories(${MILVUS_THIRDPARTY_SRC}) include_directories(${MILVUS_ENGINE_SRC}/grpc/gen-status) include_directories(${MILVUS_ENGINE_SRC}/grpc/gen-milvus) +include_directories(${pulsar_ROOT}/build/include) +link_directories(${pulsar_ROOT}/build/lib) + add_subdirectory( tracing ) add_subdirectory( utils ) add_subdirectory( config ) @@ -60,6 +63,7 @@ set( THIRD_PARTY_LIBS target_link_libraries( server PUBLIC ${link_lib} tracing + libpulsar ${THIRD_PARTY_LIBS} ${BOOST_LIB} ) diff --git a/proxy/src/main.cpp b/proxy/src/main.cpp index 3736ecd61f..d231d80563 100644 --- a/proxy/src/main.cpp +++ b/proxy/src/main.cpp @@ -21,9 +21,12 @@ #include "src/version.h" #include "utils/SignalHandler.h" #include "utils/Status.h" +#include "pulsar/Client.h" INITIALIZE_EASYLOGGINGPP +auto c = pulsar::Client("12"); + void print_help(const std::string& app_name) { std::cout << std::endl << "Usage: " << app_name << " [OPTIONS]" << std::endl; diff --git a/proxy/src/version.h b/proxy/src/version.h index b469eb6736..123176a5dc 100644 --- a/proxy/src/version.h +++ b/proxy/src/version.h @@ -11,5 +11,5 @@ #define MILVUS_VERSION "0.10.0" #define BUILD_TYPE "Debug" -#define BUILD_TIME "2020-08-26 10:38.42" -#define LAST_COMMIT_ID "d4541146463566c35477391afb0573a57b00a94e" +#define BUILD_TIME "2020-08-26 19:22.49" +#define LAST_COMMIT_ID "2a5c8e152bc9dbc0653aa4aae2c712b59661bf58" diff --git a/proxy/thirdparty/CMakeLists.txt b/proxy/thirdparty/CMakeLists.txt index a3ea31b1e5..68c4f2a352 100644 --- a/proxy/thirdparty/CMakeLists.txt +++ b/proxy/thirdparty/CMakeLists.txt @@ -55,5 +55,5 @@ endif() # ****************************** Thirdparty pulsar-client-cpp *************************************** if ( MILVUS_WITH_PULSAR ) - add_subdirectory(pulsar-client-cpp) + include(pulsar-client-cpp/CMakeLists.txt) endif() \ No newline at end of file diff --git a/proxy/thirdparty/pulsar-client-cpp/CMakeLists.txt b/proxy/thirdparty/pulsar-client-cpp/CMakeLists.txt index 289dfbb846..332f3bf215 100644 --- a/proxy/thirdparty/pulsar-client-cpp/CMakeLists.txt +++ b/proxy/thirdparty/pulsar-client-cpp/CMakeLists.txt @@ -20,27 +20,38 @@ endif () message(STATUS "Building pulsar-client-cpp-${PULSAR_CLIENT_CPP_VERSION} from source") -FetchContent_Declare( +include(ExternalProject) +ExternalProject_Add( pulsar URL ${PULSAR_URL} - # URL_MD5 "f9137c5bc18b7d74027936f0f1bfa5c8" - DOWNLOAD_DIR ${MILVUS_BINARY_DIR}/3rdparty_download/download + PREFIX ${pulsar_ROOT} + CONFIGURE_COMMAND cd ${pulsar_ROOT}/src/pulsar/pulsar-client-cpp && cmake -DBUILD_TESTS=OFF -DCMAKE_INSTALL_PREFIX=${pulsar_ROOT}/build . + BUILD_COMMAND cd ${pulsar_ROOT}/src/pulsar/pulsar-client-cpp && make -j8 + BUILD_IN_SOURCE true + INSTALL_COMMAND cd ${pulsar_ROOT}/src/pulsar/pulsar-client-cpp && make install ) - - -if (NOT pulsar_POPULATED) - FetchContent_Populate(pulsar) - - # Adding the following targets: - # pulsar-client-cpp - add_subdirectory(${pulsar_SOURCE_DIR}/pulsar-client-cpp - ${pulsar_BINARY_DIR} - EXCLUDE_FROM_ALL) -endif () - - -#get_target_property( YAML_CPP_INCLUDE_DIR pulsar-client-cpp INTERFACE_INCLUDE_DIRECTORIES ) -#message( STATUS ${YAML_CPP_INCLUDE_DIR} ) - -get_property(var DIRECTORY "${pulsar_SOURCE_DIR}/pulsar-client-cpp" PROPERTY COMPILE_OPTIONS) -message(STATUS "pulsar-client-cpp compile options: ${var}") +#FetchContent_Declare( +# pulsar +# URL ${PULSAR_URL} +# # URL_MD5 "f9137c5bc18b7d74027936f0f1bfa5c8" +# DOWNLOAD_DIR ${MILVUS_BINARY_DIR}/3rdparty_download/download +# SOURCE_DIR ${CMAKE_CURRENT_BINARY_DIR}/pulsar-client-cpp-src +# BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/pulsar-client-cpp-build +#) +# +#include(FetchContent) +#FetchContent_GetProperties( pulsar ) +#SET(BUILD_TESTS CACHE BOOL OFF FORCE) +#if (NOT pulsar_POPULATED) +# FetchContent_Populate(pulsar) +# +# # Adding the following targets: +# # pulsar-client-cpp +# add_subdirectory(${pulsar_SOURCE_DIR}/pulsar-client-cpp +# ${pulsar_BINARY_DIR}/pulsar-client-cpp +# EXCLUDE_FROM_ALL) +#endif () +# +#include_directories(${pulsar_SOURCE_DIR}/pulsar-client-cpp/include) +#get_property(var DIRECTORY "${pulsar_SOURCE_DIR}/pulsar-client-cpp" PROPERTY COMPILE_OPTIONS) +#message(STATUS "pulsar-client-cpp compile options: ${var}")