Add test for sdk::GroupByCollectionId(TopologyState)

This commit is contained in:
Alexey Rybalchenko 2019-09-05 14:40:13 +02:00 committed by Dennis Klein
parent acbf57d6f3
commit 870d0deae1
2 changed files with 42 additions and 0 deletions

View File

@ -59,14 +59,27 @@ struct TopologyFixture : ::testing::Test
auto n(mDDSTopo.GetNumRequiredAgents()); auto n(mDDSTopo.GetNumRequiredAgents());
mDDSSession.SubmitAgents(n); mDDSSession.SubmitAgents(n);
mDDSSession.ActivateTopology(mDDSTopo); mDDSSession.ActivateTopology(mDDSTopo);
std::vector<sdk::DDSAgent> agents = mDDSSession.RequestAgentInfo(); std::vector<sdk::DDSAgent> agents = mDDSSession.RequestAgentInfo();
LOG(debug) << "##### AgentInfo:";
LOG(debug) << "size: " << agents.size();
for (const auto& a : agents) { for (const auto& a : agents) {
LOG(debug) << a; LOG(debug) << a;
} }
std::vector<sdk::DDSTask> tasks = mDDSSession.RequestTaskInfo(); std::vector<sdk::DDSTask> tasks = mDDSSession.RequestTaskInfo();
LOG(debug) << "##### TaskInfo:";
LOG(debug) << "size: " << tasks.size();
for (const auto& t : tasks) { for (const auto& t : tasks) {
LOG(debug) << t; LOG(debug) << t;
} }
std::vector<sdk::DDSCollection> collections = mDDSTopo.GetCollections();
LOG(debug) << "##### CollectionInfo:";
LOG(debug) << "size: " << collections.size();
for (const auto& c : collections) {
LOG(debug) << c;
}
} }
auto TearDown() -> void override { auto TearDown() -> void override {

View File

@ -171,6 +171,35 @@ TEST_F(Topology, AsyncChangeStateTimeout)
mIoContext.run(); mIoContext.run();
} }
TEST_F(Topology, AsyncChangeStateCollectionView)
{
using namespace fair::mq;
tools::SharedSemaphore blocker;
sdk::Topology topo(mDDSTopo, mDDSSession);
topo.AsyncChangeState(
sdk::TopologyTransition::InitDevice,
[=](std::error_code ec, sdk::TopologyState state) mutable {
LOG(info) << ec;
sdk::TopologyStateByCollection cstate(sdk::GroupByCollectionId(state));
LOG(debug) << "num collections: " << cstate.size();
ASSERT_EQ(cstate.size(), 5);
for (const auto& c : cstate) {
LOG(debug) << "\t" << c.first;
State s;
ASSERT_NO_THROW(s = sdk::AggregateState(c.second));
ASSERT_EQ(s, State::InitializingDevice);
LOG(debug) << "\tAggregated state: " << s;
for (const auto& ds : c.second) {
LOG(debug) << "\t\t" << ds.state;
}
}
EXPECT_EQ(ec, std::error_code());
blocker.Signal();
});
blocker.Wait();
}
TEST_F(Topology, ChangeStateFullDeviceLifecycle) TEST_F(Topology, ChangeStateFullDeviceLifecycle)
{ {
using namespace fair::mq; using namespace fair::mq;