diff --git a/test/mock/rtps/PDP/fastdds/rtps/builtin/discovery/participant/PDP.h b/test/mock/rtps/PDP/fastdds/rtps/builtin/discovery/participant/PDP.h index bfb56ea780f..c2d3f232f60 100644 --- a/test/mock/rtps/PDP/fastdds/rtps/builtin/discovery/participant/PDP.h +++ b/test/mock/rtps/PDP/fastdds/rtps/builtin/discovery/participant/PDP.h @@ -27,11 +27,18 @@ #include -#ifdef FASTDDS_STATISTICS -#include -#endif // ifdef FASTDDS_STATISTICS - namespace eprosima { + +namespace fastdds { +namespace statistics { +namespace rtps { + +struct IProxyObserver; + +} // namespace rtps +} // namespace statistics +} // namespace fastdds + namespace fastrtps { namespace rtps { diff --git a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h index 51817bddd94..26326c84327 100644 --- a/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h +++ b/test/mock/rtps/RTPSParticipant/fastdds/rtps/participant/RTPSParticipant.h @@ -23,13 +23,14 @@ #include #include #include -#include #include #include #include #include +#include + namespace eprosima { namespace fastdds { diff --git a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp index 09558402292..e9c3dec1e3f 100644 --- a/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp +++ b/test/unittest/statistics/dds/StatisticsDomainParticipantStatusQueryableTests.cpp @@ -131,10 +131,9 @@ class DomainParticipantImplTest : public DomainParticipantImpl bool monitoring_status( fastrtps::rtps::GUID_t guid, - uint32_t status_id, - fastdds::statistics::rtps::DDSEntityStatus*& status) + statistics::MonitorServiceData& status) { - return get_monitoring_status(guid, status_id, status); + return get_monitoring_status(guid, status); } }; @@ -188,17 +187,20 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_in statistics_pub_impl->insert_policy_violation(dw1->guid(), fastdds::dds::RELIABILITY_QOS_POLICY_ID); statistics_pub_impl->insert_policy_violation(dw2->guid(), fastdds::dds::RELIABILITY_QOS_POLICY_ID); - fastdds::statistics::rtps::DDSEntityStatus* incomp_qos_status_dw_1, * incomp_qos_status_dw_2; - incomp_qos_status_dw_1 = new fastdds::statistics::rtps::DDSEntityStatus; - incomp_qos_status_dw_2 = new fastdds::statistics::rtps::DDSEntityStatus; - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), 2, incomp_qos_status_dw_1)); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), 2, incomp_qos_status_dw_2)); + MonitorServiceData incomp_qos_status_dw_1; + incomp_qos_status_dw_1.incompatible_qos_status(IncompatibleQoSStatus_s{}); + MonitorServiceData incomp_qos_status_dw_2; + incomp_qos_status_dw_2.incompatible_qos_status(IncompatibleQoSStatus_s{}); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), incomp_qos_status_dw_1)); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), incomp_qos_status_dw_2)); //! Expect incompatibilities - ASSERT_EQ(1u, static_cast(incomp_qos_status_dw_1)->total_count); - ASSERT_EQ(1u, static_cast(incomp_qos_status_dw_2)->total_count); - ASSERT_EQ(1u, incomp_qos_status_dw_1->policies[fastdds::dds::RELIABILITY_QOS_POLICY_ID].count); - ASSERT_EQ(1u, incomp_qos_status_dw_2->policies[fastdds::dds::RELIABILITY_QOS_POLICY_ID].count); + ASSERT_EQ(1u, incomp_qos_status_dw_1.incompatible_qos_status().total_count()); + ASSERT_EQ(1u, incomp_qos_status_dw_2.incompatible_qos_status().total_count()); + ASSERT_EQ(1u, + incomp_qos_status_dw_1.incompatible_qos_status().policies()[fastdds::dds::RELIABILITY_QOS_POLICY_ID].count()); + ASSERT_EQ(1u, + incomp_qos_status_dw_2.incompatible_qos_status().policies()[fastdds::dds::RELIABILITY_QOS_POLICY_ID].count()); statistics_pub_impl->delete_datawriters(); topic->get_impl()->dereference(); @@ -207,9 +209,6 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_in statistics_participant->delete_publisher(publisher); statistics_participant->delete_contained_entities(); - delete incomp_qos_status_dw_1; - delete incomp_qos_status_dw_2; - #endif // FASTDDS_STATISTICS } @@ -251,15 +250,16 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_li statistics_pub_impl->insert_policy_violation(dw1->guid(), fastdds::dds::LIVELINESS_QOS_POLICY_ID); statistics_pub_impl->insert_policy_violation(dw2->guid(), fastdds::dds::LIVELINESS_QOS_POLICY_ID); - rtps::DDSEntityStatus* liv_lost_status_dw_1, * liv_lost_status_dw_2; - liv_lost_status_dw_1 = new fastdds::statistics::rtps::DDSEntityStatus; - liv_lost_status_dw_2 = new fastdds::statistics::rtps::DDSEntityStatus; - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), 4, liv_lost_status_dw_1)); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), 4, liv_lost_status_dw_2)); + MonitorServiceData liv_lost_status_dw_1; + liv_lost_status_dw_1.liveliness_lost_status(LivelinessLostStatus_s{}); + MonitorServiceData liv_lost_status_dw_2; + liv_lost_status_dw_2.liveliness_lost_status(LivelinessLostStatus_s{}); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), liv_lost_status_dw_1)); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), liv_lost_status_dw_2)); //! Expect incompatibilities - ASSERT_EQ(1, static_cast(liv_lost_status_dw_1)->total_count); - ASSERT_EQ(1, static_cast(liv_lost_status_dw_2)->total_count); + ASSERT_EQ(1u, liv_lost_status_dw_1.liveliness_lost_status().total_count()); + ASSERT_EQ(1u, liv_lost_status_dw_2.liveliness_lost_status().total_count()); statistics_pub_impl->delete_datawriters(); topic->get_impl()->dereference(); @@ -268,9 +268,6 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_li statistics_participant->delete_publisher(publisher); statistics_participant->delete_contained_entities(); - delete liv_lost_status_dw_1; - delete liv_lost_status_dw_2; - #endif // FASTDDS_STATISTICS } @@ -312,15 +309,16 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_de statistics_pub_impl->insert_policy_violation(dw1->guid(), fastdds::dds::DEADLINE_QOS_POLICY_ID); statistics_pub_impl->insert_policy_violation(dw2->guid(), fastdds::dds::DEADLINE_QOS_POLICY_ID); - rtps::DDSEntityStatus* deadline_missed_status_dw_1, * deadline_missed_status_dw_2; - deadline_missed_status_dw_1 = new rtps::DDSEntityStatus; - deadline_missed_status_dw_2 = new rtps::DDSEntityStatus; - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), 6, deadline_missed_status_dw_1)); - ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), 6, deadline_missed_status_dw_2)); + MonitorServiceData deadline_missed_status_dw_1; + deadline_missed_status_dw_1.deadline_missed_status(DeadlineMissedStatus_s{}); + MonitorServiceData deadline_missed_status_dw_2; + deadline_missed_status_dw_2.deadline_missed_status(DeadlineMissedStatus_s{}); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw1->guid(), deadline_missed_status_dw_1)); + ASSERT_TRUE(statistics_participant_impl_test->monitoring_status(dw2->guid(), deadline_missed_status_dw_2)); //! Expect incompatibilities - ASSERT_EQ(1u, static_cast(deadline_missed_status_dw_1)->total_count); - ASSERT_EQ(1u, static_cast(deadline_missed_status_dw_2)->total_count); + ASSERT_EQ(1u, deadline_missed_status_dw_1.deadline_missed_status().total_count()); + ASSERT_EQ(1u, deadline_missed_status_dw_2.deadline_missed_status().total_count()); statistics_pub_impl->delete_datawriters(); topic->get_impl()->dereference(); @@ -329,9 +327,6 @@ TEST_F(StatisticsDomainParticipantStatusQueryableTests, istatus_queryable_get_de statistics_participant->delete_publisher(publisher); statistics_participant->delete_contained_entities(); - delete deadline_missed_status_dw_1; - delete deadline_missed_status_dw_2; - #endif // FASTDDS_STATISTICS } diff --git a/test/unittest/statistics/rtps/MonitorServiceTests.cpp b/test/unittest/statistics/rtps/MonitorServiceTests.cpp index 5416ffb4c3b..af7852a825f 100644 --- a/test/unittest/statistics/rtps/MonitorServiceTests.cpp +++ b/test/unittest/statistics/rtps/MonitorServiceTests.cpp @@ -18,8 +18,8 @@ #include #include -#include +#include #include #include @@ -30,10 +30,9 @@ namespace rtps { struct MockStatusQueryable : public IStatusQueryable { - MOCK_METHOD3(get_monitoring_status, bool ( + MOCK_METHOD2(get_monitoring_status, bool ( const fastrtps::rtps::GUID_t& guid, - const uint32_t& id, - DDSEntityStatus * &status)); + MonitorServiceData & status)); }; struct MockConnectionsQueryable : public IConnectionsQueryable @@ -208,11 +207,11 @@ TEST_F(MonitorServiceTests, multiple_dds_status_updates) ASSERT_TRUE(monitor_srv_.enable_monitor_service()); ASSERT_TRUE(monitor_srv_.is_enabled()); - ON_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_, ::testing::_)). + ON_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_)). WillByDefault(testing::Return(true)); //! Expect the getters for each status that is going to be updated - EXPECT_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_, ::testing::_)). + EXPECT_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_)). Times(n_local_entities * 5);//statuses * n_local_entities //! Trigger statuses updates for each entity @@ -247,7 +246,7 @@ TEST_F(MonitorServiceTests, entity_removal_correctly_performs) WillByDefault(testing::Return(true)); ON_CALL(mock_conns_q_, get_entity_connections(::testing::_, ::testing::_)). WillByDefault(testing::Return(true)); - ON_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_, ::testing::_)). + ON_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_)). WillByDefault(testing::Return(true)); //! Expect the creation 5 ones @@ -257,7 +256,7 @@ TEST_F(MonitorServiceTests, entity_removal_correctly_performs) Times(5); //! Expect the getters for each status that is going to be updated - EXPECT_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_, ::testing::_)). + EXPECT_CALL(mock_status_q_, get_monitoring_status(::testing::_, ::testing::_)). Times(5 * 5); //! Trigger statuses updates for each of the non-existent entity diff --git a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp index 37da738aa49..a54d4c88183 100644 --- a/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp +++ b/test/unittest/statistics/rtps/RTPSStatisticsTests.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -52,6 +51,7 @@ #include #include +#include #include #include diff --git a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp index 622560f0901..0160eec3d28 100644 --- a/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp +++ b/test/unittest/statistics/rtps/mock/StatisticsBase/statistics/rtps/monitor-service/MonitorService.hpp @@ -31,10 +31,10 @@ #include #include #include -#include #include #include +#include #include #include #include