From 6122154f74f81bb111bb0763032b251acf3fd3c1 Mon Sep 17 00:00:00 2001 From: Benjamin Sergeant Date: Fri, 25 Dec 2020 15:27:11 -0800 Subject: [PATCH] test only depend on ixcore and ixcrypto --- CMakeLists.txt | 5 --- test/CMakeLists.txt | 45 +------------------- test/IXTest.cpp | 70 ------------------------------- test/IXTest.h | 8 ---- test/IXWebSocketBroadcastTest.cpp | 8 ++-- 5 files changed, 4 insertions(+), 132 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0186ba5d..ff3cce46 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -257,11 +257,6 @@ install(EXPORT ixwebsocket if (USE_WS OR USE_TEST) add_subdirectory(ixcore) add_subdirectory(ixcrypto) - add_subdirectory(ixcobra) - add_subdirectory(ixredis) - add_subdirectory(ixsnake) - add_subdirectory(ixsentry) - add_subdirectory(ixbots) include(FetchContent) FetchContent_Declare(spdlog diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0a3fde4c..a4729a5e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,11 +22,9 @@ set (TEST_TARGET_NAMES IXHttpTest IXDNSLookupTest IXWebSocketSubProtocolTest - IXSentryClientTest IXWebSocketChatTest - IXWebSocketBroadcastTest + # IXWebSocketBroadcastTest ## FIXME was depending on cobra / take a broadcast server from ws IXWebSocketPerMessageDeflateCompressorTest - IXStreamSqlTest IXStrCaseCompareTest ) @@ -35,11 +33,6 @@ set (TEST_TARGET_NAMES if (UNIX) list(APPEND TEST_TARGET_NAMES IXWebSocketCloseTest - IXCobraChatTest - IXCobraMetricsPublisherTest - IXCobraToSentryBotTest - IXCobraToStatsdBotTest - IXCobraToStdoutBotTest ) endif() @@ -52,22 +45,6 @@ endif() # Disable tests for now that are failing or not reliable -find_package(JsonCpp) -if (NOT JSONCPP_FOUND) - set(JSONCPP_SOURCES ../third_party/jsoncpp/jsoncpp.cpp) -endif() - -if (USE_PYTHON) - find_package(Python COMPONENTS Development) - if (NOT Python_FOUND) - message(FATAL_ERROR "Python3 not found") - endif() - message("Python_FOUND:${Python_FOUND}") - message("Python_VERSION:${Python_VERSION}") - message("Python_Development_FOUND:${Python_Development_FOUND}") - message("Python_LIBRARIES:${Python_LIBRARIES}") -endif() - add_library(ixwebsocket_test) target_sources(ixwebsocket_test PRIVATE ${JSONCPP_SOURCES} @@ -80,8 +57,6 @@ target_include_directories(ixwebsocket_test PRIVATE ${PROJECT_SOURCE_DIR}/Catch2/single_include ../third_party ) -target_link_libraries(ixwebsocket_test ixsnake) -target_link_libraries(ixwebsocket_test ixcobra) target_link_libraries(ixwebsocket_test ixwebsocket) target_link_libraries(ixwebsocket_test ixcrypto) target_link_libraries(ixwebsocket_test spdlog) @@ -99,35 +74,17 @@ foreach(TEST_TARGET_NAME ${TEST_TARGET_NAMES}) target_compile_definitions(${TEST_TARGET_NAME} PRIVATE SPDLOG_COMPILED_LIB=1) - if (NOT JSONCPP_FOUND) - target_include_directories(${TEST_TARGET_NAME} PRIVATE ../third_party/jsoncpp) - endif() - if (APPLE AND USE_TLS) target_link_libraries(${TEST_TARGET_NAME} "-framework foundation" "-framework security") endif() # library with the most dependencies come first target_link_libraries(${TEST_TARGET_NAME} ixwebsocket_test) - target_link_libraries(${TEST_TARGET_NAME} ixbots) - target_link_libraries(${TEST_TARGET_NAME} ixsnake) - target_link_libraries(${TEST_TARGET_NAME} ixcobra) - target_link_libraries(${TEST_TARGET_NAME} ixsentry) - - if (JSONCPP_FOUND) - target_include_directories(${TEST_TARGET_NAME} PRIVATE ${JSONCPP_INCLUDE_DIRS}) - target_link_libraries(${TEST_TARGET_NAME} ${JSONCPP_LIBRARIES}) - endif() - - target_link_libraries(${TEST_TARGET_NAME} ixredis) target_link_libraries(${TEST_TARGET_NAME} ixwebsocket) target_link_libraries(${TEST_TARGET_NAME} ixcrypto) target_link_libraries(${TEST_TARGET_NAME} ixcore) target_link_libraries(${TEST_TARGET_NAME} spdlog) - if (USE_PYTHON) - target_link_libraries(${TEST_TARGET_NAME} ${Python_LIBRARIES}) - endif() add_test(NAME ${TEST_TARGET_NAME} COMMAND ${TEST_TARGET_NAME} diff --git a/test/IXTest.cpp b/test/IXTest.cpp index 8c9e5ff2..85a73498 100644 --- a/test/IXTest.cpp +++ b/test/IXTest.cpp @@ -10,7 +10,6 @@ #include #include #include -#include #include #include #include @@ -205,73 +204,4 @@ namespace ix #endif return scheme; } - - snake::AppConfig makeSnakeServerConfig(int port, bool preferTLS) - { - snake::AppConfig appConfig; - appConfig.port = port; - appConfig.hostname = "127.0.0.1"; - appConfig.verbose = true; - appConfig.redisPort = getFreePort(); - appConfig.redisPassword = ""; - appConfig.redisHosts.push_back("localhost"); // only one host supported now - appConfig.socketTLSOptions = makeServerTLSOptions(preferTLS); - - std::string appsConfigPath("appsConfig.json"); - - // Parse config file - auto str = readAsString(appsConfigPath); - if (str.empty()) - { - std::cout << "Cannot read content of " << appsConfigPath << std::endl; - return appConfig; - } - - std::cout << str << std::endl; - auto apps = nlohmann::json::parse(str); - appConfig.apps = apps["apps"]; - - // Display config on the terminal for debugging - dumpConfig(appConfig); - - return appConfig; - } - - std::string makeCobraEndpoint(int port, bool preferTLS) - { - std::stringstream ss; - ss << getWsScheme(preferTLS) << "localhost:" << port; - std::string endpoint = ss.str(); - - return endpoint; - } - - void runPublisher(const ix::CobraConfig& config, const std::string& channel) - { - ix::CobraMetricsPublisher cobraMetricsPublisher; - cobraMetricsPublisher.configure(config, channel); - cobraMetricsPublisher.setSession(uuid4()); - cobraMetricsPublisher.enable(true); - - Json::Value msg; - msg["fps"] = 60; - - cobraMetricsPublisher.setGenericAttributes("game", "ody"); - - // Wait a bit - ix::msleep(500); - - // publish some messages - cobraMetricsPublisher.push("sms_metric_A_id", msg); // (msg #1) - cobraMetricsPublisher.push("sms_metric_B_id", msg); // (msg #2) - ix::msleep(500); - - cobraMetricsPublisher.push("sms_metric_A_id", msg); // (msg #3) - cobraMetricsPublisher.push("sms_metric_D_id", msg); // (msg #4) - ix::msleep(500); - - cobraMetricsPublisher.push("sms_metric_A_id", msg); // (msg #4) - cobraMetricsPublisher.push("sms_metric_F_id", msg); // (msg #5) - ix::msleep(500); - } } // namespace ix diff --git a/test/IXTest.h b/test/IXTest.h index c56df2fc..27b3a93c 100644 --- a/test/IXTest.h +++ b/test/IXTest.h @@ -7,8 +7,6 @@ #pragma once #include -#include -#include #include #include #include @@ -52,14 +50,8 @@ namespace ix bool startWebSocketEchoServer(ix::WebSocketServer& server); - snake::AppConfig makeSnakeServerConfig(int port, bool preferTLS); - SocketTLSOptions makeClientTLSOptions(); SocketTLSOptions makeServerTLSOptions(bool preferTLS); std::string getHttpScheme(); std::string getWsScheme(bool preferTLS); - - std::string makeCobraEndpoint(int port, bool preferTLS); - - void runPublisher(const ix::CobraConfig& config, const std::string& channel); } // namespace ix diff --git a/test/IXWebSocketBroadcastTest.cpp b/test/IXWebSocketBroadcastTest.cpp index 29569e7e..40324476 100644 --- a/test/IXWebSocketBroadcastTest.cpp +++ b/test/IXWebSocketBroadcastTest.cpp @@ -87,12 +87,10 @@ namespace void WebSocketBroadcastChat::start() { + // + // Which server ?? + // std::string url; - { - bool preferTLS = true; - url = makeCobraEndpoint(_port, preferTLS); - } - _webSocket.setUrl(url); std::stringstream ss;