This is an automated email from the ASF dual-hosted git repository. asekretenko pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit bc8556bf4f4bb3afc4f9f73b093c9fad1c639f70 Author: Andrei Sekretenko <asekrete...@apache.org> AuthorDate: Thu Apr 23 11:53:57 2020 +0200 Added tests to cmake install target. Review: https://reviews.apache.org/r/72494 --- cmake/CompilationConfigure.cmake | 7 ++ src/examples/CMakeLists.txt | 82 +++++++++++++--------- src/tests/CMakeLists.txt | 21 +++++- .../agent_resource_provider_config_api_tests.cpp | 2 +- src/tests/default_executor_tests.cpp | 4 +- .../storage_local_resource_provider_tests.cpp | 2 +- 6 files changed, 79 insertions(+), 39 deletions(-) diff --git a/cmake/CompilationConfigure.cmake b/cmake/CompilationConfigure.cmake index d29c427..f0e712e 100644 --- a/cmake/CompilationConfigure.cmake +++ b/cmake/CompilationConfigure.cmake @@ -75,6 +75,13 @@ set( This is typically used by package managers that use different prefixes on a build system and on a target system.") +# TODO(asekretenko): Consider making Mesos tests a separate project +# that would depend on Mesos installation. +option(MESOS_INSTALL_TESTS + "Add test executables and their dependencies to the install step." + FALSE) + + # 3RDPARTY OPTIONS. ################### option( diff --git a/src/examples/CMakeLists.txt b/src/examples/CMakeLists.txt index a811a07..b25324b 100644 --- a/src/examples/CMakeLists.txt +++ b/src/examples/CMakeLists.txt @@ -14,49 +14,67 @@ # See the License for the specific language governing permissions and # limitations under the License. +function(ADD_TEST_MODULE MODULE SOURCES) + if (MESOS_INSTALL_TESTS) + add_library(${MODULE} SHARED ${SOURCES}) + install( + TARGETS ${MODULE} + RUNTIME DESTINATION ${MESOS_INSTALL_RUNTIME} + LIBRARY DESTINATION ${MESOS_INSTALL_LIBRARIES}) + else() + add_library(${MODULE} SHARED EXCLUDE_FROM_ALL ${SOURCES}) + endif() +endfunction() + +function(ADD_TEST_EXECUTABLE EXECUTABLE SOURCES) + add_executable(${EXECUTABLE} ${SOURCES}) + if (MESOS_INSTALL_TESTS) + install(TARGETS ${EXECUTABLE} RUNTIME DESTINATION ${MESOS_INSTALL_RUNTIME}) + endif() +endfunction() + if (NOT WIN32) # Build the test modules. ######################### # NOTE: Modules are not supported on Windows. - add_library(testallocator SHARED EXCLUDE_FROM_ALL test_allocator_module.cpp) - add_library(testanonymous SHARED EXCLUDE_FROM_ALL test_anonymous_module.cpp) - add_library(testauthentication SHARED EXCLUDE_FROM_ALL test_authentication_modules.cpp) - add_library(testauthorizer SHARED EXCLUDE_FROM_ALL test_authorizer_module.cpp) - add_library(testcontainer_logger SHARED EXCLUDE_FROM_ALL test_container_logger_module.cpp) - add_library(examplemodule SHARED EXCLUDE_FROM_ALL example_module_impl.cpp) - add_library(testhook SHARED EXCLUDE_FROM_ALL test_hook_module.cpp) - add_library(testhttpauthenticator SHARED EXCLUDE_FROM_ALL test_http_authenticator_module.cpp) - add_library(testisolator SHARED EXCLUDE_FROM_ALL test_isolator_module.cpp) - add_library(testmastercontender SHARED EXCLUDE_FROM_ALL test_master_contender_module.cpp) - add_library(testmasterdetector SHARED EXCLUDE_FROM_ALL test_master_detector_module.cpp) - add_library(testqos_controller SHARED EXCLUDE_FROM_ALL test_qos_controller_module.cpp) - add_library(testresource_estimator SHARED EXCLUDE_FROM_ALL test_resource_estimator_module.cpp) - + ADD_TEST_MODULE(testallocator test_allocator_module.cpp) + ADD_TEST_MODULE(testanonymous test_anonymous_module.cpp) + ADD_TEST_MODULE(testauthentication test_authentication_modules.cpp) + ADD_TEST_MODULE(testauthorizer test_authorizer_module.cpp) + ADD_TEST_MODULE(testcontainer_logger test_container_logger_module.cpp) + ADD_TEST_MODULE(examplemodule example_module_impl.cpp) + ADD_TEST_MODULE(testhook test_hook_module.cpp) + ADD_TEST_MODULE(testhttpauthenticator test_http_authenticator_module.cpp) + ADD_TEST_MODULE(testisolator test_isolator_module.cpp) + ADD_TEST_MODULE(testmastercontender test_master_contender_module.cpp) + ADD_TEST_MODULE(testmasterdetector test_master_detector_module.cpp) + ADD_TEST_MODULE(testqos_controller test_qos_controller_module.cpp) + ADD_TEST_MODULE(testresource_estimator test_resource_estimator_module.cpp) # Build the example frameworks and executors. ############################################# # TODO(josephw): The scheduler driver is current not built on Windows. - add_executable(balloon-executor balloon_executor.cpp) - add_executable(balloon-framework balloon_framework.cpp) - add_executable(disk-full-framework disk_full_framework.cpp) - add_executable(docker-no-executor-framework docker_no_executor_framework.cpp) - add_executable(dynamic-reservation-framework dynamic_reservation_framework.cpp) - add_executable(inverse-offer-framework inverse_offer_framework.cpp) - add_executable(load-generator-framework load_generator_framework.cpp) - add_executable(long-lived-executor long_lived_executor.cpp) - add_executable(long-lived-framework long_lived_framework.cpp) - add_executable(operation-feedback-framework operation_feedback_framework.cpp) - add_executable(no-executor-framework no_executor_framework.cpp) - add_executable(persistent-volume-framework persistent_volume_framework.cpp) - add_executable(test-executor test_executor.cpp) - add_executable(test-framework test_framework.cpp) - add_executable(test-http-executor test_http_executor.cpp) - add_executable(test-http-framework test_http_framework.cpp) - add_executable(test-csi-user-framework test_csi_user_framework.cpp) + ADD_TEST_EXECUTABLE(balloon-executor balloon_executor.cpp) + ADD_TEST_EXECUTABLE(balloon-framework balloon_framework.cpp) + ADD_TEST_EXECUTABLE(disk-full-framework disk_full_framework.cpp) + ADD_TEST_EXECUTABLE(docker-no-executor-framework docker_no_executor_framework.cpp) + ADD_TEST_EXECUTABLE(dynamic-reservation-framework dynamic_reservation_framework.cpp) + ADD_TEST_EXECUTABLE(inverse-offer-framework inverse_offer_framework.cpp) + ADD_TEST_EXECUTABLE(load-generator-framework load_generator_framework.cpp) + ADD_TEST_EXECUTABLE(long-lived-executor long_lived_executor.cpp) + ADD_TEST_EXECUTABLE(long-lived-framework long_lived_framework.cpp) + ADD_TEST_EXECUTABLE(operation-feedback-framework operation_feedback_framework.cpp) + ADD_TEST_EXECUTABLE(no-executor-framework no_executor_framework.cpp) + ADD_TEST_EXECUTABLE(persistent-volume-framework persistent_volume_framework.cpp) + ADD_TEST_EXECUTABLE(test-executor test_executor.cpp) + ADD_TEST_EXECUTABLE(test-framework test_framework.cpp) + ADD_TEST_EXECUTABLE(test-http-executor test_http_executor.cpp) + ADD_TEST_EXECUTABLE(test-http-framework test_http_framework.cpp) + ADD_TEST_EXECUTABLE(test-csi-user-framework test_csi_user_framework.cpp) # TODO(chhsiao): The test CSI plugin is Linux only for now. if (LINUX) - add_executable(test-csi-plugin test_csi_plugin.cpp) + ADD_TEST_EXECUTABLE(test-csi-plugin test_csi_plugin.cpp) endif () # NOTE: Do not replace this with `link_libraries()`. While it may result in diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 9d5ce02..cf579f8 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -307,9 +307,15 @@ target_compile_definitions( PKGLIBEXECDIR="${PKG_LIBEXEC_INSTALL_DIR}" TESTLIBEXECDIR="${TEST_LIB_EXEC_DIR}" PKGMODULEDIR="${PKG_MODULE_DIR}" - SBINDIR="${S_BIN_DIR}") + SBINDIR="${S_BIN_DIR}" + MESOS_INSTALL_TESTS=${MESOS_INSTALL_TESTS}) + +if(MESOS_INSTALL_TESTS) + add_executable(mesos-tests ${MESOS_TESTS_SRC}) +else() + add_executable(mesos-tests EXCLUDE_FROM_ALL ${MESOS_TESTS_SRC}) +endif() -add_executable(mesos-tests EXCLUDE_FROM_ALL ${MESOS_TESTS_SRC}) target_link_libraries(mesos-tests PRIVATE mesos-tests-interface) target_compile_definitions( @@ -317,7 +323,13 @@ target_compile_definitions( $<$<BOOL:${HAS_JAVA}>:MESOS_HAS_JAVA>) # Helper to run tests that require a subprocess. -add_executable(test-helper EXCLUDE_FROM_ALL ${TEST_HELPER_SRC}) +if (MESOS_INSTALL_TESTS) + add_executable(test-helper ${TEST_HELPER_SRC}) + install(TARGETS test-helper RUNTIME DESTINATION ${MESOS_INSTALL_RUNTIME}) +else() + add_executable(test-helper EXCLUDE_FROM_ALL ${TEST_HELPER_SRC}) +endif() + target_link_libraries(test-helper PRIVATE mesos-tests-interface) # The tests require these binaries. @@ -392,6 +404,9 @@ if (NOT WIN32) endif () endif () +if (MESOS_INSTALL_TESTS) + install(TARGETS mesos-tests RUNTIME DESTINATION ${MESOS_INSTALL_RUNTIME}) +endif() # ADD TEST TARGET (runs when you do, e.g., `make check`). ######################################################### diff --git a/src/tests/agent_resource_provider_config_api_tests.cpp b/src/tests/agent_resource_provider_config_api_tests.cpp index aadebd3..ef4bc80 100644 --- a/src/tests/agent_resource_provider_config_api_tests.cpp +++ b/src/tests/agent_resource_provider_config_api_tests.cpp @@ -158,7 +158,7 @@ public: "local_" + strings::remove(id::UUID::random().toString(), "-"); const string testCsiPluginPath = - path::join(tests::flags.build_dir, "src", "test-csi-plugin"); + path::join(getTestHelperDir(), "test-csi-plugin"); const string testCsiPluginWorkDir = path::join(sandbox.get(), testCsiPluginName); diff --git a/src/tests/default_executor_tests.cpp b/src/tests/default_executor_tests.cpp index 2353520..0196eb9 100644 --- a/src/tests/default_executor_tests.cpp +++ b/src/tests/default_executor_tests.cpp @@ -4457,11 +4457,11 @@ TEST_P(DefaultExecutorTest, DomainSockets) {"GLOG_v", os::getenv("GLOG_v").getOrElse("0") }, }; - Result<std::string> path = os::realpath(BUILD_DIR); + Result<std::string> path = os::realpath(getLauncherDir()); ASSERT_SOME(path); Try<process::Subprocess> executor = process::subprocess( - path::join(path.get(), "src/mesos-default-executor"), + path::join(path.get(), "mesos-default-executor"), argv, process::Subprocess::FD(STDIN_FILENO), process::Subprocess::FD(STDOUT_FILENO), diff --git a/src/tests/storage_local_resource_provider_tests.cpp b/src/tests/storage_local_resource_provider_tests.cpp index 568683a..75959aa 100644 --- a/src/tests/storage_local_resource_provider_tests.cpp +++ b/src/tests/storage_local_resource_provider_tests.cpp @@ -252,7 +252,7 @@ public: const Option<Duration>& reconciliationInterval = None()) { const string testCsiPluginPath = - path::join(tests::flags.build_dir, "src", "test-csi-plugin"); + path::join(getTestHelperDir(), "test-csi-plugin"); Try<string> resourceProviderConfig = strings::format( R"~(