From 8cd807df5f423741947fddcac1373bfc15a64683 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Svensson?= Date: Tue, 25 Jun 2024 20:10:54 +0200 Subject: [PATCH] Move remaining tests and build/run all legacy tests using CMake (#26) Move the remaining tests, i.e. the cluster tests, to the new project structure and enable building and running all tests using CMake. Example: mkdir build && cd build cmake -DENABLE_SSL=ON -DENABLE_IPV6_TESTS=ON .. make make test The legacy CMake options `ENABLE_SSL_TESTS` and `ENABLE_ASYNC_TESTS` are removed, now controlled by the build option `ENABLE_SSL` and if `libevent` is available. --- .github/workflows/build.yml | 6 +- .github/workflows/ci.yml | 9 +- .github/workflows/db-compatibility.yml | 19 ++- CMakeLists.txt | 26 ++-- Makefile | 2 +- .../tests => tests}/CMakeLists.txt | 121 +++++++++--------- tests/{test.c => client_test.c} | 0 .../tests => tests}/clusterclient.c | 1 - .../tests => tests}/clusterclient_async.c | 2 +- .../clusterclient_reconnect_async.c | 0 {libvalkeycluster/tests => tests}/ct_async.c | 0 .../tests => tests}/ct_async_glib.c | 0 .../tests => tests}/ct_async_libev.c | 0 .../tests => tests}/ct_async_libuv.c | 0 .../tests => tests}/ct_commands.c | 1 - .../tests => tests}/ct_connection.c | 0 .../tests => tests}/ct_connection_ipv6.c | 1 - .../ct_out_of_memory_handling.c | 1 - .../tests => tests}/ct_pipeline.c | 0 .../tests => tests}/ct_specific_nodes.c | 0 .../ask-redirect-connection-error-test.sh | 0 .../scripts/ask-redirect-test.sh | 0 .../ask-redirect-using-cluster-nodes-test.sh | 0 .../scripts/cluster-down-test.sh | 0 .../scripts/cluster-scale-down-test.sh | 0 .../scripts/command-from-callback-test.sh | 0 .../connect-error-using-cluster-nodes-test.sh | 0 .../scripts/connection-error-test.sh | 0 ...o-all-nodes-during-scaledown-test-async.sh | 0 ...size-to-all-nodes-during-scaledown-test.sh | 0 .../scripts/dbsize-to-all-nodes-test.sh | 0 .../scripts/moved-redirect-test.sh | 0 ...moved-redirect-using-cluster-nodes-test.sh | 0 .../tests => tests}/scripts/reconnect-test.sh | 0 .../scripts/redirect-with-hostname-test.sh | 0 .../scripts/redirect-with-ipv6-test.sh | 0 .../tests => tests}/scripts/redis-cluster | 0 .../tests => tests}/scripts/set-get-test.sh | 0 .../scripts/simulated-valkey.pl | 0 .../scripts/slots-not-served-test-async.sh | 0 .../scripts/slots-not-served-test.sh | 0 .../scripts/timeout-handling-test.sh | 0 .../tests => tests}/scripts/valkey-cluster | 0 tests/test.sh | 2 +- .../tests => tests}/test_utils.c | 0 .../tests => tests}/test_utils.h | 0 .../tests => tests}/ut_parse_cmd.c | 0 47 files changed, 87 insertions(+), 104 deletions(-) rename {libvalkeycluster/tests => tests}/CMakeLists.txt (73%) rename tests/{test.c => client_test.c} (100%) rename {libvalkeycluster/tests => tests}/clusterclient.c (99%) rename {libvalkeycluster/tests => tests}/clusterclient_async.c (99%) rename {libvalkeycluster/tests => tests}/clusterclient_reconnect_async.c (100%) rename {libvalkeycluster/tests => tests}/ct_async.c (100%) rename {libvalkeycluster/tests => tests}/ct_async_glib.c (100%) rename {libvalkeycluster/tests => tests}/ct_async_libev.c (100%) rename {libvalkeycluster/tests => tests}/ct_async_libuv.c (100%) rename {libvalkeycluster/tests => tests}/ct_commands.c (99%) rename {libvalkeycluster/tests => tests}/ct_connection.c (100%) rename {libvalkeycluster/tests => tests}/ct_connection_ipv6.c (98%) rename {libvalkeycluster/tests => tests}/ct_out_of_memory_handling.c (99%) rename {libvalkeycluster/tests => tests}/ct_pipeline.c (100%) rename {libvalkeycluster/tests => tests}/ct_specific_nodes.c (100%) rename {libvalkeycluster/tests => tests}/scripts/ask-redirect-connection-error-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/ask-redirect-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/ask-redirect-using-cluster-nodes-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/cluster-down-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/cluster-scale-down-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/command-from-callback-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/connect-error-using-cluster-nodes-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/connection-error-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/dbsize-to-all-nodes-during-scaledown-test-async.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/dbsize-to-all-nodes-during-scaledown-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/dbsize-to-all-nodes-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/moved-redirect-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/moved-redirect-using-cluster-nodes-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/reconnect-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/redirect-with-hostname-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/redirect-with-ipv6-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/redis-cluster (100%) rename {libvalkeycluster/tests => tests}/scripts/set-get-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/simulated-valkey.pl (100%) rename {libvalkeycluster/tests => tests}/scripts/slots-not-served-test-async.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/slots-not-served-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/timeout-handling-test.sh (100%) rename {libvalkeycluster/tests => tests}/scripts/valkey-cluster (100%) rename {libvalkeycluster/tests => tests}/test_utils.c (100%) rename {libvalkeycluster/tests => tests}/test_utils.h (100%) rename {libvalkeycluster/tests => tests}/ut_parse_cmd.c (100%) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f5679216..8ca0ffa0 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: - name: Build using cmake env: - EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON -DENABLE_ASYNC_TESTS:BOOL=ON + EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON CFLAGS: -Werror CXXFLAGS: -Werror run: mkdir build && cd build && cmake .. && make @@ -62,7 +62,7 @@ jobs: - name: Build using cmake env: - EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON -DENABLE_ASYNC_TESTS:BOOL=ON + EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON CFLAGS: -Werror CXXFLAGS: -Werror run: mkdir build && cd build && cmake3 .. && make @@ -107,7 +107,7 @@ jobs: - name: Build using cmake env: - EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON -DENABLE_SSL_TESTS:BOOL=ON -DENABLE_ASYNC_TESTS:BOOL=ON + EXTRA_CMAKE_OPTS: -DENABLE_EXAMPLES:BOOL=ON -DENABLE_SSL:BOOL=ON CFLAGS: -Werror CXXFLAGS: -Werror run: mkdir build && cd build && cmake .. && make diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 429da711..173c88d1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -48,13 +48,10 @@ jobs: with: packages: libevent-dev libuv1-dev libev-dev libglib2.0-dev ${{ matrix.compiler }} version: 1.0 - - name: Install hiredis - env: - VERSION: 1.2.0 + - name: Install Valkey for non-cluster tests run: | - curl -L https://github.com/redis/hiredis/archive/v${VERSION}.tar.gz | tar -xz - cmake -S hiredis-${VERSION} -B hiredis-build -DENABLE_SSL=ON - sudo make -C hiredis-build install + git clone --depth 1 --branch 7.2.5 https://github.com/valkey-io/valkey.git + cd valkey && BUILD_TLS=yes make install - name: Setup cmake uses: jwlawson/actions-setup-cmake@802fa1a2c4e212495c05bf94dba2704a92a472be # v2.0.2 with: diff --git a/.github/workflows/db-compatibility.yml b/.github/workflows/db-compatibility.yml index b2c8d57b..d26f802e 100644 --- a/.github/workflows/db-compatibility.yml +++ b/.github/workflows/db-compatibility.yml @@ -13,13 +13,17 @@ jobs: fail-fast: false matrix: include: - - valkey-version: 7.2.5 + - valkey-version: '7.2.5' steps: - name: Prepare uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad # v1.4.2 with: packages: libevent-dev version: 1.0 + - name: Install Valkey for non-cluster tests + run: | + git clone --depth 1 --branch ${{ matrix.valkey-version }} https://github.com/valkey-io/valkey.git + cd valkey && BUILD_TLS=yes make install - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 - name: Create build folder run: cmake -E make_directory build @@ -55,18 +59,19 @@ jobs: fail-fast: false matrix: include: - - redis-version: 7.2.4 - - redis-version: 7.0.15 - - redis-version: 6.2.14 - - redis-version: 6.0.20 - - redis-version: 5.0.14 + - redis-version: '7.2.4' + - redis-version: '7.0.15' + - redis-version: '6.2.14' steps: - name: Prepare uses: awalsh128/cache-apt-pkgs-action@a6c3917cc929dd0345bfb2d3feaf9101823370ad # v1.4.2 with: packages: libevent-dev version: 1.0 - + - name: Install Redis for non-cluster tests + run: | + git clone --depth 1 --branch ${{ matrix.redis-version }} https://github.com/redis/redis.git + cd redis && BUILD_TLS=yes make install - uses: actions/checkout@44c2b7a8a4ea60a981eaca3cf939b5f4305c123b # v4.1.5 - name: Create build folder diff --git a/CMakeLists.txt b/CMakeLists.txt index a2c81c5f..feb51b32 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,9 +20,8 @@ INCLUDE(GNUInstallDirs) OPTION(BUILD_SHARED_LIBS "Build shared libraries" ON) OPTION(ENABLE_SSL "Build valkey_ssl for SSL support" OFF) OPTION(DISABLE_TESTS "If tests should be compiled or not" OFF) -OPTION(ENABLE_SSL_TESTS "Should we test SSL connections" OFF) OPTION(ENABLE_EXAMPLES "Enable building valkey examples" OFF) -OPTION(ENABLE_ASYNC_TESTS "Should we run all asynchronous API tests" OFF) +option(ENABLE_IPV6_TESTS "Enable IPv6 tests requiring special prerequisites" OFF) # Historically, the NuGet file was always install; default # to ON for those who rely on that historical behaviour. OPTION(ENABLE_NUGET "Install NuGET packaging details" ON) @@ -237,21 +236,14 @@ IF(ENABLE_SSL) DESTINATION ${CMAKE_CONF_INSTALL_DIR}) ENDIF() -#IF(NOT DISABLE_TESTS) -# ENABLE_TESTING() -# ADD_EXECUTABLE(libvalkey-test test.c) -# TARGET_LINK_LIBRARIES(libvalkey-test valkey) -# IF(ENABLE_SSL_TESTS) -# ADD_DEFINITIONS(-DVALKEY_TEST_SSL=1) -# TARGET_LINK_LIBRARIES(libvalkey-test valkey_ssl) -# ENDIF() -# IF(ENABLE_ASYNC_TESTS) -# ADD_DEFINITIONS(-DVALKEY_TEST_ASYNC=1) -# TARGET_LINK_LIBRARIES(libvalkey-test event) -# ENDIF() -# ADD_TEST(NAME libvalkey-test -# COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/test.sh) -#ENDIF() +# Add tests +if(NOT DISABLE_TESTS) + # Make sure ctest prints the output when a test fails. + # Must be set before including CTest. + set(CMAKE_CTEST_ARGUMENTS "--output-on-failure") + include(CTest) + add_subdirectory(tests) +endif() # Add examples IF(ENABLE_EXAMPLES) diff --git a/Makefile b/Makefile index 53d9f9df..35fe1f90 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ TEST_DIR = tests INCLUDE_DIR = include/valkey -TEST_SRCS = $(wildcard $(TEST_DIR)/*.c) +TEST_SRCS = $(TEST_DIR)/client_test.c TEST_OBJS = $(patsubst $(TEST_DIR)/%.c,$(OBJ_DIR)/%.o,$(TEST_SRCS)) TEST_BINS = $(patsubst $(TEST_DIR)/%.c,$(TEST_DIR)/%,$(TEST_SRCS)) diff --git a/libvalkeycluster/tests/CMakeLists.txt b/tests/CMakeLists.txt similarity index 73% rename from libvalkeycluster/tests/CMakeLists.txt rename to tests/CMakeLists.txt index f20ffde0..62eb68be 100644 --- a/libvalkeycluster/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,41 +1,35 @@ -SET(TEST_WITH_REDIS_VERSION "6.2.1" CACHE STRING "Redis version used when running tests.") - -# Re-enable `-std=gnu99` for tests only, this avoids the need to sprinkle -# `#define _XOPEN_SOURCE 600` in test code for e.g. strdup() -set(CMAKE_C_EXTENSIONS ON) +SET(TEST_WITH_VALKEY_VERSION "7.2.5" CACHE STRING "Valkey version used when running tests.") if(ENABLE_SSL) # Generate SSL certs and keys when needed - set(SSL_CONFIGS ca.crt ca.key ca.txt redis.crt redis.key client.crt client.key) + set(SSL_CONFIGS ca.crt ca.key ca.txt valkey.crt valkey.key client.crt client.key) add_custom_command( OUTPUT ${SSL_CONFIGS} COMMAND openssl genrsa -out ca.key 4096 - COMMAND openssl req -x509 -new -nodes -sha256 -key ca.key -days 3650 -subj '/CN=Redis Test CA' -out ca.crt - COMMAND openssl genrsa -out redis.key 2048 - COMMAND openssl req -new -sha256 -key redis.key -subj '/CN=Redis Server Test Cert' | openssl x509 -req -sha256 -CA ca.crt -CAkey ca.key -CAserial ca.txt -CAcreateserial -days 365 -out redis.crt + COMMAND openssl req -x509 -new -nodes -sha256 -key ca.key -days 3650 -subj '/CN=Valkey Test CA' -out ca.crt + COMMAND openssl genrsa -out valkey.key 2048 + COMMAND openssl req -new -sha256 -key valkey.key -subj '/CN=Valkey Server Test Cert' | openssl x509 -req -sha256 -CA ca.crt -CAkey ca.key -CAserial ca.txt -CAcreateserial -days 365 -out valkey.crt COMMAND openssl genrsa -out client.key 2048 - COMMAND openssl req -new -sha256 -key client.key -subj '/CN=Redis Client Test Cert' | openssl x509 -req -sha256 -CA ca.crt -CAkey ca.key -CAserial ca.txt -CAcreateserial -days 365 -out client.crt + COMMAND openssl req -new -sha256 -key client.key -subj '/CN=Valkey Client Test Cert' | openssl x509 -req -sha256 -CA ca.crt -CAkey ca.key -CAserial ca.txt -CAcreateserial -days 365 -out client.crt ) add_custom_target(generate_tls_configs DEPENDS ${SSL_CONFIGS}) - - set(SSL_LIBRARY hiredis_cluster_ssl) + set(SSL_LIBRARY valkey_ssl) endif() -# Targets to setup Redis Clusters for testing if(ENABLE_IPV6_TESTS) set(NO_IPV6 "") else() set(NO_IPV6 "true") # Ignore command endif() -if(TEST_WITH_VALKEY_VERSION) - set(CLUSTER_SCRIPT "${CMAKE_SOURCE_DIR}/tests/scripts/valkey-cluster") - set(CLUSTER_VERSION "VALKEY_VERSION=${TEST_WITH_VALKEY_VERSION}") -else() +# Targets to setup clusters for testing +if(TEST_WITH_REDIS_VERSION) set(CLUSTER_SCRIPT "${CMAKE_SOURCE_DIR}/tests/scripts/redis-cluster") set(CLUSTER_VERSION "REDIS_VERSION=${TEST_WITH_REDIS_VERSION}") +else() + set(CLUSTER_SCRIPT "${CMAKE_SOURCE_DIR}/tests/scripts/valkey-cluster") + set(CLUSTER_VERSION "VALKEY_VERSION=${TEST_WITH_VALKEY_VERSION}") endif() - add_custom_target(start COMMAND PORT=7000 ${CLUSTER_VERSION} ${CLUSTER_SCRIPT} start COMMAND PORT=7100 ${CLUSTER_VERSION} ADDITIONAL_OPTIONS='--requirepass secretword --masterauth secretword' ADDITIONAL_CLI_OPTIONS='-a secretword' ${CLUSTER_SCRIPT} start @@ -64,31 +58,48 @@ else() set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "" FORCE) endif() -# Make sure ctest gives the output when tests fail -list(APPEND CMAKE_CTEST_ARGUMENTS "--output-on-failure") +# Add non-cluster tests + +add_executable(client_test client_test.c) +if(SSL_LIBRARY) + target_compile_definitions(client_test PUBLIC VALKEY_TEST_SSL=1) +endif() +if(LIBEVENT_LIBRARY) + target_compile_definitions(client_test PUBLIC VALKEY_TEST_ASYNC=1) +endif() +target_link_libraries(client_test valkey ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) +add_test(NAME client_test COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/test.sh") +if(TEST_WITH_REDIS_VERSION) + set_property(TEST client_test PROPERTY ENVIRONMENT "VALKEY_SERVER=redis-server") +endif() +if(SSL_LIBRARY) + set_property(TEST client_test PROPERTY ENVIRONMENT "TEST_SSL=1") +endif() + +# Add cluster tests add_executable(ct_async ct_async.c) -target_link_libraries(ct_async hiredis_cluster ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) +target_link_libraries(ct_async valkey ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) add_test(NAME ct_async COMMAND "$") set_tests_properties(ct_async PROPERTIES LABELS "CT") add_executable(ct_commands ct_commands.c test_utils.c) -target_link_libraries(ct_commands hiredis_cluster ${SSL_LIBRARY}) +target_link_libraries(ct_commands valkey ${SSL_LIBRARY}) add_test(NAME ct_commands COMMAND "$") set_tests_properties(ct_commands PROPERTIES LABELS "CT") add_executable(ct_connection ct_connection.c test_utils.c) -target_link_libraries(ct_connection hiredis_cluster ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) +target_link_libraries(ct_connection valkey ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) add_test(NAME ct_connection COMMAND "$") set_tests_properties(ct_connection PROPERTIES LABELS "CT") add_executable(ct_pipeline ct_pipeline.c) -target_link_libraries(ct_pipeline hiredis_cluster ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) +target_link_libraries(ct_pipeline valkey ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) add_test(NAME ct_pipeline COMMAND "$") set_tests_properties(ct_pipeline PROPERTIES LABELS "CT") add_executable(ct_connection_ipv6 ct_connection_ipv6.c) -target_link_libraries(ct_connection_ipv6 hiredis_cluster ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) +target_link_libraries(ct_connection_ipv6 valkey ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) add_test(NAME ct_connection_ipv6 COMMAND "$") set_tests_properties(ct_connection_ipv6 PROPERTIES LABELS "CT") if(NOT ENABLE_IPV6_TESTS) @@ -96,35 +107,24 @@ if(NOT ENABLE_IPV6_TESTS) endif() add_executable(ct_out_of_memory_handling ct_out_of_memory_handling.c) -target_link_libraries(ct_out_of_memory_handling hiredis_cluster ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) +target_link_libraries(ct_out_of_memory_handling valkey ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) add_test(NAME ct_out_of_memory_handling COMMAND "$") set_tests_properties(ct_out_of_memory_handling PROPERTIES LABELS "CT") add_executable(ct_specific_nodes ct_specific_nodes.c test_utils.c) -target_link_libraries(ct_specific_nodes hiredis_cluster ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) +target_link_libraries(ct_specific_nodes valkey ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) add_test(NAME ct_specific_nodes COMMAND "$") set_tests_properties(ct_specific_nodes PROPERTIES LABELS "CT") add_executable(ut_parse_cmd ut_parse_cmd.c test_utils.c) -target_link_libraries(ut_parse_cmd hiredis_cluster ${SSL_LIBRARY}) +target_include_directories(ut_parse_cmd PRIVATE "${PROJECT_SOURCE_DIR}/src") +target_link_libraries(ut_parse_cmd valkey ${SSL_LIBRARY}) add_test(NAME ut_parse_cmd COMMAND "$") set_tests_properties(ut_parse_cmd PROPERTIES LABELS "UT") -if(ENABLE_SSL) - # Executable: tls - add_executable(example_tls main_tls.c) - target_link_libraries(example_tls hiredis_cluster ${SSL_LIBRARY}) - add_dependencies(example_tls generate_tls_configs) - - # Executable: async tls - add_executable(example_async_tls main_async_tls.c) - target_link_libraries(example_async_tls hiredis_cluster ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) - add_dependencies(example_async_tls generate_tls_configs) -endif() - if(LIBUV_LIBRARY) add_executable(ct_async_libuv ct_async_libuv.c) - target_link_libraries(ct_async_libuv hiredis_cluster ${SSL_LIBRARY} ${LIBUV_LIBRARY}) + target_link_libraries(ct_async_libuv valkey ${SSL_LIBRARY} ${LIBUV_LIBRARY}) add_test(NAME ct_async_libuv COMMAND "$") set_tests_properties(ct_async_libuv PROPERTIES LABELS "CT") else() @@ -134,9 +134,7 @@ endif() if(LIBEV_LIBRARY) add_executable(ct_async_libev ct_async_libev.c) - # Temporary remove warning of unused parameter due to an issue in hiredis libev adapter - target_compile_options(ct_async_libev PRIVATE -Wno-unused-parameter) - target_link_libraries(ct_async_libev hiredis_cluster ${SSL_LIBRARY} ${LIBEV_LIBRARY}) + target_link_libraries(ct_async_libev valkey ${SSL_LIBRARY} ${LIBEV_LIBRARY}) add_test(NAME ct_async_libev COMMAND "$") set_tests_properties(ct_async_libev PROPERTIES LABELS "CT") else() @@ -146,7 +144,7 @@ endif() if(GLIB_LIBRARY_FOUND) add_executable(ct_async_glib ct_async_glib.c) - target_link_libraries(ct_async_glib hiredis_cluster ${SSL_LIBRARY} PkgConfig::GLIB_LIBRARY) + target_link_libraries(ct_async_glib valkey ${SSL_LIBRARY} PkgConfig::GLIB_LIBRARY) add_test(NAME ct_async_glib COMMAND "$") set_tests_properties(ct_async_glib PROPERTIES LABELS "CT") else() @@ -154,24 +152,24 @@ else() set_tests_properties(ct_async_glib PROPERTIES DISABLED True) endif() -# Tests using simulated redis node +# Tests using simulated Valkey node add_executable(clusterclient clusterclient.c) -target_link_libraries(clusterclient hiredis_cluster ${SSL_LIBRARY}) +target_link_libraries(clusterclient valkey ${SSL_LIBRARY}) add_executable(clusterclient_async clusterclient_async.c) -target_link_libraries(clusterclient_async hiredis_cluster ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) +target_link_libraries(clusterclient_async valkey ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) add_executable(clusterclient_reconnect_async clusterclient_reconnect_async.c) -target_link_libraries(clusterclient_reconnect_async hiredis_cluster ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) +target_link_libraries(clusterclient_reconnect_async valkey ${SSL_LIBRARY} ${LIBEVENT_LIBRARY}) add_test(NAME set-get-test COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/set-get-test.sh" "$" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") add_test(NAME set-get-test-async COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/set-get-test.sh" - "$" + "$" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") add_test(NAME ask-redirect-test COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/ask-redirect-test.sh" - "$" + "$" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") add_test(NAME ask-redirect-test-async COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/ask-redirect-test.sh" @@ -184,10 +182,10 @@ add_test(NAME ask-redirect-using-cluster-nodes-test-async add_test(NAME moved-redirect-test COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/moved-redirect-test.sh" "$" - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") add_test(NAME moved-redirect-test-async COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/moved-redirect-test.sh" - "$" + "$" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") add_test(NAME moved-redirect-using-cluster-nodes-test-async COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/moved-redirect-using-cluster-nodes-test.sh" @@ -196,23 +194,23 @@ add_test(NAME moved-redirect-using-cluster-nodes-test-async add_test(NAME dbsize-to-all-nodes-test COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/dbsize-to-all-nodes-test.sh" "$" - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") add_test(NAME dbsize-to-all-nodes-test-async COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/dbsize-to-all-nodes-test.sh" "$" - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") add_test(NAME dbsize-to-all-nodes-during-scaledown-test COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/dbsize-to-all-nodes-during-scaledown-test.sh" "$" - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") add_test(NAME dbsize-to-all-nodes-during-scaledown-test-async COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/dbsize-to-all-nodes-during-scaledown-test-async.sh" "$" - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") add_test(NAME reconnect-test COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/reconnect-test.sh" - "$" - WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") + "$" + WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") add_test(NAME timeout-handling-test COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/timeout-handling-test.sh" "$" @@ -253,15 +251,10 @@ if(NOT ENABLE_IPV6_TESTS) set_tests_properties(redirect-with-ipv6-test PROPERTIES DISABLED True) set_tests_properties(redirect-with-ipv6-async-test PROPERTIES DISABLED True) endif() -# This test can't be run on hiredis v1.1.0 due to hiredis issue #1171. -# Disabling the testcase if hiredis contains the issue or if the version is unknown. add_test(NAME redirect-with-hostname-test-async COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/redirect-with-hostname-test.sh" "$" WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/tests/scripts/") -if(hiredis_VERSION VERSION_EQUAL "1.1.0" OR hiredis_VERSION VERSION_EQUAL "0") - set_tests_properties(redirect-with-hostname-test-async PROPERTIES DISABLED True) -endif() add_test(NAME cluster-scale-down-test COMMAND "${CMAKE_SOURCE_DIR}/tests/scripts/cluster-scale-down-test.sh" "$" diff --git a/tests/test.c b/tests/client_test.c similarity index 100% rename from tests/test.c rename to tests/client_test.c diff --git a/libvalkeycluster/tests/clusterclient.c b/tests/clusterclient.c similarity index 99% rename from libvalkeycluster/tests/clusterclient.c rename to tests/clusterclient.c index 7ef38bf2..1144d24a 100644 --- a/libvalkeycluster/tests/clusterclient.c +++ b/tests/clusterclient.c @@ -15,7 +15,6 @@ */ #include "valkeycluster.h" -#include "win32.h" #include #include #include diff --git a/libvalkeycluster/tests/clusterclient_async.c b/tests/clusterclient_async.c similarity index 99% rename from libvalkeycluster/tests/clusterclient_async.c rename to tests/clusterclient_async.c index 8f19589a..f88801ee 100644 --- a/libvalkeycluster/tests/clusterclient_async.c +++ b/tests/clusterclient_async.c @@ -181,7 +181,7 @@ void sendNextCommand(int fd, short kind, void *arg) { void eventCallback(const valkeyClusterContext *cc, int event, void *privdata) { (void)cc; (void)privdata; - char *e = NULL; + const char *e = NULL; switch (event) { case VALKEYCLUSTER_EVENT_SLOTMAP_UPDATED: e = "slotmap-updated"; diff --git a/libvalkeycluster/tests/clusterclient_reconnect_async.c b/tests/clusterclient_reconnect_async.c similarity index 100% rename from libvalkeycluster/tests/clusterclient_reconnect_async.c rename to tests/clusterclient_reconnect_async.c diff --git a/libvalkeycluster/tests/ct_async.c b/tests/ct_async.c similarity index 100% rename from libvalkeycluster/tests/ct_async.c rename to tests/ct_async.c diff --git a/libvalkeycluster/tests/ct_async_glib.c b/tests/ct_async_glib.c similarity index 100% rename from libvalkeycluster/tests/ct_async_glib.c rename to tests/ct_async_glib.c diff --git a/libvalkeycluster/tests/ct_async_libev.c b/tests/ct_async_libev.c similarity index 100% rename from libvalkeycluster/tests/ct_async_libev.c rename to tests/ct_async_libev.c diff --git a/libvalkeycluster/tests/ct_async_libuv.c b/tests/ct_async_libuv.c similarity index 100% rename from libvalkeycluster/tests/ct_async_libuv.c rename to tests/ct_async_libuv.c diff --git a/libvalkeycluster/tests/ct_commands.c b/tests/ct_commands.c similarity index 99% rename from libvalkeycluster/tests/ct_commands.c rename to tests/ct_commands.c index 5281f7f6..902b77c2 100644 --- a/libvalkeycluster/tests/ct_commands.c +++ b/tests/ct_commands.c @@ -1,6 +1,5 @@ #include "test_utils.h" #include "valkeycluster.h" -#include "win32.h" #include #include #include diff --git a/libvalkeycluster/tests/ct_connection.c b/tests/ct_connection.c similarity index 100% rename from libvalkeycluster/tests/ct_connection.c rename to tests/ct_connection.c diff --git a/libvalkeycluster/tests/ct_connection_ipv6.c b/tests/ct_connection_ipv6.c similarity index 98% rename from libvalkeycluster/tests/ct_connection_ipv6.c rename to tests/ct_connection_ipv6.c index 7facccd5..d5c36662 100644 --- a/libvalkeycluster/tests/ct_connection_ipv6.c +++ b/tests/ct_connection_ipv6.c @@ -1,6 +1,5 @@ #include "test_utils.h" #include "valkeycluster.h" -#include "win32.h" #include #include #include diff --git a/libvalkeycluster/tests/ct_out_of_memory_handling.c b/tests/ct_out_of_memory_handling.c similarity index 99% rename from libvalkeycluster/tests/ct_out_of_memory_handling.c rename to tests/ct_out_of_memory_handling.c index a7c7ba68..da8b9f14 100644 --- a/libvalkeycluster/tests/ct_out_of_memory_handling.c +++ b/tests/ct_out_of_memory_handling.c @@ -27,7 +27,6 @@ #include "adapters/libevent.h" #include "test_utils.h" #include "valkeycluster.h" -#include "win32.h" #include #include #include diff --git a/libvalkeycluster/tests/ct_pipeline.c b/tests/ct_pipeline.c similarity index 100% rename from libvalkeycluster/tests/ct_pipeline.c rename to tests/ct_pipeline.c diff --git a/libvalkeycluster/tests/ct_specific_nodes.c b/tests/ct_specific_nodes.c similarity index 100% rename from libvalkeycluster/tests/ct_specific_nodes.c rename to tests/ct_specific_nodes.c diff --git a/libvalkeycluster/tests/scripts/ask-redirect-connection-error-test.sh b/tests/scripts/ask-redirect-connection-error-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/ask-redirect-connection-error-test.sh rename to tests/scripts/ask-redirect-connection-error-test.sh diff --git a/libvalkeycluster/tests/scripts/ask-redirect-test.sh b/tests/scripts/ask-redirect-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/ask-redirect-test.sh rename to tests/scripts/ask-redirect-test.sh diff --git a/libvalkeycluster/tests/scripts/ask-redirect-using-cluster-nodes-test.sh b/tests/scripts/ask-redirect-using-cluster-nodes-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/ask-redirect-using-cluster-nodes-test.sh rename to tests/scripts/ask-redirect-using-cluster-nodes-test.sh diff --git a/libvalkeycluster/tests/scripts/cluster-down-test.sh b/tests/scripts/cluster-down-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/cluster-down-test.sh rename to tests/scripts/cluster-down-test.sh diff --git a/libvalkeycluster/tests/scripts/cluster-scale-down-test.sh b/tests/scripts/cluster-scale-down-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/cluster-scale-down-test.sh rename to tests/scripts/cluster-scale-down-test.sh diff --git a/libvalkeycluster/tests/scripts/command-from-callback-test.sh b/tests/scripts/command-from-callback-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/command-from-callback-test.sh rename to tests/scripts/command-from-callback-test.sh diff --git a/libvalkeycluster/tests/scripts/connect-error-using-cluster-nodes-test.sh b/tests/scripts/connect-error-using-cluster-nodes-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/connect-error-using-cluster-nodes-test.sh rename to tests/scripts/connect-error-using-cluster-nodes-test.sh diff --git a/libvalkeycluster/tests/scripts/connection-error-test.sh b/tests/scripts/connection-error-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/connection-error-test.sh rename to tests/scripts/connection-error-test.sh diff --git a/libvalkeycluster/tests/scripts/dbsize-to-all-nodes-during-scaledown-test-async.sh b/tests/scripts/dbsize-to-all-nodes-during-scaledown-test-async.sh similarity index 100% rename from libvalkeycluster/tests/scripts/dbsize-to-all-nodes-during-scaledown-test-async.sh rename to tests/scripts/dbsize-to-all-nodes-during-scaledown-test-async.sh diff --git a/libvalkeycluster/tests/scripts/dbsize-to-all-nodes-during-scaledown-test.sh b/tests/scripts/dbsize-to-all-nodes-during-scaledown-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/dbsize-to-all-nodes-during-scaledown-test.sh rename to tests/scripts/dbsize-to-all-nodes-during-scaledown-test.sh diff --git a/libvalkeycluster/tests/scripts/dbsize-to-all-nodes-test.sh b/tests/scripts/dbsize-to-all-nodes-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/dbsize-to-all-nodes-test.sh rename to tests/scripts/dbsize-to-all-nodes-test.sh diff --git a/libvalkeycluster/tests/scripts/moved-redirect-test.sh b/tests/scripts/moved-redirect-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/moved-redirect-test.sh rename to tests/scripts/moved-redirect-test.sh diff --git a/libvalkeycluster/tests/scripts/moved-redirect-using-cluster-nodes-test.sh b/tests/scripts/moved-redirect-using-cluster-nodes-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/moved-redirect-using-cluster-nodes-test.sh rename to tests/scripts/moved-redirect-using-cluster-nodes-test.sh diff --git a/libvalkeycluster/tests/scripts/reconnect-test.sh b/tests/scripts/reconnect-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/reconnect-test.sh rename to tests/scripts/reconnect-test.sh diff --git a/libvalkeycluster/tests/scripts/redirect-with-hostname-test.sh b/tests/scripts/redirect-with-hostname-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/redirect-with-hostname-test.sh rename to tests/scripts/redirect-with-hostname-test.sh diff --git a/libvalkeycluster/tests/scripts/redirect-with-ipv6-test.sh b/tests/scripts/redirect-with-ipv6-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/redirect-with-ipv6-test.sh rename to tests/scripts/redirect-with-ipv6-test.sh diff --git a/libvalkeycluster/tests/scripts/redis-cluster b/tests/scripts/redis-cluster similarity index 100% rename from libvalkeycluster/tests/scripts/redis-cluster rename to tests/scripts/redis-cluster diff --git a/libvalkeycluster/tests/scripts/set-get-test.sh b/tests/scripts/set-get-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/set-get-test.sh rename to tests/scripts/set-get-test.sh diff --git a/libvalkeycluster/tests/scripts/simulated-valkey.pl b/tests/scripts/simulated-valkey.pl similarity index 100% rename from libvalkeycluster/tests/scripts/simulated-valkey.pl rename to tests/scripts/simulated-valkey.pl diff --git a/libvalkeycluster/tests/scripts/slots-not-served-test-async.sh b/tests/scripts/slots-not-served-test-async.sh similarity index 100% rename from libvalkeycluster/tests/scripts/slots-not-served-test-async.sh rename to tests/scripts/slots-not-served-test-async.sh diff --git a/libvalkeycluster/tests/scripts/slots-not-served-test.sh b/tests/scripts/slots-not-served-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/slots-not-served-test.sh rename to tests/scripts/slots-not-served-test.sh diff --git a/libvalkeycluster/tests/scripts/timeout-handling-test.sh b/tests/scripts/timeout-handling-test.sh similarity index 100% rename from libvalkeycluster/tests/scripts/timeout-handling-test.sh rename to tests/scripts/timeout-handling-test.sh diff --git a/libvalkeycluster/tests/scripts/valkey-cluster b/tests/scripts/valkey-cluster similarity index 100% rename from libvalkeycluster/tests/scripts/valkey-cluster rename to tests/scripts/valkey-cluster diff --git a/tests/test.sh b/tests/test.sh index b419b9de..0b4e6cf0 100755 --- a/tests/test.sh +++ b/tests/test.sh @@ -122,4 +122,4 @@ done # Treat skips as failures if directed [ "$SKIPS_AS_FAILS" = 1 ] && SKIPS_ARG="${SKIPS_ARG} --skips-as-fails" -${TEST_PREFIX:-} ./test -h 127.0.0.1 -p ${VALKEY_PORT} -s ${SOCK_FILE} ${SSL_TEST_ARGS} ${SKIPS_ARG} +${TEST_PREFIX:-} ./client_test -h 127.0.0.1 -p ${VALKEY_PORT} -s ${SOCK_FILE} ${SSL_TEST_ARGS} ${SKIPS_ARG} diff --git a/libvalkeycluster/tests/test_utils.c b/tests/test_utils.c similarity index 100% rename from libvalkeycluster/tests/test_utils.c rename to tests/test_utils.c diff --git a/libvalkeycluster/tests/test_utils.h b/tests/test_utils.h similarity index 100% rename from libvalkeycluster/tests/test_utils.h rename to tests/test_utils.h diff --git a/libvalkeycluster/tests/ut_parse_cmd.c b/tests/ut_parse_cmd.c similarity index 100% rename from libvalkeycluster/tests/ut_parse_cmd.c rename to tests/ut_parse_cmd.c