mirror of
https://github.com/FairRootGroup/FairMQ.git
synced 2025-10-13 08:41:16 +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
|
||||
SOURCES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/runner.cxx
|
||||
sdk/_dds.cxx
|
||||
# sdk/_dds.cxx
|
||||
sdk/_topology.cxx
|
||||
sdk/TopologyFixture.h
|
||||
|
||||
LINKS
|
||||
SDK
|
||||
Tools
|
||||
DDS::dds_tools_lib
|
||||
DDS::dds_topology_lib
|
||||
INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
TIMEOUT 15
|
||||
|
|
|
@ -9,22 +9,25 @@
|
|||
#ifndef FAIR_MQ_TEST_TOPOLOGYFIXTURE
|
||||
#define FAIR_MQ_TEST_TOPOLOGYFIXTURE
|
||||
|
||||
#include <DDS/Topology.h>
|
||||
#include <TestEnvironment.h>
|
||||
#include <fairlogger/Logger.h>
|
||||
#include "TestEnvironment.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 <stdlib.h>
|
||||
#include <thread>
|
||||
|
||||
namespace fair {
|
||||
namespace mq {
|
||||
namespace test {
|
||||
|
||||
struct Topology : ::testing::Test
|
||||
struct LoggerConfig
|
||||
{
|
||||
Topology()
|
||||
: mDDSTopologyFile(std::string(SDK_TESTSUITE_SOURCE_DIR) + "/test_topo.xml")
|
||||
, mDDSEnv(CMAKE_CURRENT_BINARY_DIR)
|
||||
, mDDSSession(mDDSEnv)
|
||||
LoggerConfig()
|
||||
{
|
||||
Logger::SetConsoleSeverity("debug");
|
||||
Logger::DefineVerbosity("user1",
|
||||
|
@ -32,27 +35,23 @@ struct Topology : ::testing::Test
|
|||
VerbositySpec::Info::severity));
|
||||
Logger::SetVerbosity("user1");
|
||||
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 {
|
||||
// LOG(debug) << "ActivateDDSTopology(\"" << topology_file << "\")";
|
||||
|
@ -60,15 +59,19 @@ struct Topology : ::testing::Test
|
|||
|
||||
auto SetUp() -> void override {
|
||||
LOG(info) << mDDSEnv;
|
||||
mDDSSession.SubmitAgents(1);
|
||||
mDDSSession.SubmitAgents(1);
|
||||
LOG(info) << mDDSSession;
|
||||
mDDSSession.SubmitAgents(2);
|
||||
std::this_thread::sleep_for(std::chrono::seconds(1));
|
||||
mDDSSession.ActivateTopology(mDDSTopologyFile);
|
||||
}
|
||||
|
||||
auto TearDown() -> void override {}
|
||||
|
||||
LoggerConfig mLoggerConfig;
|
||||
std::string mDDSTopologyFile;
|
||||
sdk::DDSEnvironment mDDSEnv;
|
||||
sdk::DDSSession mDDSSession;
|
||||
dds::topology_api::CTopology mDDSTopology;
|
||||
};
|
||||
|
||||
} /* namespace test */
|
||||
|
|
|
@ -6,16 +6,17 @@
|
|||
* copied verbatim in the file "LICENSE" *
|
||||
********************************************************************************/
|
||||
|
||||
// #include "TopologyFixture.h"
|
||||
#include "TopologyFixture.h"
|
||||
|
||||
// #include <fairmq/sdk/Topology.h>
|
||||
#include <fairmq/sdk/DDSSession.h>
|
||||
#include <fairmq/sdk/Topology.h>
|
||||
|
||||
namespace {
|
||||
|
||||
using Topology = fair::mq::test::TopologyFixture;
|
||||
|
||||
// TEST_F(Topology, Basic) { fair::mq::sdk::Topology topo; }
|
||||
// TEST_F(Topology, Basic2) { fair::mq::sdk::Topology topo; }
|
||||
|
||||
TEST_F(Topology, Basic)
|
||||
{
|
||||
fair::mq::sdk::Topology topo;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -1,49 +1,33 @@
|
|||
<topology name="ExampleDDS">
|
||||
|
||||
<property name="data1" />
|
||||
<property name="data2" />
|
||||
<property name="data" />
|
||||
|
||||
<declrequirement name="SamplerWorker" type="wnname" value="sampler"/>
|
||||
<declrequirement name="ProcessorWorker" type="wnname" value="processor"/>
|
||||
<declrequirement name="SinkWorker" type="wnname" value="sink"/>
|
||||
|
||||
<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>
|
||||
<name>SamplerWorker</name>
|
||||
</requirements>
|
||||
<properties>
|
||||
<name access="write">data1</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>
|
||||
<name access="write">data</name>
|
||||
</properties>
|
||||
</decltask>
|
||||
|
||||
<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>
|
||||
<name>SinkWorker</name>
|
||||
</requirements>
|
||||
<properties>
|
||||
<name access="write">data2</name>
|
||||
<name access="read">data</name>
|
||||
</properties>
|
||||
</decltask>
|
||||
|
||||
<main name="main">
|
||||
<task>Sampler</task>
|
||||
<task>Sink</task>
|
||||
<group name="ProcessorGroup" n="10">
|
||||
<task>Processor</task>
|
||||
</group>
|
||||
</main>
|
||||
|
||||
</topology>
|
||||
|
|
Loading…
Reference in New Issue
Block a user