SDK: Add sync ChangeState and add msg to its result

This commit is contained in:
Dennis Klein
2019-07-24 10:41:08 +02:00
parent a93840b240
commit d70a203449
5 changed files with 96 additions and 41 deletions

View File

@@ -21,27 +21,39 @@ TEST_F(Topology, Construction)
fair::mq::sdk::Topology topo(mDDSTopo, mDDSSession);
}
TEST_F(Topology, ChangeState)
TEST_F(Topology, ChangeState_async1)
{
using fair::mq::sdk::Topology;
using fair::mq::sdk::TopologyTransition;
Topology topo(mDDSTopo, mDDSSession);
Topology::ChangeStateResult r;
fair::mq::tools::Semaphore blocker;
topo.ChangeState(TopologyTransition::Stop, [&](Topology::ChangeStateResult result) {
topo.ChangeState(TopologyTransition::Stop, [&blocker](Topology::ChangeStateResult result) {
LOG(info) << result;
r = result;
EXPECT_EQ(result.rc, fair::mq::AsyncOpResultCode::Ok);
// TODO add the helper to check state consistency
for (const auto& e : result.state) {
EXPECT_EQ(e.second.state, fair::mq::sdk::DeviceState::Ready);
}
blocker.Signal();
});
blocker.Wait();
EXPECT_EQ(r.rc, fair::mq::AsyncOpResult::Ok);
}
TEST_F(Topology, ChangeState_sync)
{
using fair::mq::sdk::Topology;
using fair::mq::sdk::TopologyTransition;
Topology topo(mDDSTopo, mDDSSession);
auto result(topo.ChangeState(TopologyTransition::Stop));
EXPECT_EQ(result.rc, fair::mq::AsyncOpResultCode::Ok);
// TODO add the helper to check state consistency
for (const auto& e : r.state) {
for (const auto& e : result.state) {
EXPECT_EQ(e.second.state, fair::mq::sdk::DeviceState::Ready);
}
}
// TEST_F(Topology, Timeout)
// {
// using fair::mq::sdk::Topology;

View File

@@ -16,7 +16,7 @@
</decltask>
<decltask name="Sink">
<exe reachable="true">fairmq-sink --id sink --color false --channel-config name=data,type=pull,method=connect -P dds</exe>
<exe reachable="true">fairmq-sink --id sink_%taskIndex% --color false --channel-config name=data,type=pull,method=connect -P dds</exe>
<requirements>
<name>SinkWorker</name>
</requirements>
@@ -27,7 +27,9 @@
<main name="main">
<task>Sampler</task>
<task>Sink</task>
<group name="SinkGroup" n="50">
<task>Sink</task>
</group>
</main>
</topology>