From 90496c89fe9b116b79406998ffc52bcd3bef93ff Mon Sep 17 00:00:00 2001 From: Dennis Klein Date: Tue, 16 Jul 2019 00:07:30 +0200 Subject: [PATCH] Test: Add new testsuite SDK --- CMakeLists.txt | 7 +- fairmq/sdk/CMakeLists.txt | 21 +++-- fairmq/sdk/DDSEnvironment.cxx | 73 +++++++++++++++++ fairmq/sdk/DDSEnvironment.h | 54 +++++++++++++ fairmq/sdk/DDSInfo.h.in | 29 +++++++ fairmq/sdk/DDSSession.cxx | 146 ++++++++++++++++++++++++++++++++++ fairmq/sdk/DDSSession.h | 72 +++++++++++++++++ fairmq/sdk/DDSTopology.h | 54 +++++++++++++ fairmq/sdk/Topology.cxx | 22 +++++ fairmq/sdk/Topology.h | 37 +++++++++ test/CMakeLists.txt | 21 +++++ test/TestEnvironment.h.in | 2 + test/sdk/TopologyFixture.h | 79 ++++++++++++++++++ test/sdk/_dds.cxx | 57 +++++++++++++ test/sdk/_topology.cxx | 21 +++++ test/sdk/test_topo.xml | 50 ++++++++++++ 16 files changed, 739 insertions(+), 6 deletions(-) create mode 100644 fairmq/sdk/DDSEnvironment.cxx create mode 100644 fairmq/sdk/DDSEnvironment.h create mode 100644 fairmq/sdk/DDSInfo.h.in create mode 100644 fairmq/sdk/DDSSession.cxx create mode 100644 fairmq/sdk/DDSSession.h create mode 100644 fairmq/sdk/DDSTopology.h create mode 100644 test/sdk/TopologyFixture.h create mode 100644 test/sdk/_dds.cxx create mode 100644 test/sdk/_topology.cxx create mode 100644 test/sdk/test_topo.xml diff --git a/CMakeLists.txt b/CMakeLists.txt index 548e5080..b076cc54 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,9 +74,14 @@ if(BUILD_NANOMSG_TRANSPORT) ) endif() +if(BUILD_SDK) + set(required_dds_version 2.5.4) +else() + set(required_dds_version 2.4) +endif() if(BUILD_DDS_PLUGIN OR BUILD_SDK) find_package2(PRIVATE DDS REQUIRED - VERSION 2.4 + VERSION ${required_dds_version} ) set(DDS_Boost_COMPONENTS system log log_setup) set(DDS_Boost_VERSION 1.67) diff --git a/fairmq/sdk/CMakeLists.txt b/fairmq/sdk/CMakeLists.txt index 7cb2360e..5bdc2d9f 100644 --- a/fairmq/sdk/CMakeLists.txt +++ b/fairmq/sdk/CMakeLists.txt @@ -6,12 +6,17 @@ # copied verbatim in the file "LICENSE" # ################################################################################ -################ -# libFairMQSDK # -################ +################# +# libFairMQ_SDK # +################# +configure_file(DDSInfo.h.in ${CMAKE_CURRENT_BINARY_DIR}/DDSInfo.h @ONLY) + set(target SDK) set(SDK_PUBLIC_HEADER_FILES + DDSEnvironment.h + ${CMAKE_CURRENT_BINARY_DIR}/DDSInfo.h + DDSSession.h Topology.h ) @@ -19,6 +24,8 @@ set(SDK_PRIVATE_HEADER_FILES ) set(SDK_SOURCE_FILES + DDSEnvironment.cxx + DDSSession.cxx Topology.cxx ) @@ -32,17 +39,21 @@ target_compile_definitions(${target} PUBLIC BOOST_ERROR_CODE_HEADER_ONLY) target_include_directories(${target} PUBLIC $ + $ $ ) target_link_libraries(${target} PUBLIC + Boost::filesystem FairLogger::FairLogger StateMachine PRIVATE - Tools + Boost::boost DDS::dds_intercom_lib - DDS::dds_protocol_lib + DDS::dds_tools_lib + DDS::dds_topology_lib + Tools ) set_target_properties(${target} PROPERTIES VERSION ${PROJECT_GIT_VERSION} diff --git a/fairmq/sdk/DDSEnvironment.cxx b/fairmq/sdk/DDSEnvironment.cxx new file mode 100644 index 00000000..2d4684e8 --- /dev/null +++ b/fairmq/sdk/DDSEnvironment.cxx @@ -0,0 +1,73 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "DDSEnvironment.h" + +#include +#include +#include +#include +#include +#include + +namespace fair { +namespace mq { +namespace sdk { + +// TODO https://github.com/FairRootGroup/DDS/issues/224 +auto LoadDDSEnv(const boost::filesystem::path& config_home, const boost::filesystem::path& prefix) + -> void +{ + setenv("DDS_LOCATION", prefix.c_str(), 1); + if (!config_home.empty()) { + setenv("HOME", config_home.c_str(), 1); + } + std::string path(std::getenv("PATH")); + path = DDSExecutableDir + std::string(":") + path; + setenv("PATH", path.c_str(), 1); + std::istringstream cmd; + cmd.str("DDS_CFG=`dds-user-defaults --ignore-default-sid -p`\n" + "if [ -z \"$DDS_CFG\" ]; then\n" + " dds-user-defaults --ignore-default-sid -d -c \"$HOME/.DDS/DDS.cfg\"\n" + "fi"); + std::system(cmd.str().c_str()); +} + +struct DDSEnvironment::Impl +{ + Impl(Path config_home, Path prefix) + : fConfigHome(std::move(config_home)) + , fInstallPrefix(std::move(prefix)) + { + LoadDDSEnv(fConfigHome, fInstallPrefix); + if (fConfigHome.empty()) { + fConfigHome = std::getenv("HOME"); + } + } + + Path fConfigHome; + Path fInstallPrefix; +}; + +DDSEnvironment::DDSEnvironment(Path config_home, Path prefix) + : fImpl(std::make_shared(std::move(config_home), std::move(prefix))) +{} + +auto DDSEnvironment::GetConfigHome() const -> Path { return fImpl->fConfigHome; } + +auto DDSEnvironment::GetInstallPrefix() const -> Path { return fImpl->fInstallPrefix; } + +auto operator<<(std::ostream& os, DDSEnvironment env) -> std::ostream& +{ + return os << "$DDS_LOCATION: " << env.GetInstallPrefix() << ", " + << "$DDS_CONFIG_HOME: " << env.GetConfigHome() / DDSEnvironment::Path(".DDS"); +} + +} // namespace sdk +} // namespace mq +} // namespace fair diff --git a/fairmq/sdk/DDSEnvironment.h b/fairmq/sdk/DDSEnvironment.h new file mode 100644 index 00000000..ad0517c3 --- /dev/null +++ b/fairmq/sdk/DDSEnvironment.h @@ -0,0 +1,54 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_MQ_SDK_DDSENVIRONMENT_H +#define FAIR_MQ_SDK_DDSENVIRONMENT_H + +#include +#include +#include +#include + +namespace fair { +namespace mq { +namespace sdk { + +/** + * @brief Sets up the DDS environment + * @param config_home Path under which DDS creates a ".DDS" runtime directory for configuration and logs + * @param prefix Path where DDS is installed + */ +auto LoadDDSEnv(const boost::filesystem::path& config_home = "", const boost::filesystem::path& prefix = DDSInstallPrefix) + -> void; + +/** + * @class DDSEnvironment DDSSession.h + * @brief Sets up the DDS environment (object helper) + */ +class DDSEnvironment +{ + public: + using Path = boost::filesystem::path; + + /// @brief See fair::mq::sdk::LoadDDSEnv + explicit DDSEnvironment(Path config_home = "", Path prefix = DDSInstallPrefix); + + auto GetConfigHome() const -> Path; + auto GetInstallPrefix() const -> Path; + + friend auto operator<<(std::ostream& os, DDSEnvironment env) -> std::ostream&; + private: + struct Impl; + std::shared_ptr fImpl; +}; + +} // namespace sdk +} // namespace mq +} // namespace fair + +#endif /* FAIR_MQ_SDK_DDSENVIRONMENT_H */ diff --git a/fairmq/sdk/DDSInfo.h.in b/fairmq/sdk/DDSInfo.h.in new file mode 100644 index 00000000..357d9f7d --- /dev/null +++ b/fairmq/sdk/DDSInfo.h.in @@ -0,0 +1,29 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_MQ_SDK_DDSINFO_H +#define FAIR_MQ_SDK_DDSINFO_H + +#include + +namespace fair { +namespace mq { +namespace sdk { + +const std::string DDSVersion("@DDS_VERSION@"); +const std::string DDSInstallPrefix("@DDS_INSTALL_PREFIX@"); +const std::string DDSExecutableDir("@DDS_BINDIR@"); +const std::string DDSIncludeDir("@DDS_INCDIR@"); +const std::string DDSLibraryDir("@DDS_LIBDIR@"); +const std::string DDSPluginDir("@DDS_PLUGINDIR@"); + +} // namespace sdk +} // namespace mq +} // namespace fair + +#endif /* FAIR_MQ_SDK_DDSINFO_H */ diff --git a/fairmq/sdk/DDSSession.cxx b/fairmq/sdk/DDSSession.cxx new file mode 100644 index 00000000..a2cb25bd --- /dev/null +++ b/fairmq/sdk/DDSSession.cxx @@ -0,0 +1,146 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "DDSSession.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace fair { +namespace mq { +namespace sdk { + +auto operator<<(std::ostream& os, DDSRMSPlugin plugin) -> std::ostream& +{ + switch (plugin) { + case DDSRMSPlugin::ssh: + return os << "ssh"; + case DDSRMSPlugin::localhost: + return os << "localhost"; + default: + __builtin_unreachable(); + } +} + +auto operator>>(std::istream& is, DDSRMSPlugin& plugin) -> std::istream& +{ + std::string value; + if (is >> value) { + if (value == "ssh") { + plugin = DDSRMSPlugin::ssh; + } else if (value == "localhost") { + plugin = DDSRMSPlugin::localhost; + } else { + throw std::runtime_error("Unknown or unsupported DDSRMSPlugin"); + } + } + return is; +} + +struct DDSSession::Impl +{ + Impl(DDSEnvironment env, DDSRMSPlugin plugin) + : fEnv(std::move(env)) + , fDefaultPlugin(std::move(plugin)) + , fSession() + , fId(to_string(fSession.create())) + {} + + Impl(DDSEnvironment env, DDSRMSPlugin plugin, Id existing_id) + : fEnv(std::move(env)) + , fDefaultPlugin(std::move(plugin)) + , fSession() + , fId(std::move(existing_id)) + { + fSession.attach(fId); + } + + ~Impl() + { + fSession.stop(); + fSession.shutdown(); + } + + const DDSEnvironment fEnv; + const DDSRMSPlugin fDefaultPlugin; + dds::tools_api::CSession fSession; + const Id fId; +}; + +DDSSession::DDSSession(DDSEnvironment env, DDSRMSPlugin default_plugin) +: fImpl(std::make_shared(std::move(env), std::move(default_plugin))) {} + +DDSSession::DDSSession(DDSEnvironment env, Id existing_id) +: fImpl(std::make_shared(std::move(env), DDSRMSPlugin::localhost, std::move(existing_id))) {} + +DDSSession::DDSSession(DDSEnvironment env, DDSRMSPlugin default_plugin, Id existing_id) +: fImpl(std::make_shared(std::move(env), std::move(default_plugin), std::move(existing_id))) {} + +auto DDSSession::IsRunning() const -> bool { return fImpl->fSession.IsRunning(); } + +auto DDSSession::GetId() const -> Id { return fImpl->fId; } + +auto DDSSession::GetDefaultPlugin() const -> DDSRMSPlugin { return fImpl->fDefaultPlugin; } + +auto DDSSession::SubmitAgents(Quantity agents) -> void +{ + SubmitAgents(agents, GetDefaultPlugin(), Path()); +} + +auto DDSSession::SubmitAgents(Quantity agents, DDSRMSPlugin plugin) -> void +{ + SubmitAgents(agents, plugin, Path()); +} + +auto DDSSession::SubmitAgents(Quantity agents, const Path& config) -> void +{ + SubmitAgents(agents, GetDefaultPlugin(), std::move(config)); +} + +auto DDSSession::SubmitAgents(Quantity agents, DDSRMSPlugin plugin, const Path& config) -> void +{ + // Requesting to submit 0 agents is not meaningful + assert(agents > 0); + // The config argument is required with all plugins except localhost + if (plugin != DDSRMSPlugin::localhost) { + assert(exists(config)); + } + + dds::tools_api::SSubmitRequestData submitInfo; + submitInfo.m_rms = tools::ToString(plugin); + submitInfo.m_instances = agents; + submitInfo.m_config = config.string(); + + tools::Semaphore blocker; + auto submitRequest = dds::tools_api::SSubmitRequest::makeRequest(submitInfo); + submitRequest->setMessageCallback( + [](const dds::tools_api::SMessageResponseData& message) { LOG(debug) << message; }); + submitRequest->setDoneCallback([&]() { + LOG(debug) << agents << " Agents submitted"; + blocker.Signal(); + }); + + fImpl->fSession.sendRequest(submitRequest); + blocker.Wait(); +} + +auto operator<<(std::ostream& os, DDSSession session) -> std::ostream& +{ + return os << "$DDS_SESSION_ID: " << session.GetId(); +} + +} // namespace sdk +} // namespace mq +} // namespace fair diff --git a/fairmq/sdk/DDSSession.h b/fairmq/sdk/DDSSession.h new file mode 100644 index 00000000..c73c21b0 --- /dev/null +++ b/fairmq/sdk/DDSSession.h @@ -0,0 +1,72 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_MQ_SDK_DDSSESSION_H +#define FAIR_MQ_SDK_DDSSESSION_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace fair { +namespace mq { +namespace sdk { + +/** + * @enum DDSRMSPlugin DDSSession.h + * @brief Supported DDS resource management system plugins + */ +enum class DDSRMSPlugin +{ + localhost, + ssh +}; +auto operator<<(std::ostream& os, DDSRMSPlugin plugin) -> std::ostream&; +auto operator>>(std::istream& is, DDSRMSPlugin& plugin) -> std::istream&; + +/** + * @class DDSSession DDSSession.h + * @brief Represents a DDS session + */ +class DDSSession +{ + public: + using Id = std::string; + using Quantity = std::uint32_t; + using Path = boost::filesystem::path; + + DDSSession() = delete; + explicit DDSSession(DDSEnvironment env, DDSRMSPlugin default_plugin = DDSRMSPlugin::localhost); + explicit DDSSession(DDSEnvironment env, Id existing_id); + explicit DDSSession(DDSEnvironment env, DDSRMSPlugin default_plugin, Id existing_id); + + auto GetId() const -> Id; + auto GetDefaultPlugin() const -> DDSRMSPlugin; + auto IsRunning() const -> bool; + auto SubmitAgents(Quantity agents) -> void; + auto SubmitAgents(Quantity agents, DDSRMSPlugin plugin) -> void; + auto SubmitAgents(Quantity agents, DDSRMSPlugin plugin, const Path& config) -> void; + auto SubmitAgents(Quantity agents, const Path& config) -> void; + + friend auto operator<<(std::ostream& os, DDSSession session) -> std::ostream&; + private: + struct Impl; + std::shared_ptr fImpl; +}; + +} // namespace sdk +} // namespace mq +} // namespace fair + +#endif /* FAIR_MQ_SDK_DDSSESSION_H */ diff --git a/fairmq/sdk/DDSTopology.h b/fairmq/sdk/DDSTopology.h new file mode 100644 index 00000000..814fddc9 --- /dev/null +++ b/fairmq/sdk/DDSTopology.h @@ -0,0 +1,54 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_MQ_SDK_DDSTOPOLOGY_H +#define FAIR_MQ_SDK_DDSTOPOLOGY_H + +#include +#include +#include + +namespace dds { +namespace topology_api { + +class CTopology; + +} // namespace topology_api +} // namespace dds + +namespace fair { +namespace mq { +namespace sdk { + +/** + * @class DDSTopology DDSTopology.h + * @brief Represents a DDS topology + */ +class DDSSession +{ + public: + using CSessionPtr = std::shared_ptr; + + explicit DDSSession(); + explicit DDSSession(std::string existing_session_id); + + auto GetId() const -> const std::string&; + auto IsRunning() const -> bool; + private: + CSessionPtr fSession; + const std::string fId; +}; + +auto LoadDDSEnv(const std::string& config_home = "", const std::string& prefix = DDSInstallPrefix) + -> void; + +} // namespace sdk +} // namespace mq +} // namespace fair + +#endif /* FAIR_MQ_SDK_DDSTOPOLOGY_H */ diff --git a/fairmq/sdk/Topology.cxx b/fairmq/sdk/Topology.cxx index e69de29b..86a6ffc3 100644 --- a/fairmq/sdk/Topology.cxx +++ b/fairmq/sdk/Topology.cxx @@ -0,0 +1,22 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include "Topology.h" + +#include + +namespace fair { +namespace mq { +namespace sdk { + +Topology::Topology() +{} + +} // namespace sdk +} // namespace mq +} // namespace fair diff --git a/fairmq/sdk/Topology.h b/fairmq/sdk/Topology.h index e69de29b..5409fe2b 100644 --- a/fairmq/sdk/Topology.h +++ b/fairmq/sdk/Topology.h @@ -0,0 +1,37 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_MQ_SDK_TOPOLOGY_H +#define FAIR_MQ_SDK_TOPOLOGY_H + +#include + +namespace fair { +namespace mq { +namespace sdk { + +/** + * @class Topology Topology.h + * @brief Represents a FairMQ topology + */ +class Topology +{ + public: + + /// Construct a FairMQ topology from a existing DDS session via the dds::topology_api + /// @param topo a shared_ptr to an initialized CTopology object + explicit Topology(); + + private: +}; + +} // namespace sdk +} // namespace mq +} // namespace fair + +#endif /* FAIR_MQ_SDK_TOPOLOGY_H */ diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index adc5858b..9de5ef9f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -47,6 +47,7 @@ endif() set(MQ_CONFIG "${CMAKE_BINARY_DIR}/test/testsuite_FairMQ.IOPatterns_config.json") set(RUN_TEST_DEVICE "${CMAKE_BINARY_DIR}/test/testhelper_runTestDevice") set(FAIRMQ_BIN_DIR ${CMAKE_BINARY_DIR}/fairmq) +set(SDK_TESTSUITE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/sdk) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/protocols/config.json.in ${MQ_CONFIG}) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/runner.cxx.in ${CMAKE_CURRENT_BINARY_DIR}/runner.cxx) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/TestEnvironment.h.in ${CMAKE_CURRENT_BINARY_DIR}/TestEnvironment.h) @@ -280,3 +281,23 @@ add_testsuite(MemoryResources ${definitions} ) +if(BUILD_SDK) + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/sdk/test_topo.xml + ${CMAKE_BINARY_DIR}/test_topo.xml) + add_testsuite(SDK + SOURCES + ${CMAKE_CURRENT_BINARY_DIR}/runner.cxx + sdk/_dds.cxx + sdk/_topology.cxx + sdk/TopologyFixture.h + + LINKS + SDK + Tools + DDS::dds_tools_lib + INCLUDES ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + TIMEOUT 15 + ${definitions} + ) +endif() diff --git a/test/TestEnvironment.h.in b/test/TestEnvironment.h.in index 0d7d379d..7c6205ed 100644 --- a/test/TestEnvironment.h.in +++ b/test/TestEnvironment.h.in @@ -10,5 +10,7 @@ #define FAIR_MQ_TEST_ENVIRONMENT_H #define FAIRMQ_TEST_ENVIRONMENT "@FAIRMQ_BIN_DIR@" +#define SDK_TESTSUITE_SOURCE_DIR "@SDK_TESTSUITE_SOURCE_DIR@" +#define CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@" #endif /* FAIR_MQ_TEST_ENVIRONMENT_H */ diff --git a/test/sdk/TopologyFixture.h b/test/sdk/TopologyFixture.h new file mode 100644 index 00000000..95b5f6cc --- /dev/null +++ b/test/sdk/TopologyFixture.h @@ -0,0 +1,79 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#ifndef FAIR_MQ_TEST_TOPOLOGYFIXTURE +#define FAIR_MQ_TEST_TOPOLOGYFIXTURE + +#include +#include +#include +#include +#include + +namespace fair { +namespace mq { +namespace test { + +struct Topology : ::testing::Test +{ + Topology() + : mDDSTopologyFile(std::string(SDK_TESTSUITE_SOURCE_DIR) + "/test_topo.xml") + , mDDSEnv(CMAKE_CURRENT_BINARY_DIR) + , mDDSSession(mDDSEnv) + { + Logger::SetConsoleSeverity("debug"); + Logger::DefineVerbosity("user1", + fair::VerbositySpec::Make(VerbositySpec::Info::timestamp_us, + VerbositySpec::Info::severity)); + Logger::SetVerbosity("user1"); + Logger::SetConsoleColor(); + } +// + // auto WaitForIdleDDSAgents(int required) -> void { + // LOG(debug) << "WaitForIdleDDSAgents(" << required << ")"; +// + // DDS Agent Info request + // dds::tools_api::SAgentInfoRequestData agentInfoInfo; + // auto agentInfoRequest = dds::tools_api::SAgentInfoRequest::makeRequest(agentInfoInfo); + // agentInfoRequest->setResponseCallback( + // [&](const dds::tools_api::SAgentInfoResponseData& _response) { + // LOG(debug) << "agent: " << _response.m_index << "/" << _response.m_activeAgentsCount; + // LOG(debug) << "info: " << _response.m_agentInfo; + // }); + // agentInfoRequest->setMessageCallback( + // [](const dds::tools_api::SMessageResponseData& _message) { LOG(debug) << _message; }); + // agentInfoRequest->setDoneCallback([&]() { + // mActiveDDSOps.Signal(); + // }); + // mDDSSession.sendRequest(agentInfoRequest); + // mActiveDDSOps.Wait(); + // } +// + // auto ActivateDDSTopology(const std::string& topology_file) -> void { + // LOG(debug) << "ActivateDDSTopology(\"" << topology_file << "\")"; + // } + + auto SetUp() -> void override { + LOG(info) << mDDSEnv; + mDDSSession.SubmitAgents(1); + mDDSSession.SubmitAgents(1); + } + + auto TearDown() -> void override {} + + std::string mDDSTopologyFile; + sdk::DDSEnvironment mDDSEnv; + sdk::DDSSession mDDSSession; +}; + +} /* namespace test */ +} /* namespace mq */ +} /* namespace fair */ + +#endif /* FAIR_MQ_TEST_TOPOLOGYFIXTURE */ + diff --git a/test/sdk/_dds.cxx b/test/sdk/_dds.cxx new file mode 100644 index 00000000..e15e70c8 --- /dev/null +++ b/test/sdk/_dds.cxx @@ -0,0 +1,57 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +#include +#include +#include +#include +#include +#include + +namespace { + +auto session_test() -> void +{ + fair::Logger::SetConsoleSeverity("debug"); + fair::Logger::DefineVerbosity("user1", + fair::VerbositySpec::Make(fair::VerbositySpec::Info::timestamp_us, + fair::VerbositySpec::Info::severity)); + fair::Logger::SetVerbosity("user1"); + fair::Logger::SetConsoleColor(); + + fair::mq::sdk::DDSEnvironment env(CMAKE_CURRENT_BINARY_DIR); + LOG(debug) << env; + { + fair::mq::sdk::DDSSession session(env); + LOG(debug) << session; + session.SubmitAgents(5); + session.SubmitAgents(5); + } + { + fair::mq::sdk::DDSSession session(env); + LOG(debug) << session; + session.SubmitAgents(5); + } + { + fair::mq::sdk::DDSSession session(env); + LOG(debug) << session; + session.SubmitAgents(5); + } +} + +TEST(DDS, Session) +{ + session_test(); +} + +TEST(DDS, Session2) +{ + session_test(); +} + +} // namespace diff --git a/test/sdk/_topology.cxx b/test/sdk/_topology.cxx new file mode 100644 index 00000000..bf1db46d --- /dev/null +++ b/test/sdk/_topology.cxx @@ -0,0 +1,21 @@ +/******************************************************************************** + * Copyright (C) 2019 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH * + * * + * This software is distributed under the terms of the * + * GNU Lesser General Public Licence (LGPL) version 3, * + * copied verbatim in the file "LICENSE" * + ********************************************************************************/ + +// #include "TopologyFixture.h" + +// #include +#include + +namespace { + + +// TEST_F(Topology, Basic) { fair::mq::sdk::Topology topo; } +// TEST_F(Topology, Basic2) { fair::mq::sdk::Topology topo; } + + +} // namespace diff --git a/test/sdk/test_topo.xml b/test/sdk/test_topo.xml new file mode 100644 index 00000000..b2a3cc61 --- /dev/null +++ b/test/sdk/test_topo.xml @@ -0,0 +1,50 @@ + + + + + + + + + + + @EX_BIN_DIR@/fairmq-ex-dds-sampler --id sampler --color false --channel-config name=data1,type=push,method=bind -S "<@DDS_PLUGIN_LIB_DIR@/" -P dds + + SamplerWorker + + + data1 + + + + + @EX_BIN_DIR@/fairmq-ex-dds-processor --id processor_%taskIndex% --config-key processor --color false --channel-config name=data1,type=pull,method=connect name=data2,type=push,method=connect -S "<@DDS_PLUGIN_LIB_DIR@/" -P dds + + ProcessorWorker + + + data1 + data2 + + + + + @EX_BIN_DIR@/fairmq-ex-dds-sink --id sink --color false --channel-config name=data2,type=pull,method=bind -S "<@DDS_PLUGIN_LIB_DIR@/" -P dds + + SinkWorker + + + data2 + + + +
+ Sampler + Sink + + Processor + +
+ +
+