mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 16:46:47 +00:00
Tests.SDK: Implement Topology test fixture
This commit is contained in:
parent
cfcdd666bf
commit
53be96d93c
|
@ -287,14 +287,14 @@ if(BUILD_SDK)
|
||||||
add_testsuite(SDK
|
add_testsuite(SDK
|
||||||
SOURCES
|
SOURCES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/runner.cxx
|
${CMAKE_CURRENT_BINARY_DIR}/runner.cxx
|
||||||
sdk/_dds.cxx
|
# sdk/_dds.cxx
|
||||||
sdk/_topology.cxx
|
sdk/_topology.cxx
|
||||||
sdk/TopologyFixture.h
|
sdk/TopologyFixture.h
|
||||||
|
|
||||||
LINKS
|
LINKS
|
||||||
SDK
|
SDK
|
||||||
Tools
|
Tools
|
||||||
DDS::dds_tools_lib
|
DDS::dds_topology_lib
|
||||||
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}
|
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
${CMAKE_CURRENT_BINARY_DIR}
|
${CMAKE_CURRENT_BINARY_DIR}
|
||||||
TIMEOUT 15
|
TIMEOUT 15
|
||||||
|
|
|
@ -9,22 +9,25 @@
|
||||||
#ifndef FAIR_MQ_TEST_TOPOLOGYFIXTURE
|
#ifndef FAIR_MQ_TEST_TOPOLOGYFIXTURE
|
||||||
#define FAIR_MQ_TEST_TOPOLOGYFIXTURE
|
#define FAIR_MQ_TEST_TOPOLOGYFIXTURE
|
||||||
|
|
||||||
#include <DDS/Topology.h>
|
#include "TestEnvironment.h"
|
||||||
#include <TestEnvironment.h>
|
|
||||||
#include <fairlogger/Logger.h>
|
|
||||||
#include <fairmq/sdk/DDSSession.h>
|
#include <fairmq/sdk/DDSSession.h>
|
||||||
|
#include <fairmq/Tools.h>
|
||||||
|
|
||||||
|
#include <DDS/Topology.h>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cstdlib>
|
||||||
|
#include <fairlogger/Logger.h>
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <thread>
|
||||||
|
|
||||||
namespace fair {
|
namespace fair {
|
||||||
namespace mq {
|
namespace mq {
|
||||||
namespace test {
|
namespace test {
|
||||||
|
|
||||||
struct Topology : ::testing::Test
|
struct LoggerConfig
|
||||||
{
|
{
|
||||||
Topology()
|
LoggerConfig()
|
||||||
: mDDSTopologyFile(std::string(SDK_TESTSUITE_SOURCE_DIR) + "/test_topo.xml")
|
|
||||||
, mDDSEnv(CMAKE_CURRENT_BINARY_DIR)
|
|
||||||
, mDDSSession(mDDSEnv)
|
|
||||||
{
|
{
|
||||||
Logger::SetConsoleSeverity("debug");
|
Logger::SetConsoleSeverity("debug");
|
||||||
Logger::DefineVerbosity("user1",
|
Logger::DefineVerbosity("user1",
|
||||||
|
@ -32,27 +35,23 @@ struct Topology : ::testing::Test
|
||||||
VerbositySpec::Info::severity));
|
VerbositySpec::Info::severity));
|
||||||
Logger::SetVerbosity("user1");
|
Logger::SetVerbosity("user1");
|
||||||
Logger::SetConsoleColor();
|
Logger::SetConsoleColor();
|
||||||
|
|
||||||
|
std::string path(std::getenv("PATH"));
|
||||||
|
path = tools::ToString(FAIRMQ_TEST_ENVIRONMENT, ":", path);
|
||||||
|
setenv("PATH", path.c_str(), 1);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct TopologyFixture : ::testing::Test
|
||||||
|
{
|
||||||
|
TopologyFixture()
|
||||||
|
: mLoggerConfig()
|
||||||
|
, mDDSTopologyFile(std::string(SDK_TESTSUITE_SOURCE_DIR) + "/test_topo.xml")
|
||||||
|
, mDDSEnv(CMAKE_CURRENT_BINARY_DIR)
|
||||||
|
, mDDSSession(mDDSEnv)
|
||||||
|
, mDDSTopology(mDDSTopologyFile)
|
||||||
|
{}
|
||||||
//
|
//
|
||||||
// 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<dds::tools_api::SAgentInfoRequest>(agentInfoRequest);
|
|
||||||
// mActiveDDSOps.Wait();
|
|
||||||
// }
|
|
||||||
//
|
//
|
||||||
// auto ActivateDDSTopology(const std::string& topology_file) -> void {
|
// auto ActivateDDSTopology(const std::string& topology_file) -> void {
|
||||||
// LOG(debug) << "ActivateDDSTopology(\"" << topology_file << "\")";
|
// LOG(debug) << "ActivateDDSTopology(\"" << topology_file << "\")";
|
||||||
|
@ -60,15 +59,19 @@ struct Topology : ::testing::Test
|
||||||
|
|
||||||
auto SetUp() -> void override {
|
auto SetUp() -> void override {
|
||||||
LOG(info) << mDDSEnv;
|
LOG(info) << mDDSEnv;
|
||||||
mDDSSession.SubmitAgents(1);
|
LOG(info) << mDDSSession;
|
||||||
mDDSSession.SubmitAgents(1);
|
mDDSSession.SubmitAgents(2);
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||||
|
mDDSSession.ActivateTopology(mDDSTopologyFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto TearDown() -> void override {}
|
auto TearDown() -> void override {}
|
||||||
|
|
||||||
|
LoggerConfig mLoggerConfig;
|
||||||
std::string mDDSTopologyFile;
|
std::string mDDSTopologyFile;
|
||||||
sdk::DDSEnvironment mDDSEnv;
|
sdk::DDSEnvironment mDDSEnv;
|
||||||
sdk::DDSSession mDDSSession;
|
sdk::DDSSession mDDSSession;
|
||||||
|
dds::topology_api::CTopology mDDSTopology;
|
||||||
};
|
};
|
||||||
|
|
||||||
} /* namespace test */
|
} /* namespace test */
|
||||||
|
|
|
@ -6,16 +6,17 @@
|
||||||
* copied verbatim in the file "LICENSE" *
|
* copied verbatim in the file "LICENSE" *
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
|
||||||
// #include "TopologyFixture.h"
|
#include "TopologyFixture.h"
|
||||||
|
|
||||||
// #include <fairmq/sdk/Topology.h>
|
#include <fairmq/sdk/Topology.h>
|
||||||
#include <fairmq/sdk/DDSSession.h>
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using Topology = fair::mq::test::TopologyFixture;
|
||||||
|
|
||||||
// TEST_F(Topology, Basic) { fair::mq::sdk::Topology topo; }
|
TEST_F(Topology, Basic)
|
||||||
// TEST_F(Topology, Basic2) { fair::mq::sdk::Topology topo; }
|
{
|
||||||
|
fair::mq::sdk::Topology topo;
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
|
@ -1,49 +1,33 @@
|
||||||
<topology name="ExampleDDS">
|
<topology name="ExampleDDS">
|
||||||
|
|
||||||
<property name="data1" />
|
<property name="data" />
|
||||||
<property name="data2" />
|
|
||||||
|
|
||||||
<declrequirement name="SamplerWorker" type="wnname" value="sampler"/>
|
<declrequirement name="SamplerWorker" type="wnname" value="sampler"/>
|
||||||
<declrequirement name="ProcessorWorker" type="wnname" value="processor"/>
|
|
||||||
<declrequirement name="SinkWorker" type="wnname" value="sink"/>
|
<declrequirement name="SinkWorker" type="wnname" value="sink"/>
|
||||||
|
|
||||||
<decltask name="Sampler">
|
<decltask name="Sampler">
|
||||||
<exe reachable="true">@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</exe>
|
<exe reachable="true">fairmq-bsampler --id sampler --color false --channel-config name=data,type=push,method=bind -P dds --msg-rate 10</exe>
|
||||||
<requirements>
|
<requirements>
|
||||||
<name>SamplerWorker</name>
|
<name>SamplerWorker</name>
|
||||||
</requirements>
|
</requirements>
|
||||||
<properties>
|
<properties>
|
||||||
<name access="write">data1</name>
|
<name access="write">data</name>
|
||||||
</properties>
|
|
||||||
</decltask>
|
|
||||||
|
|
||||||
<decltask name="Processor">
|
|
||||||
<exe reachable="true">@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</exe>
|
|
||||||
<requirements>
|
|
||||||
<name>ProcessorWorker</name>
|
|
||||||
</requirements>
|
|
||||||
<properties>
|
|
||||||
<name access="read">data1</name>
|
|
||||||
<name access="read">data2</name>
|
|
||||||
</properties>
|
</properties>
|
||||||
</decltask>
|
</decltask>
|
||||||
|
|
||||||
<decltask name="Sink">
|
<decltask name="Sink">
|
||||||
<exe reachable="true">@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</exe>
|
<exe reachable="true">fairmq-sink --id sink --color false --channel-config name=data,type=pull,method=connect -P dds</exe>
|
||||||
<requirements>
|
<requirements>
|
||||||
<name>SinkWorker</name>
|
<name>SinkWorker</name>
|
||||||
</requirements>
|
</requirements>
|
||||||
<properties>
|
<properties>
|
||||||
<name access="write">data2</name>
|
<name access="read">data</name>
|
||||||
</properties>
|
</properties>
|
||||||
</decltask>
|
</decltask>
|
||||||
|
|
||||||
<main name="main">
|
<main name="main">
|
||||||
<task>Sampler</task>
|
<task>Sampler</task>
|
||||||
<task>Sink</task>
|
<task>Sink</task>
|
||||||
<group name="ProcessorGroup" n="10">
|
|
||||||
<task>Processor</task>
|
|
||||||
</group>
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
</topology>
|
</topology>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user