From bc4f785fa4c0fea558c69b0ee9180b80098fe06a Mon Sep 17 00:00:00 2001 From: Marc Parisi Date: Mon, 30 Oct 2017 11:03:33 -0400 Subject: [PATCH] MINIFICPP-270: Encapsulate extension building into functions that automate the build and test process slightly --- CMakeLists.txt | 72 +++++----- Extensions.md | 21 +++ cmake/BuildTests.cmake | 136 ++++-------------- cmake/Extensions.cmake | 74 ++++++++++ extensions/http-curl/CMakeLists.txt | 5 +- extensions/libarchive/CMakeLists.txt | 6 +- extensions/rocksdb-repos/CMakeLists.txt | 8 +- libminifi/test/archive-tests/CMakeLists.txt | 37 +++++ libminifi/test/curl-tests/CMakeLists.txt | 53 +++++++ .../ControllerServiceIntegrationTests.cpp | 0 libminifi/test/rocksdb-tests/CMakeLists.txt | 36 +++++ main/CMakeLists.txt | 30 ++-- 12 files changed, 304 insertions(+), 174 deletions(-) create mode 100644 cmake/Extensions.cmake create mode 100644 libminifi/test/archive-tests/CMakeLists.txt create mode 100644 libminifi/test/curl-tests/CMakeLists.txt rename libminifi/test/{integration => curl-tests}/ControllerServiceIntegrationTests.cpp (100%) create mode 100644 libminifi/test/rocksdb-tests/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 48859f7a40..51d817f815 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,7 @@ set(PROJECT_VERSION_MINOR 3) set(PROJECT_VERSION_PATCH 0) option(SKIP_TESTS "Skips building all tests." OFF) + include(FeatureSummary) # Use ccache if present @@ -74,11 +75,13 @@ endif (OPENSSL_FOUND) # Provide custom modules for the project list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -find_package(UUID REQUIRED) -file(GLOB SPD_SOURCES "thirdparty/spdlog-20170710/include/spdlog/*") +SET(TEST_DIR ${CMAKE_SOURCE_DIR}/libminifi/test) +include(Extensions) +find_package(UUID REQUIRED) +file(GLOB SPD_SOURCES "thirdparty/spdlog-20170710/include/spdlog/*") include(ExternalProject) @@ -105,40 +108,41 @@ add_subdirectory(thirdparty/civetweb-1.9.1 EXCLUDE_FROM_ALL) include_directories(thirdparty/concurrentqueue) include_directories(thirdparty/yaml-cpp-yaml-cpp-20171024/include) add_subdirectory(libminifi) -if (NOT DISABLE_CURL) - find_package(CURL) - add_subdirectory(extensions/http-curl) - mark_as_advanced(HTTP-CURL) - +#function(createExtension extensionCondition extensionGuard extensionName description dirName) + +## Add http-curl extensions +createExtension(DISABLE_CURL + HTTP-CURL + "HTTP CURL" + "This enables RESTProtocol, InvokeHTTP, and the HTTPClient for Site to Site" + "extensions/http-curl" + "${TEST_DIR}/curl-tests") + +## Add the rocks DB extension +if ( NOT ROCKSDB_FOUND OR BUILD_ROCKSDB ) + set(BUILD_RD "TRUE") endif() - -if (NOT DISABLE_ROCKSDB) - find_package(RocksDB) - if (NOT ROCKSDB_FOUND OR BUILD_ROCKSDB) - add_subdirectory(thirdparty/rocksdb/) - include_directories(thirdparty/rocksdb/include) - else() - include_directories(${ROCKSDB_INCLUDE_DIR}) - endif() - - add_subdirectory(extensions/rocksdb-repos) - mark_as_advanced(ROCKSDB-REPOS) - +createExtension(DISABLE_ROCKSDB + ROCKSDB-REPOS + "ROCKSDB REPOS" + "This Enables persistent provenance, flowfile, and content repositories using RocksDB" + "extensions/rocksdb-repos" + "${TEST_DIR}/rocksdb-tests" + BUILD_RD + "thirdparty/rocksdb/") + +## Create LibArchive Extension +if ( NOT LibArchive_FOUND OR BUILD_LIBARCHIVE ) + set(BUILD_TP "TRUE") endif() - -if (NOT DISABLE_LIBARCHIVE) - find_package(LibArchive) - if (NOT LibArchive_FOUND OR BUILD_LIBARCHIVE) - add_subdirectory(thirdparty/libarchive-3.3.2) - endif() - add_subdirectory(extensions/libarchive) - mark_as_advanced(ARCHIVE-EXTENSIONS) -endif() - -## ENABLE FEATURE INFORMATION -ADD_FEATURE_INFO("HTTP CURL" HTTP-CURL "This enables RESTProtocol, InvokeHTTP, and the HTTPClient for Site to Site") -ADD_FEATURE_INFO("ROCKSDB REPOS" ROCKSDB-REPOS "This Enables persistent provenance, flowfile, and content repositories using RocksDB") -ADD_FEATURE_INFO("ARCHIVE EXTENSIONS" ARCHIVE-EXTENSIONS "This Enables libarchive functionality including MergeContent, CompressContent, and (Un)FocusArchiveEntry") +createExtension(DISABLE_LIBARCHIVE + ARCHIVE-EXTENSIONS + "ARCHIVE EXTENSIONS" + "This Enables libarchive functionality including MergeContent, CompressContent, and (Un)FocusArchiveEntry" + "extensions/libarchive" + "${TEST_DIR}/archive-tests" + BUILD_TP + "thirdparty/libarchive-3.3.2") ## NOW WE CAN ADD LIBRARIES AND EXTENSIONS TO MAIN diff --git a/Extensions.md b/Extensions.md index 7e13243c0e..95625c5867 100644 --- a/Extensions.md +++ b/Extensions.md @@ -27,6 +27,27 @@ This folder contains a CMakeLists file so that we can conditionally build it. In Your CMAKE file should build a static library, that will be included into the run time. This must be added with your conditional to the libminifi CMAKE, along with a platform specific whole archive inclusion. Note that this will ensure that despite no direct linkage being found by the compiler, we will include the code so that we can dynamically find your code. +# Including your extension in the build +There is a new function that can be used in the root cmake to build and included your extension. An example is based on the LibArchive extension. The createExtension function has 8 possible arguments. The first five arguments are required. +The first argument specifies the variable controlling the exclusion of this extension, followed by the variable that +is used when including it into conditional statements. The third argument is the pretty name followed by the description of the extension and the extension directory. The first optional argument is the test directory, which must also contain a CMakeLists.txt file. The seventh argument can be a conditional variable that tells us whether or not to add a third party subdirectory specified by the final extension. + +In the lib archive example, we provide all arguments, but your extension may only need the first five and the the test folder. The seventh and eighth arguments must be included in tandem. + +```cmake +if ( NOT LibArchive_FOUND OR BUILD_LIBARCHIVE ) + set(BUILD_TP "TRUE") +endif() +createExtension(DISABLE_LIBARCHIVE + ARCHIVE-EXTENSIONS + "ARCHIVE EXTENSIONS" + "This Enables libarchive functionality including MergeContent, CompressContent, and (Un)FocusArchiveEntry" + "extensions/libarchive" + "${TEST_DIR}/archive-tests" + BUILD_TP + "thirdparty/libarchive-3.3.2") +``` + # C bindings To find your classes, you must adhere to a dlsym call back that adheres to the core::ObjectFactory class, like the one below. This object factory will return a list of classes, that we can instantiate through the class loader mechanism. Note that since we are including your code directly into our runtime, we will take care of dlopen and dlsym calls. A map from the class name to the object factory is kept in memory. diff --git a/cmake/BuildTests.cmake b/cmake/BuildTests.cmake index 89f34fd516..918cab7e3e 100644 --- a/cmake/BuildTests.cmake +++ b/cmake/BuildTests.cmake @@ -33,55 +33,38 @@ find_package(Boost COMPONENTS system filesystem REQUIRED) function(createTests testName) message ("-- Adding test: ${testName}") - target_include_directories(${testName} PRIVATE BEFORE "thirdparty/catch") - target_include_directories(${testName} PRIVATE BEFORE "thirdparty/spdlog-20170710/include") - target_include_directories(${testName} PRIVATE BEFORE "thirdparty/yaml-cpp-yaml-cpp-0.5.3/include") - target_include_directories(${testName} PRIVATE BEFORE "thirdparty/jsoncpp/include") - target_include_directories(${testName} PRIVATE BEFORE "thirdparty/civetweb-1.9.1/include") - target_include_directories(${testName} PRIVATE BEFORE "thirdparty/libarchive-3.3.2/libarchive") - target_include_directories(${testName} PRIVATE BEFORE "include") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/c2/protocols") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/c2") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/core") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/core/controller") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/core/repository") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/core/yaml") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/core/statemanagement") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/core/statemanagement/metrics") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/io") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/utils") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/processors") - target_include_directories(${testName} PRIVATE BEFORE "libminifi/include/provenance") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/thirdparty/catch") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/thirdparty/spdlog-20170710/include") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/thirdparty/yaml-cpp-yaml-cpp-0.5.3/include") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/thirdparty/jsoncpp/include") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/thirdparty/civetweb-1.9.1/include") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/thirdparty/libarchive-3.3.2/libarchive") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/include") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/c2/protocols") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/c2") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/core") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/core/controller") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/core/repository") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/core/yaml") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/core/statemanagement") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/core/statemanagement/metrics") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/io") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/utils") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/processors") + target_include_directories(${testName} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/libminifi/include/provenance") target_link_libraries(${testName} ${CMAKE_THREAD_LIBS_INIT} ${OPENSSL_LIBRARIES} core-minifi minifi yaml-cpp c-library civetweb-cpp ${JSON_CPP_LIB}) target_link_libraries(${testName} ${Boost_SYSTEM_LIBRARY}) target_link_libraries(${testName} ${Boost_FILESYSTEM_LIBRARY}) - if (CURL_FOUND) - target_include_directories(${testName} PRIVATE BEFORE ${CURL_INCLUDE_DIRS}) - target_include_directories(${testName} PRIVATE BEFORE "extensions/http-curl/") - target_include_directories(${testName} PRIVATE BEFORE "extensions/http-curl/client/") - target_include_directories(${testName} PRIVATE BEFORE "extensions/http-curl/processors/") - target_include_directories(${testName} PRIVATE BEFORE "extensions/http-curl/protocols/") - target_link_libraries(${testName} ${CURL_LIBRARIES} ) - if (APPLE) - target_link_libraries (${testName} -Wl,-all_load ${HTTP-CURL}) - else () - target_link_libraries (${testName} -Wl,--whole-archive ${HTTP-CURL} -Wl,--no-whole-archive) - endif () - endif() endfunction() enable_testing(test) -SET(TEST_DIR ${CMAKE_SOURCE_DIR}/libminifi/test) SET(TEST_RESOURCES ${TEST_DIR}/resources) GETSOURCEFILES(UNIT_TESTS "${TEST_DIR}/unit/") GETSOURCEFILES(INTEGRATION_TESTS "${TEST_DIR}/integration/") -GETSOURCEFILES(CURL_INTEGRATION_TESTS "${TEST_DIR}/curl-tests/") -GETSOURCEFILES(ROCKSDB_INTEGRATION_TESTS "${TEST_DIR}/rocksdb-tests/") -GETSOURCEFILES(ARCHIVE_INTEGRATION_TESTS "${TEST_DIR}/archive-tests/") SET(UNIT_TEST_COUNT 0) FOREACH(testfile ${UNIT_TESTS}) @@ -102,80 +85,11 @@ FOREACH(testfile ${INTEGRATION_TESTS}) ENDFOREACH() message("-- Finished building ${INT_TEST_COUNT} integration test file(s)...") -if (ROCKSDB-REPOS) -SET(ROCKSDB_TEST_COUNT 0) -FOREACH(testfile ${ROCKSDB_INTEGRATION_TESTS}) - get_filename_component(testfilename "${testfile}" NAME_WE) - add_executable("${testfilename}" "${TEST_DIR}/rocksdb-tests/${testfile}" ${SPD_SOURCES} "${TEST_DIR}/TestBase.cpp") - target_include_directories(${testfilename} PRIVATE BEFORE "extensions/rocksdb-repos/") - target_include_directories(${testfilename} PRIVATE BEFORE "thirdparty/rocksdb/include") - if (APPLE) - target_link_libraries (${testfilename} -Wl,-all_load ${ROCKSDB-REPOS}) - else () - target_link_libraries (${testfilename} -Wl,--whole-archive ${ROCKSDB-REPOS} -Wl,--no-whole-archive) - endif () - createTests("${testfilename}") - MATH(EXPR ROCKSDB_TEST_COUNT "${ROCKSDB_TEST_COUNT}+1") -ENDFOREACH() -message("-- Finished building ${ROCKSDB_TEST_COUNT} RocksDB related test file(s)...") -endif(ROCKSDB-REPOS) - -if (ARCHIVE-EXTENSIONS) -SET(EXTENSIONS_TEST_COUNT 0) -FOREACH(testfile ${ARCHIVE_INTEGRATION_TESTS}) - get_filename_component(testfilename "${testfile}" NAME_WE) - add_executable("${testfilename}" "${TEST_DIR}/archive-tests/${testfile}" ${SPD_SOURCES} "${TEST_DIR}/TestBase.cpp") - target_include_directories(${testfilename} PRIVATE BEFORE "extensions/libarchive") - target_include_directories(${testfilename} PRIVATE BEFORE "thirdparty/libarchive-3.3.2/libarchive") - if (APPLE) - target_link_libraries (${testfilename} -Wl,-all_load ${ARCHIVE-EXTENSIONS}) - else () - target_link_libraries (${testfilename} -Wl,--whole-archive ${ARCHIVE-EXTENSIONS} -Wl,--no-whole-archive) - endif () - createTests("${testfilename}") - MATH(EXPR EXTENSIONS_TEST_COUNT "${ROCKSDB_TEST_COUNT}+1") - add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) -ENDFOREACH() -message("-- Finished building ${ARCHIVE-EXTENSIONS_TEST_COUNT} Lib Archive related test file(s)...") -endif(ARCHIVE-EXTENSIONS) - -if (HTTP-CURL) - -SET(CURL_INT_TEST_COUNT 0) -FOREACH(testfile ${CURL_INTEGRATION_TESTS}) - get_filename_component(testfilename "${testfile}" NAME_WE) - add_executable("${testfilename}" "${TEST_DIR}/curl-tests/${testfile}" ${SPD_SOURCES} "${TEST_DIR}/TestBase.cpp") - createTests("${testfilename}") - #message("Adding ${testfilename} from ${testfile}") - MATH(EXPR CURL_INT_TEST_COUNT "${CURL_INT_TEST_COUNT}+1") -ENDFOREACH() -message("-- Finished building ${CURL_INT_TEST_COUNT} libcURL integration test file(s)...") - - - -add_test(NAME HttpGetIntegrationTest COMMAND HttpGetIntegrationTest "${TEST_RESOURCES}/TestHTTPGet.yml" "${TEST_RESOURCES}/") - -add_test(NAME C2UpdateTest COMMAND C2UpdateTest "${TEST_RESOURCES}/TestHTTPGet.yml" "${TEST_RESOURCES}/") - -add_test(NAME HttpGetIntegrationTestSecure COMMAND HttpGetIntegrationTest "${TEST_RESOURCES}/TestHTTPGetSecure.yml" "${TEST_RESOURCES}/") - -add_test(NAME HttpPostIntegrationTest COMMAND HttpPostIntegrationTest "${TEST_RESOURCES}/TestHTTPPost.yml" "${TEST_RESOURCES}/") - -add_test(NAME HttpPostIntegrationTestChunked COMMAND HttpPostIntegrationTest "${TEST_RESOURCES}/TestHTTPPostChunkedEncoding.yml" "${TEST_RESOURCES}/") - -add_test(NAME C2VerifyServeResults COMMAND C2VerifyServeResults "${TEST_RESOURCES}/TestHTTPGet.yml" "${TEST_RESOURCES}/") - -add_test(NAME C2VerifyHeartbeatAndStop COMMAND C2VerifyHeartbeatAndStop "${TEST_RESOURCES}/TestHTTPGet.yml" "${TEST_RESOURCES}/") - -add_test(NAME SiteToSiteRestTest COMMAND SiteToSiteRestTest "${TEST_RESOURCES}/TestSite2SiteRest.yml" "${TEST_RESOURCES}/" "http://localhost:8082/nifi-api/controller") - -## removed due to travis issues with our certs -#add_test(NAME SiteToSiteRestTestSecure COMMAND SiteToSiteRestTest "${TEST_RESOURCES}/TestSite2SiteRestSecure.yml" "${TEST_RESOURCES}/" "https://localhost:8082/nifi-api/controller") - -add_test(NAME ControllerServiceIntegrationTests COMMAND ControllerServiceIntegrationTests "${TEST_RESOURCES}/TestControllerServices.yml" "${TEST_RESOURCES}/") - -add_test(NAME ThreadPoolAdjust COMMAND ThreadPoolAdjust "${TEST_RESOURCES}/TestHTTPPostChunkedEncoding.yml" "${TEST_RESOURCES}/") -endif(HTTP-CURL) +get_property(extensions GLOBAL PROPERTY EXTENSION-TESTS) +foreach(EXTENSION ${extensions}) + message("Adding ${EXTENSION} ? ") + add_subdirectory(${EXTENSION}) +endforeach() add_test(NAME TestExecuteProcess COMMAND TestExecuteProcess ) diff --git a/cmake/Extensions.cmake b/cmake/Extensions.cmake new file mode 100644 index 0000000000..141ea15f9e --- /dev/null +++ b/cmake/Extensions.cmake @@ -0,0 +1,74 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + +define_property(GLOBAL PROPERTY EXTENSION-OPTIONS + BRIEF_DOCS "Global extension list" + FULL_DOCS "Global extension list") + +set_property(GLOBAL PROPERTY EXTENSION-OPTIONS "") + +macro(register_extension extension-name) + get_property(extensions GLOBAL PROPERTY EXTENSION-OPTIONS) + set_property(GLOBAL APPEND PROPERTY EXTENSION-OPTIONS ${extension-name}) +endmacro() + +### TESTING MACROS + +define_property(GLOBAL PROPERTY EXTENSION-TESTS + BRIEF_DOCS "Global extension tests" + FULL_DOCS "Global extension tests") + +set_property(GLOBAL PROPERTY EXTENSION-TESTS "") + +macro(register_extension_test extension-dir) + if (NOT SKIP_TESTS) + get_property(extensions GLOBAL PROPERTY EXTENSION-TESTS) + set_property(GLOBAL APPEND PROPERTY EXTENSION-TESTS "${extension-dir}") + endif() +endmacro() + +function(registerExtension extensionCondition dirName) + if (NOT ${extensionCondition}) + add_subdirectory(${dirName}) + endif() +endfunction(registerExtension) + +function(registerTest dirName) + if (NOT SKIP_TESTS) + add_subdirectory(${dirName}) + endif() +endfunction(registerTest) + +### FUNCTION TO CREATE AN EXTENSION + +function(createExtension extensionCondition extensionGuard extensionName description dirName) + if (NOT ${extensionCondition}) + add_subdirectory(${dirName}) + ADD_FEATURE_INFO("${extensionName}" ${extensionGuard} "${description}") + mark_as_advanced(${extensionGuard}) + if (ARGV5) + register_extension_test(${ARGV5}) + endif(ARGV5) + if (ARGV6 AND ARGV7) + if (${ARGV6}) + add_subdirectory(${ARGV7}) + endif() + endif() + endif() +endfunction(createExtension) + diff --git a/extensions/http-curl/CMakeLists.txt b/extensions/http-curl/CMakeLists.txt index 6989a7d37c..d851aff31c 100644 --- a/extensions/http-curl/CMakeLists.txt +++ b/extensions/http-curl/CMakeLists.txt @@ -17,8 +17,6 @@ # under the License. # -cmake_minimum_required(VERSION 2.6) - find_package(CURL REQUIRED) set(CMAKE_EXE_LINKER_FLAGS "-Wl,--export-all-symbols") @@ -67,7 +65,6 @@ else () ) endif () - SET (HTTP-CURL minifi-http-curl PARENT_SCOPE) - +register_extension(minifi-http-curl) diff --git a/extensions/libarchive/CMakeLists.txt b/extensions/libarchive/CMakeLists.txt index 4050b6103a..0dd24def68 100644 --- a/extensions/libarchive/CMakeLists.txt +++ b/extensions/libarchive/CMakeLists.txt @@ -17,14 +17,13 @@ # under the License. # -cmake_minimum_required(VERSION 2.6) - - set(CMAKE_EXE_LINKER_FLAGS "-Wl,--export-all-symbols") set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-symbols") include_directories(../../libminifi/include ../../libminifi/include/core ../../thirdparty/spdlog-20170710/include ../../thirdparty/concurrentqueue ../../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include ../../thirdparty/civetweb-1.9.1/include ../../thirdparty/jsoncpp/include ../../thirdparty/) +find_package(LibArchive) + include_directories(../../thirdparty/libarchive-3.3.2/libarchive) file(GLOB SOURCES "*.cpp") @@ -75,4 +74,5 @@ endif () SET (ARCHIVE-EXTENSIONS minifi-archive-extensions PARENT_SCOPE) +register_extension(minifi-archive-extensions) diff --git a/extensions/rocksdb-repos/CMakeLists.txt b/extensions/rocksdb-repos/CMakeLists.txt index 76dd1f2aaa..f169a02529 100644 --- a/extensions/rocksdb-repos/CMakeLists.txt +++ b/extensions/rocksdb-repos/CMakeLists.txt @@ -24,8 +24,14 @@ set(CMAKE_EXE_LINKER_FLAGS "-Wl,--export-all-symbols") set(CMAKE_SHARED_LINKER_FLAGS "-Wl,--export-symbols") include_directories(../../libminifi/include ../../libminifi/include/core ../../thirdparty/spdlog-20170710/include ../../thirdparty/concurrentqueue ../../thirdparty/yaml-cpp-yaml-cpp-0.5.3/include ../../thirdparty/civetweb-1.9.1/include ../../thirdparty/jsoncpp/include ../../thirdparty/rocksdb/include ../../thirdparty/) + find_package(RocksDB) +if (NOT ROCKSDB_FOUND OR BUILD_ROCKSDB) + include_directories(thirdparty/rocksdb/include) +else() + include_directories(${ROCKSDB_INCLUDE_DIR}) +endif() file(GLOB SOURCES "*.cpp") @@ -72,4 +78,4 @@ endif () SET (ROCKSDB-REPOS minifi-rocksdb-repos PARENT_SCOPE) - +register_extension(minifi-rocksdb-repos) diff --git a/libminifi/test/archive-tests/CMakeLists.txt b/libminifi/test/archive-tests/CMakeLists.txt new file mode 100644 index 0000000000..dc23b1c6f4 --- /dev/null +++ b/libminifi/test/archive-tests/CMakeLists.txt @@ -0,0 +1,37 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +file(GLOB ARCHIVE_INTEGRATION_TESTS "*.cpp") + +SET(EXTENSIONS_TEST_COUNT 0) +FOREACH(testfile ${ARCHIVE_INTEGRATION_TESTS}) + get_filename_component(testfilename "${testfile}" NAME_WE) + add_executable("${testfilename}" "${testfile}" ${SPD_SOURCES} "${TEST_DIR}/TestBase.cpp") + target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/libarchive") + target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/thirdparty/libarchive-3.3.2/libarchive") + createTests("${testfilename}") + if (APPLE) + target_link_libraries (${testfilename} -Wl,-all_load minifi-archive-extensions) + else () + target_link_libraries (${testfilename} -Wl,--whole-archive minifi-archive-extensions -Wl,--no-whole-archive) + endif () + MATH(EXPR EXTENSIONS_TEST_COUNT "${EXTENSIONS_TEST_COUNT}+1") + add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) +ENDFOREACH() +message("-- Finished building ${ARCHIVE-EXTENSIONS_TEST_COUNT} Lib Archive related test file(s)...") diff --git a/libminifi/test/curl-tests/CMakeLists.txt b/libminifi/test/curl-tests/CMakeLists.txt new file mode 100644 index 0000000000..37e8b25d39 --- /dev/null +++ b/libminifi/test/curl-tests/CMakeLists.txt @@ -0,0 +1,53 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +file(GLOB CURL_INTEGRATION_TESTS "*.cpp") + +SET(CURL_INT_TEST_COUNT 0) + +FOREACH(testfile ${CURL_INTEGRATION_TESTS}) + get_filename_component(testfilename "${testfile}" NAME_WE) + add_executable("${testfilename}" "${testfile}" ${SPD_SOURCES} "${TEST_DIR}/TestBase.cpp") + target_include_directories(${testfilename} PRIVATE BEFORE ${CURL_INCLUDE_DIRS}) + target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/http-curl/") + target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/http-curl/client/") + target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/http-curl/processors/") + target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/http-curl/protocols/") + target_link_libraries(${testfilename} ${CURL_LIBRARIES} ) + createTests("${testfilename}") + if (APPLE) + target_link_libraries ("${testfilename}" -Wl,-all_load minifi-http-curl ) + else () + target_link_libraries ("${testfilename}" -Wl,--whole-archive minifi-http-curl -Wl,--no-whole-archive) + endif() + MATH(EXPR CURL_INT_TEST_COUNT "${CURL_INT_TEST_COUNT}+1") +ENDFOREACH() + +message("-- Finished building ${CURL_INT_TEST_COUNT} libcURL integration test file(s)...") + +add_test(NAME HttpGetIntegrationTest COMMAND HttpGetIntegrationTest "${TEST_RESOURCES}/TestHTTPGet.yml" "${TEST_RESOURCES}/") +add_test(NAME C2UpdateTest COMMAND C2UpdateTest "${TEST_RESOURCES}/TestHTTPGet.yml" "${TEST_RESOURCES}/") +add_test(NAME HttpGetIntegrationTestSecure COMMAND HttpGetIntegrationTest "${TEST_RESOURCES}/TestHTTPGetSecure.yml" "${TEST_RESOURCES}/") +add_test(NAME HttpPostIntegrationTest COMMAND HttpPostIntegrationTest "${TEST_RESOURCES}/TestHTTPPost.yml" "${TEST_RESOURCES}/") +add_test(NAME HttpPostIntegrationTestChunked COMMAND HttpPostIntegrationTest "${TEST_RESOURCES}/TestHTTPPostChunkedEncoding.yml" "${TEST_RESOURCES}/") +add_test(NAME C2VerifyServeResults COMMAND C2VerifyServeResults "${TEST_RESOURCES}/TestHTTPGet.yml" "${TEST_RESOURCES}/") +add_test(NAME C2VerifyHeartbeatAndStop COMMAND C2VerifyHeartbeatAndStop "${TEST_RESOURCES}/TestHTTPGet.yml" "${TEST_RESOURCES}/") +add_test(NAME SiteToSiteRestTest COMMAND SiteToSiteRestTest "${TEST_RESOURCES}/TestSite2SiteRest.yml" "${TEST_RESOURCES}/" "http://localhost:8082/nifi-api/controller") +add_test(NAME ControllerServiceIntegrationTests COMMAND ControllerServiceIntegrationTests "${TEST_RESOURCES}/TestControllerServices.yml" "${TEST_RESOURCES}/") +add_test(NAME ThreadPoolAdjust COMMAND ThreadPoolAdjust "${TEST_RESOURCES}/TestHTTPPostChunkedEncoding.yml" "${TEST_RESOURCES}/") diff --git a/libminifi/test/integration/ControllerServiceIntegrationTests.cpp b/libminifi/test/curl-tests/ControllerServiceIntegrationTests.cpp similarity index 100% rename from libminifi/test/integration/ControllerServiceIntegrationTests.cpp rename to libminifi/test/curl-tests/ControllerServiceIntegrationTests.cpp diff --git a/libminifi/test/rocksdb-tests/CMakeLists.txt b/libminifi/test/rocksdb-tests/CMakeLists.txt new file mode 100644 index 0000000000..713921bdbb --- /dev/null +++ b/libminifi/test/rocksdb-tests/CMakeLists.txt @@ -0,0 +1,36 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# + +file(GLOB ROCKSDB_INTEGRATION_TESTS "*.cpp") +SET(ROCKSDB_TEST_COUNT 0) +FOREACH(testfile ${ROCKSDB_INTEGRATION_TESTS}) + get_filename_component(testfilename "${testfile}" NAME_WE) + add_executable("${testfilename}" "${testfile}" ${SPD_SOURCES} "${TEST_DIR}/TestBase.cpp") + target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/extensions/rocksdb-repos/") + target_include_directories(${testfilename} PRIVATE BEFORE "${CMAKE_SOURCE_DIR}/thirdparty/rocksdb/include") + createTests("${testfilename}") + if (APPLE) + target_link_libraries (${testfilename} -Wl,-all_load minifi-rocksdb-repos) + else () + target_link_libraries (${testfilename} -Wl,--whole-archive minifi-rocksdb-repos -Wl,--no-whole-archive) + endif () + MATH(EXPR ROCKSDB_TEST_COUNT "${ROCKSDB_TEST_COUNT}+1") + add_test(NAME "${testfilename}" COMMAND "${testfilename}" WORKING_DIRECTORY ${TEST_DIR}) +ENDFOREACH() +message("-- Finished building ${ROCKSDB_TEST_COUNT} RocksDB related test file(s)...") diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index e984dee079..7f875cc75d 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -55,26 +55,16 @@ include_directories(${OPENSSL_INCLUDE_DIR}) target_link_libraries(minifiexe core-minifi minifi yaml-cpp c-library civetweb-cpp ${JSON_CPP_LIB} ${UUID_LIBRARIES} ${OPENSSL_LIBRARIES}) if (APPLE) - if (HTTP-CURL) - target_link_libraries (minifiexe -Wl,-all_load ${HTTP-CURL}) - endif() - if (ROCKSDB-REPOS) - target_link_libraries (minifiexe -Wl,-all_load ${ROCKSDB-REPOS}) - endif() - if (ARCHIVE-EXTENSIONS) - target_link_libraries (minifiexe -Wl,-all_load ${ARCHIVE-EXTENSIONS}) - endif() - + get_property(extensions GLOBAL PROPERTY EXTENSION-OPTIONS) + foreach(EXTENSION ${extensions}) + message("Linking against ${EXTENSION}") + target_link_libraries (minifiexe -Wl,-all_load ${EXTENSION}) + endforeach() else () - if (HTTP-CURL) - target_link_libraries (minifiexe -Wl,--whole-archive ${HTTP-CURL} -Wl,--no-whole-archive) - endif() - if (ROCKSDB-REPOS) - target_link_libraries (minifiexe -Wl,--whole-archive ${ROCKSDB-REPOS} -Wl,--no-whole-archive) - endif() - if (ARCHIVE-EXTENSIONS) - target_link_libraries (minifiexe -Wl,--whole-archive ${ARCHIVE-EXTENSIONS} -Wl,--no-whole-archive) - endif() + get_property(extensions GLOBAL PROPERTY EXTENSION-OPTIONS) + foreach(EXTENSION ${extensions}) + target_link_libraries (minifiexe -Wl,--whole-archive ${EXTENSION} -Wl,--no-whole-archive) + endforeach() endif () set_property(TARGET minifiexe PROPERTY INTERPROCEDURAL_OPTIMIZATION True) @@ -82,8 +72,6 @@ set_property(TARGET minifiexe PROPERTY INTERPROCEDURAL_OPTIMIZATION True) set_target_properties(minifiexe PROPERTIES OUTPUT_NAME minifi) - - install(TARGETS minifiexe RUNTIME DESTINATION bin