This is an automated email from the ASF dual-hosted git repository.
alexey pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 83cec9c1e [tools] Enable building 'kudu test' CLI tool by default
83cec9c1e is described below
commit 83cec9c1ecdd17967bef39f9d990c9c31dc4302c
Author: Yingchun Lai <[email protected]>
AuthorDate: Tue Aug 8 14:47:57 2023 +0800
[tools] Enable building 'kudu test' CLI tool by default
This patch enable building 'kudu test' CLI tool by default
even if -DNO_TESTS=1.
However, it's possible to disable building the test-related
CLI tool by setting -DKUDU_CLI_TEST_TOOL_ENABLED=0.
Change-Id: I381348b0123f8566d547cdd4449e308ea5f6aa13
Reviewed-on: http://gerrit.cloudera.org:8080/20326
Reviewed-by: Yifan Zhang <[email protected]>
Tested-by: Alexey Serbin <[email protected]>
Reviewed-by: Alexey Serbin <[email protected]>
---
CMakeLists.txt | 16 ++++---
src/kudu/clock/CMakeLists.txt | 16 +++----
src/kudu/hms/CMakeLists.txt | 4 +-
src/kudu/master/CMakeLists.txt | 3 +-
src/kudu/mini-cluster/CMakeLists.txt | 85 ++++++++++++++++++------------------
src/kudu/postgres/CMakeLists.txt | 48 ++++++++++----------
src/kudu/ranger-kms/CMakeLists.txt | 4 +-
src/kudu/ranger/CMakeLists.txt | 4 +-
src/kudu/security/CMakeLists.txt | 4 +-
src/kudu/tools/CMakeLists.txt | 7 ++-
src/kudu/tools/tool_action.h | 2 +-
src/kudu/tools/tool_action_test.cc | 4 +-
src/kudu/tools/tool_main.cc | 2 +-
src/kudu/tserver/CMakeLists.txt | 3 +-
src/kudu/util/CMakeLists.txt | 10 +++--
15 files changed, 111 insertions(+), 101 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 949f830f0..c7af97d8c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -234,11 +234,17 @@ add_definitions(-DKUDU_HEADERS_USE_RICH_SLICE=1)
# exported client headers).
add_definitions(-DKUDU_HEADERS_NO_STUBS=1)
-# If not building tests, add an extra macro to allow for omitting test-related
-# provisions and functionality from the kudu CLI tool: that's based on the
-# mini-cluster library, and the mini-cluster library is built only for testing.
-if(NO_TESTS)
- add_definitions(-DKUDU_CLI_TOOL_NO_TESTS)
+# The test-related CLI tool will be built if not disabled explicitly.
+if("${KUDU_CLI_TEST_TOOL_ENABLED}" STREQUAL "" OR KUDU_CLI_TEST_TOOL_ENABLED)
+ add_definitions(-DKUDU_CLI_TEST_TOOL_ENABLED)
+ set(KUDU_CLI_TEST_TOOL_ENABLED 1)
+endif()
+
+if(NOT NO_TESTS)
+ # If building tests, the test-related CLI tool must be built as well for
testing.
+ if(NOT KUDU_CLI_TEST_TOOL_ENABLED)
+ message(FATAL_ERROR "Must not set -DKUDU_CLI_TEST_TOOL_ENABLED=0 when
build with -DNO_TESTS=0")
+ endif()
endif()
# compiler flags for different build types (run 'cmake
-DCMAKE_BUILD_TYPE=<type> .')
diff --git a/src/kudu/clock/CMakeLists.txt b/src/kudu/clock/CMakeLists.txt
index 710bdccf7..af18e9552 100644
--- a/src/kudu/clock/CMakeLists.txt
+++ b/src/kudu/clock/CMakeLists.txt
@@ -40,14 +40,8 @@ target_link_libraries(clock
##############################
# mini_chronyd
##############################
-
-# The mini_chronyd is used only for tests, and corresponding tests for this
-# module below are skipped if NO_TEST=1.
-if(NO_TESTS)
- return()
-endif()
-
-if (NOT NO_CHRONY)
+# The mini_chronyd is used only for tests.
+if (NOT NO_CHRONY AND KUDU_CLI_TEST_TOOL_ENABLED)
# Link the chrony binaries so that they can be found via
# MiniChronyd::GetPath in MiniChronyd::Start.
execute_process(COMMAND ln -nsf
@@ -64,7 +58,13 @@ if (NOT NO_CHRONY)
gutil
kudu_test_util
kudu_util)
+endif()
+
+if(NO_TESTS)
+ return()
+endif()
+if (NOT NO_CHRONY)
set(MINI_CHRONYD_TEST_UTIL_SRCS test/mini_chronyd_test_util.cc)
add_library(mini_chronyd_test_util ${MINI_CHRONYD_TEST_UTIL_SRCS})
target_link_libraries(mini_chronyd_test_util
diff --git a/src/kudu/hms/CMakeLists.txt b/src/kudu/hms/CMakeLists.txt
index a83b9b01f..f777e007d 100644
--- a/src/kudu/hms/CMakeLists.txt
+++ b/src/kudu/hms/CMakeLists.txt
@@ -74,8 +74,8 @@ add_custom_command(OUTPUT ${HMS_PLUGIN_JAR}
DEPENDS proto_jar)
add_custom_target(hms_plugin_jar DEPENDS ${HMS_PLUGIN_JAR})
-if (NOT NO_TESTS)
- # The mini_hms library is used only for tests.
+# The mini_hms is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
set(MINI_HMS_SRCS
mini_hms.cc)
diff --git a/src/kudu/master/CMakeLists.txt b/src/kudu/master/CMakeLists.txt
index 249fd234a..21fe08058 100644
--- a/src/kudu/master/CMakeLists.txt
+++ b/src/kudu/master/CMakeLists.txt
@@ -72,7 +72,8 @@ set(MASTER_SRCS
txn_manager.cc
txn_manager_service.cc)
-if(NOT NO_TESTS)
+# The mini_master is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
set(MASTER_SRCS ${MASTER_SRCS} mini_master.cc)
endif()
diff --git a/src/kudu/mini-cluster/CMakeLists.txt
b/src/kudu/mini-cluster/CMakeLists.txt
index bed157cfd..2ccba9633 100644
--- a/src/kudu/mini-cluster/CMakeLists.txt
+++ b/src/kudu/mini-cluster/CMakeLists.txt
@@ -15,53 +15,54 @@
# specific language governing permissions and limitations
# under the License.
-# The mini-cluster is used only for testing.
-if(NO_TESTS)
- return()
-endif()
+##############################
+# mini_cluster
+##############################
+# The mini_cluster is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
+ set(MINI_CLUSTER_SRCS
+ external_mini_cluster.cc
+ internal_mini_cluster.cc
+ mini_cluster.cc
+ webui_checker.cc
+ )
-set(MINI_CLUSTER_SRCS
- external_mini_cluster.cc
- internal_mini_cluster.cc
- mini_cluster.cc
- webui_checker.cc
-)
+ set(MINI_CLUSTER_LIBS
+ gflags
+ glog
+ gmock
+ gtest
+ gutil
+ krpc
+ kudu_client
+ kudu_common
+ kudu_test_util
+ kudu_util
+ master
+ master_proto
+ mini_hms
+ mini_kdc
+ mini_oidc
+ mini_ranger
+ mini_ranger_kms
+ server_base_proto
+ tablet_proto
+ tserver
+ tserver_proto
+ tserver_service_proto
+ wire_protocol_proto)
-set(MINI_CLUSTER_LIBS
- gflags
- glog
- gmock
- gtest
- gutil
- krpc
- kudu_client
- kudu_common
- kudu_test_util
- kudu_util
- master
- master_proto
- mini_hms
- mini_kdc
- mini_oidc
- mini_ranger
- mini_ranger_kms
- server_base_proto
- tablet_proto
- tserver
- tserver_proto
- tserver_service_proto
- wire_protocol_proto)
+ if(NOT NO_CHRONY)
+ set(MINI_CLUSTER_LIBS ${MINI_CLUSTER_LIBS} mini_chronyd)
+ endif()
-if(NOT NO_CHRONY)
- set(MINI_CLUSTER_LIBS ${MINI_CLUSTER_LIBS} mini_chronyd)
+ add_library(mini_cluster ${MINI_CLUSTER_SRCS})
+ target_link_libraries(mini_cluster ${MINI_CLUSTER_LIBS})
+ add_dependencies(mini_cluster
+ kudu-tserver
+ kudu-master)
endif()
-add_library(mini_cluster ${MINI_CLUSTER_SRCS})
-target_link_libraries(mini_cluster ${MINI_CLUSTER_LIBS})
-add_dependencies(mini_cluster
- kudu-tserver
- kudu-master)
-
#######################################
# Unit tests
#######################################
diff --git a/src/kudu/postgres/CMakeLists.txt b/src/kudu/postgres/CMakeLists.txt
index c116894d7..404c0766d 100644
--- a/src/kudu/postgres/CMakeLists.txt
+++ b/src/kudu/postgres/CMakeLists.txt
@@ -15,36 +15,32 @@
# specific language governing permissions and limitations
# under the License.
-# The mini_postgres is used only for tests, and its tests are disabled
-# if NO_TESTS=1 is set.
-if(NO_TESTS)
- return()
-endif()
-
#######################################
# mini_postgres
#######################################
+# The mini_postgres is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
+ execute_process(COMMAND ln -nsf
+ "${THIRDPARTY_DIR}/installed/common/bin"
+ "${EXECUTABLE_OUTPUT_PATH}/postgres")
+ execute_process(COMMAND ln -nsf
+ "${THIRDPARTY_DIR}/installed/common/lib"
+ "${EXECUTABLE_OUTPUT_PATH}/postgres-lib")
+ execute_process(COMMAND ln -nsf
+ "${THIRDPARTY_DIR}/installed/common/share/postgresql"
+ "${EXECUTABLE_OUTPUT_PATH}/postgres-share")
+ execute_process(COMMAND ln -nsf
+ "${THIRDPARTY_DIR}/installed/common/opt/jdbc/postgresql.jar"
+ "${EXECUTABLE_OUTPUT_PATH}/postgresql.jar")
-execute_process(COMMAND ln -nsf
- "${THIRDPARTY_DIR}/installed/common/bin"
- "${EXECUTABLE_OUTPUT_PATH}/postgres")
-execute_process(COMMAND ln -nsf
- "${THIRDPARTY_DIR}/installed/common/lib"
- "${EXECUTABLE_OUTPUT_PATH}/postgres-lib")
-execute_process(COMMAND ln -nsf
- "${THIRDPARTY_DIR}/installed/common/share/postgresql"
- "${EXECUTABLE_OUTPUT_PATH}/postgres-share")
-execute_process(COMMAND ln -nsf
- "${THIRDPARTY_DIR}/installed/common/opt/jdbc/postgresql.jar"
- "${EXECUTABLE_OUTPUT_PATH}/postgresql.jar")
-
-add_library(mini_postgres
- mini_postgres.cc)
-target_link_libraries(mini_postgres
- gutil
- kudu_test_util
- kudu_util
-)
+ add_library(mini_postgres
+ mini_postgres.cc)
+ target_link_libraries(mini_postgres
+ gutil
+ kudu_test_util
+ kudu_util
+ )
+endif()
#######################################
# Unit tests
diff --git a/src/kudu/ranger-kms/CMakeLists.txt
b/src/kudu/ranger-kms/CMakeLists.txt
index 1bd967a79..355e5e0c1 100644
--- a/src/kudu/ranger-kms/CMakeLists.txt
+++ b/src/kudu/ranger-kms/CMakeLists.txt
@@ -30,8 +30,8 @@ target_link_libraries(ranger_kms_client
${RANGER_KMS_CLIENT_DEPS})
#######################################
# mini_ranger_kms
#######################################
-if(NOT NO_TESTS)
- # The mini_ranger_kms is used only in tests.
+# The mini_ranger_kms is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
execute_process(COMMAND ln -nsf
"${THIRDPARTY_DIR}/installed/common/opt/ranger-kms"
"${EXECUTABLE_OUTPUT_PATH}/ranger_kms-home")
diff --git a/src/kudu/ranger/CMakeLists.txt b/src/kudu/ranger/CMakeLists.txt
index aa5753584..4af0dc318 100644
--- a/src/kudu/ranger/CMakeLists.txt
+++ b/src/kudu/ranger/CMakeLists.txt
@@ -51,8 +51,8 @@ target_link_libraries(kudu_ranger ${RANGER_DEPS})
# mini_ranger
#######################################
-# The mini_ranger is used only in tests.
-if(NOT NO_TESTS)
+# The mini_ranger is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
execute_process(COMMAND ln -nsf
"${THIRDPARTY_DIR}/installed/common/opt/ranger"
"${EXECUTABLE_OUTPUT_PATH}/ranger-home")
diff --git a/src/kudu/security/CMakeLists.txt b/src/kudu/security/CMakeLists.txt
index 4ae9dee8c..266aa352f 100644
--- a/src/kudu/security/CMakeLists.txt
+++ b/src/kudu/security/CMakeLists.txt
@@ -99,8 +99,8 @@ ADD_EXPORTABLE_LIBRARY(security
# mini_kdc
##############################
-if (NOT NO_TESTS)
- # The mini_kdc is used only in tests.
+# The mini_kdc is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
set(MINI_KDC_SRCS test/mini_kdc.cc)
add_library(mini_kdc ${MINI_KDC_SRCS})
diff --git a/src/kudu/tools/CMakeLists.txt b/src/kudu/tools/CMakeLists.txt
index f7bc8147a..452ded584 100644
--- a/src/kudu/tools/CMakeLists.txt
+++ b/src/kudu/tools/CMakeLists.txt
@@ -120,7 +120,7 @@ set(KUDU_CLI_TOOL_SRCS
tool_main.cc
)
-if(NOT NO_TESTS)
+if (KUDU_CLI_TEST_TOOL_ENABLED)
set(KUDU_CLI_TOOL_SRCS ${KUDU_CLI_TOOL_SRCS} tool_action_test.cc)
endif()
@@ -148,9 +148,12 @@ set(KUDU_CLI_TOOL_LINK_LIBS
tserver
${KUDU_BASE_LIBS}
)
-if(NOT NO_TESTS)
+
+# The mini_cluster is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
set(KUDU_CLI_TOOL_LINK_LIBS ${KUDU_CLI_TOOL_LINK_LIBS} mini_cluster)
endif()
+
target_link_libraries(kudu ${KUDU_CLI_TOOL_LINK_LIBS})
option(KUDU_CLIENT_INSTALL "Whether to install the Kudu command line tool" ON)
diff --git a/src/kudu/tools/tool_action.h b/src/kudu/tools/tool_action.h
index 3ddba0ca3..773a73a94 100644
--- a/src/kudu/tools/tool_action.h
+++ b/src/kudu/tools/tool_action.h
@@ -345,7 +345,7 @@ std::unique_ptr<Mode> BuildTxnMode();
std::unique_ptr<Mode> BuildTServerMode();
std::unique_ptr<Mode> BuildWalMode();
-#if !defined(KUDU_CLI_TOOL_NO_TESTS)
+#if defined(KUDU_CLI_TEST_TOOL_ENABLED)
std::unique_ptr<Mode> BuildTestMode();
#endif
diff --git a/src/kudu/tools/tool_action_test.cc
b/src/kudu/tools/tool_action_test.cc
index abd75bae4..c861bd6a7 100644
--- a/src/kudu/tools/tool_action_test.cc
+++ b/src/kudu/tools/tool_action_test.cc
@@ -457,7 +457,7 @@ string SerializeRequest(const ControlShellRequestPB& req) {
} // anonymous namespace
-#if !defined(KUDU_CLI_TOOL_NO_TESTS)
+#if defined(KUDU_CLI_TEST_TOOL_ENABLED)
unique_ptr<Mode> BuildTestMode() {
ControlShellRequestPB create;
@@ -488,7 +488,7 @@ unique_ptr<Mode> BuildTestMode() {
.AddAction(std::move(control_shell))
.Build();
}
-#endif // #if !defined(KUDU_CLI_TOOL_NO_TESTS) ...
+#endif // #if defined(KUDU_CLI_TEST_TOOL_ENABLED) ...
} // namespace tools
} // namespace kudu
diff --git a/src/kudu/tools/tool_main.cc b/src/kudu/tools/tool_main.cc
index 5a8faeeeb..755cd16fa 100644
--- a/src/kudu/tools/tool_main.cc
+++ b/src/kudu/tools/tool_main.cc
@@ -70,7 +70,7 @@ unique_ptr<Mode> RootMode(const string& name) {
.AddMode(BuildRemoteReplicaMode())
.AddMode(BuildTableMode())
.AddMode(BuildTabletMode())
-#if !defined(KUDU_CLI_TOOL_NO_TESTS)
+#if defined(KUDU_CLI_TEST_TOOL_ENABLED)
.AddMode(BuildTestMode())
#endif
.AddMode(BuildTxnMode())
diff --git a/src/kudu/tserver/CMakeLists.txt b/src/kudu/tserver/CMakeLists.txt
index d522bd947..064c39d1a 100644
--- a/src/kudu/tserver/CMakeLists.txt
+++ b/src/kudu/tserver/CMakeLists.txt
@@ -118,7 +118,8 @@ set(TSERVER_SRCS
tserver_path_handlers.cc
)
-if(NOT NO_TESTS)
+# The mini_tablet_server is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
set(TSERVER_SRCS ${TSERVER_SRCS} mini_tablet_server.cc)
endif()
diff --git a/src/kudu/util/CMakeLists.txt b/src/kudu/util/CMakeLists.txt
index 127c884b1..4ac6fb802 100644
--- a/src/kudu/util/CMakeLists.txt
+++ b/src/kudu/util/CMakeLists.txt
@@ -378,7 +378,8 @@ target_link_libraries(kudu_jwt_util
#######################################
# mini_oidc
#######################################
-if(NOT NO_TESTS)
+# The mini_oidc is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
add_library(mini_oidc mini_oidc.cc)
target_link_libraries(mini_oidc
server_process
@@ -391,7 +392,8 @@ endif()
#######################################
# jwt_test_certs
#######################################
-if(NOT NO_TESTS)
+# The jwt_test_certs is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
add_library(jwt_test_certs jwt_test_certs.cc)
target_link_libraries(jwt_test_certs
kudu_jwt_util)
@@ -430,8 +432,8 @@ target_link_libraries(protoc-gen-insertions gutil protobuf
protoc ${KUDU_BASE_LI
#######################################
# kudu_test_util
#######################################
-if(NOT NO_TESTS)
- # The kudu_test_util is needed only for testing.
+# The kudu_test_util is used only for tests.
+if (KUDU_CLI_TEST_TOOL_ENABLED)
add_library(kudu_test_util
test_util.cc)
target_link_libraries(kudu_test_util