test only depend on ixcore and ixcrypto
This commit is contained in:
parent
0b7919834a
commit
6122154f74
@ -257,11 +257,6 @@ install(EXPORT ixwebsocket
|
|||||||
if (USE_WS OR USE_TEST)
|
if (USE_WS OR USE_TEST)
|
||||||
add_subdirectory(ixcore)
|
add_subdirectory(ixcore)
|
||||||
add_subdirectory(ixcrypto)
|
add_subdirectory(ixcrypto)
|
||||||
add_subdirectory(ixcobra)
|
|
||||||
add_subdirectory(ixredis)
|
|
||||||
add_subdirectory(ixsnake)
|
|
||||||
add_subdirectory(ixsentry)
|
|
||||||
add_subdirectory(ixbots)
|
|
||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
FetchContent_Declare(spdlog
|
FetchContent_Declare(spdlog
|
||||||
|
@ -22,11 +22,9 @@ set (TEST_TARGET_NAMES
|
|||||||
IXHttpTest
|
IXHttpTest
|
||||||
IXDNSLookupTest
|
IXDNSLookupTest
|
||||||
IXWebSocketSubProtocolTest
|
IXWebSocketSubProtocolTest
|
||||||
IXSentryClientTest
|
|
||||||
IXWebSocketChatTest
|
IXWebSocketChatTest
|
||||||
IXWebSocketBroadcastTest
|
# IXWebSocketBroadcastTest ## FIXME was depending on cobra / take a broadcast server from ws
|
||||||
IXWebSocketPerMessageDeflateCompressorTest
|
IXWebSocketPerMessageDeflateCompressorTest
|
||||||
IXStreamSqlTest
|
|
||||||
IXStrCaseCompareTest
|
IXStrCaseCompareTest
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -35,11 +33,6 @@ set (TEST_TARGET_NAMES
|
|||||||
if (UNIX)
|
if (UNIX)
|
||||||
list(APPEND TEST_TARGET_NAMES
|
list(APPEND TEST_TARGET_NAMES
|
||||||
IXWebSocketCloseTest
|
IXWebSocketCloseTest
|
||||||
IXCobraChatTest
|
|
||||||
IXCobraMetricsPublisherTest
|
|
||||||
IXCobraToSentryBotTest
|
|
||||||
IXCobraToStatsdBotTest
|
|
||||||
IXCobraToStdoutBotTest
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@ -52,22 +45,6 @@ endif()
|
|||||||
|
|
||||||
# Disable tests for now that are failing or not reliable
|
# 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)
|
add_library(ixwebsocket_test)
|
||||||
target_sources(ixwebsocket_test PRIVATE
|
target_sources(ixwebsocket_test PRIVATE
|
||||||
${JSONCPP_SOURCES}
|
${JSONCPP_SOURCES}
|
||||||
@ -80,8 +57,6 @@ target_include_directories(ixwebsocket_test PRIVATE
|
|||||||
${PROJECT_SOURCE_DIR}/Catch2/single_include
|
${PROJECT_SOURCE_DIR}/Catch2/single_include
|
||||||
../third_party
|
../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 ixwebsocket)
|
||||||
target_link_libraries(ixwebsocket_test ixcrypto)
|
target_link_libraries(ixwebsocket_test ixcrypto)
|
||||||
target_link_libraries(ixwebsocket_test spdlog)
|
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)
|
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)
|
if (APPLE AND USE_TLS)
|
||||||
target_link_libraries(${TEST_TARGET_NAME} "-framework foundation" "-framework security")
|
target_link_libraries(${TEST_TARGET_NAME} "-framework foundation" "-framework security")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# library with the most dependencies come first
|
# library with the most dependencies come first
|
||||||
target_link_libraries(${TEST_TARGET_NAME} ixwebsocket_test)
|
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} ixwebsocket)
|
||||||
target_link_libraries(${TEST_TARGET_NAME} ixcrypto)
|
target_link_libraries(${TEST_TARGET_NAME} ixcrypto)
|
||||||
target_link_libraries(${TEST_TARGET_NAME} ixcore)
|
target_link_libraries(${TEST_TARGET_NAME} ixcore)
|
||||||
|
|
||||||
target_link_libraries(${TEST_TARGET_NAME} spdlog)
|
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}
|
add_test(NAME ${TEST_TARGET_NAME}
|
||||||
COMMAND ${TEST_TARGET_NAME}
|
COMMAND ${TEST_TARGET_NAME}
|
||||||
|
@ -10,7 +10,6 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ixcobra/IXCobraMetricsPublisher.h>
|
|
||||||
#include <ixcrypto/IXUuid.h>
|
#include <ixcrypto/IXUuid.h>
|
||||||
#include <ixwebsocket/IXNetSystem.h>
|
#include <ixwebsocket/IXNetSystem.h>
|
||||||
#include <ixwebsocket/IXWebSocket.h>
|
#include <ixwebsocket/IXWebSocket.h>
|
||||||
@ -205,73 +204,4 @@ namespace ix
|
|||||||
#endif
|
#endif
|
||||||
return scheme;
|
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
|
} // namespace ix
|
||||||
|
@ -7,8 +7,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <ixcobra/IXCobraConfig.h>
|
|
||||||
#include <ixsnake/IXAppConfig.h>
|
|
||||||
#include <ixwebsocket/IXGetFreePort.h>
|
#include <ixwebsocket/IXGetFreePort.h>
|
||||||
#include <ixwebsocket/IXSocketTLSOptions.h>
|
#include <ixwebsocket/IXSocketTLSOptions.h>
|
||||||
#include <ixwebsocket/IXWebSocketServer.h>
|
#include <ixwebsocket/IXWebSocketServer.h>
|
||||||
@ -52,14 +50,8 @@ namespace ix
|
|||||||
|
|
||||||
bool startWebSocketEchoServer(ix::WebSocketServer& server);
|
bool startWebSocketEchoServer(ix::WebSocketServer& server);
|
||||||
|
|
||||||
snake::AppConfig makeSnakeServerConfig(int port, bool preferTLS);
|
|
||||||
|
|
||||||
SocketTLSOptions makeClientTLSOptions();
|
SocketTLSOptions makeClientTLSOptions();
|
||||||
SocketTLSOptions makeServerTLSOptions(bool preferTLS);
|
SocketTLSOptions makeServerTLSOptions(bool preferTLS);
|
||||||
std::string getHttpScheme();
|
std::string getHttpScheme();
|
||||||
std::string getWsScheme(bool preferTLS);
|
std::string getWsScheme(bool preferTLS);
|
||||||
|
|
||||||
std::string makeCobraEndpoint(int port, bool preferTLS);
|
|
||||||
|
|
||||||
void runPublisher(const ix::CobraConfig& config, const std::string& channel);
|
|
||||||
} // namespace ix
|
} // namespace ix
|
||||||
|
@ -87,12 +87,10 @@ namespace
|
|||||||
|
|
||||||
void WebSocketBroadcastChat::start()
|
void WebSocketBroadcastChat::start()
|
||||||
{
|
{
|
||||||
|
//
|
||||||
|
// Which server ??
|
||||||
|
//
|
||||||
std::string url;
|
std::string url;
|
||||||
{
|
|
||||||
bool preferTLS = true;
|
|
||||||
url = makeCobraEndpoint(_port, preferTLS);
|
|
||||||
}
|
|
||||||
|
|
||||||
_webSocket.setUrl(url);
|
_webSocket.setUrl(url);
|
||||||
|
|
||||||
std::stringstream ss;
|
std::stringstream ss;
|
||||||
|
Loading…
Reference in New Issue
Block a user