Test: Add new testsuite SDK

This commit is contained in:
Dennis Klein
2019-07-16 00:07:30 +02:00
committed by Dennis Klein
parent 1a93da5be0
commit 90496c89fe
16 changed files with 739 additions and 6 deletions

View File

@@ -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()

View File

@@ -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 */

View File

@@ -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 <DDS/Topology.h>
#include <TestEnvironment.h>
#include <fairlogger/Logger.h>
#include <fairmq/sdk/DDSSession.h>
#include <gtest/gtest.h>
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<dds::tools_api::SAgentInfoRequest>(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 */

57
test/sdk/_dds.cxx Normal file
View File

@@ -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 <TestEnvironment.h>
#include <fairlogger/Logger.h>
#include <fairmq/sdk/DDSEnvironment.h>
#include <fairmq/sdk/DDSInfo.h>
#include <fairmq/sdk/DDSSession.h>
#include <gtest/gtest.h>
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

21
test/sdk/_topology.cxx Normal file
View File

@@ -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 <fairmq/sdk/Topology.h>
#include <fairmq/sdk/DDSSession.h>
namespace {
// TEST_F(Topology, Basic) { fair::mq::sdk::Topology topo; }
// TEST_F(Topology, Basic2) { fair::mq::sdk::Topology topo; }
} // namespace

50
test/sdk/test_topo.xml Normal file
View File

@@ -0,0 +1,50 @@
<topology name="ExampleDDS">
<property name="data1" />
<property name="data2" />
<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 "&lt;@DDS_PLUGIN_LIB_DIR@/" -P dds</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 "&lt;@DDS_PLUGIN_LIB_DIR@/" -P dds</exe>
<requirements>
<name>ProcessorWorker</name>
</requirements>
<properties>
<name access="read">data1</name>
<name access="read">data2</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 "&lt;@DDS_PLUGIN_LIB_DIR@/" -P dds</exe>
<requirements>
<name>SinkWorker</name>
</requirements>
<properties>
<name access="write">data2</name>
</properties>
</decltask>
<main name="main">
<task>Sampler</task>
<task>Sink</task>
<group name="ProcessorGroup" n="10">
<task>Processor</task>
</group>
</main>
</topology>