From 870d0deae1b28af7c4fbd5eb7e93cadd8d0d3686 Mon Sep 17 00:00:00 2001 From: Alexey Rybalchenko Date: Thu, 5 Sep 2019 14:40:13 +0200 Subject: [PATCH] Add test for sdk::GroupByCollectionId(TopologyState) --- test/sdk/Fixtures.h | 13 +++++++++++++ test/sdk/_topology.cxx | 29 +++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/test/sdk/Fixtures.h b/test/sdk/Fixtures.h index cf613adf..9085f678 100644 --- a/test/sdk/Fixtures.h +++ b/test/sdk/Fixtures.h @@ -59,14 +59,27 @@ struct TopologyFixture : ::testing::Test auto n(mDDSTopo.GetNumRequiredAgents()); mDDSSession.SubmitAgents(n); mDDSSession.ActivateTopology(mDDSTopo); + std::vector agents = mDDSSession.RequestAgentInfo(); + LOG(debug) << "##### AgentInfo:"; + LOG(debug) << "size: " << agents.size(); for (const auto& a : agents) { LOG(debug) << a; } + std::vector tasks = mDDSSession.RequestTaskInfo(); + LOG(debug) << "##### TaskInfo:"; + LOG(debug) << "size: " << tasks.size(); for (const auto& t : tasks) { LOG(debug) << t; } + + std::vector collections = mDDSTopo.GetCollections(); + LOG(debug) << "##### CollectionInfo:"; + LOG(debug) << "size: " << collections.size(); + for (const auto& c : collections) { + LOG(debug) << c; + } } auto TearDown() -> void override { diff --git a/test/sdk/_topology.cxx b/test/sdk/_topology.cxx index b8a72231..1d80d302 100644 --- a/test/sdk/_topology.cxx +++ b/test/sdk/_topology.cxx @@ -171,6 +171,35 @@ TEST_F(Topology, AsyncChangeStateTimeout) 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) { using namespace fair::mq;