From fca47eb1bb1c5e51119b8520db44f55189a5eb24 Mon Sep 17 00:00:00 2001 From: Mario Dominguez Date: Mon, 23 Sep 2024 11:50:03 +0200 Subject: [PATCH] Apply Miguel's rev Signed-off-by: Mario Dominguez --- src/cpp/fastdds/publisher/DataWriterImpl.cpp | 4 -- src/cpp/fastdds/subscriber/DataReaderImpl.cpp | 4 -- src/cpp/fastdds/topic/TopicImpl.cpp | 4 -- .../common/DDSBlackboxTestsPersistence.cpp | 20 ++++++++++ .../dds/participant/ParticipantTests.cpp | 29 ++++++++++++++- .../dds/publisher/DataWriterTests.cpp | 37 ++++++++++++++++--- .../dds/subscriber/DataReaderTests.cpp | 25 ++++++++++--- 7 files changed, 98 insertions(+), 25 deletions(-) diff --git a/src/cpp/fastdds/publisher/DataWriterImpl.cpp b/src/cpp/fastdds/publisher/DataWriterImpl.cpp index 01b3ea2d84d..f4d732ec723 100644 --- a/src/cpp/fastdds/publisher/DataWriterImpl.cpp +++ b/src/cpp/fastdds/publisher/DataWriterImpl.cpp @@ -1940,10 +1940,6 @@ ReturnCode_t DataWriterImpl::check_qos_including_resource_limits( ReturnCode_t DataWriterImpl::check_qos( const DataWriterQos& qos) { - if (qos.durability().kind == PERSISTENT_DURABILITY_QOS) - { - EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, "PERSISTENT Durability not supported, behaving as TRANSIENT instead"); - } if (qos.destination_order().kind == BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS) { EPROSIMA_LOG_ERROR(RTPS_QOS_CHECK, "BY SOURCE TIMESTAMP DestinationOrder not supported"); diff --git a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp index eb91da13950..2ea8a902e88 100644 --- a/src/cpp/fastdds/subscriber/DataReaderImpl.cpp +++ b/src/cpp/fastdds/subscriber/DataReaderImpl.cpp @@ -1497,10 +1497,6 @@ ReturnCode_t DataReaderImpl::check_qos_including_resource_limits( ReturnCode_t DataReaderImpl::check_qos( const DataReaderQos& qos) { - if (qos.durability().kind == PERSISTENT_DURABILITY_QOS) - { - EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, "PERSISTENT Durability not supported, behaving as TRANSIENT instead"); - } if (qos.destination_order().kind == BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS) { EPROSIMA_LOG_ERROR(DDS_QOS_CHECK, "BY SOURCE TIMESTAMP DestinationOrder not supported"); diff --git a/src/cpp/fastdds/topic/TopicImpl.cpp b/src/cpp/fastdds/topic/TopicImpl.cpp index aa26407a81d..c858ce3bafc 100644 --- a/src/cpp/fastdds/topic/TopicImpl.cpp +++ b/src/cpp/fastdds/topic/TopicImpl.cpp @@ -66,10 +66,6 @@ ReturnCode_t TopicImpl::check_qos_including_resource_limits( ReturnCode_t TopicImpl::check_qos( const TopicQos& qos) { - if (PERSISTENT_DURABILITY_QOS == qos.durability().kind) - { - EPROSIMA_LOG_WARNING(RTPS_QOS_CHECK, "PERSISTENT Durability not supported, behaving as TRANSIENT instead"); - } if (BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS == qos.destination_order().kind) { EPROSIMA_LOG_ERROR(DDS_QOS_CHECK, "BY SOURCE TIMESTAMP DestinationOrder not supported"); diff --git a/test/blackbox/common/DDSBlackboxTestsPersistence.cpp b/test/blackbox/common/DDSBlackboxTestsPersistence.cpp index 5d39d6aaad3..30d62ce42b1 100644 --- a/test/blackbox/common/DDSBlackboxTestsPersistence.cpp +++ b/test/blackbox/common/DDSBlackboxTestsPersistence.cpp @@ -564,6 +564,26 @@ TEST_P(DDSPersistenceTests, PubSubAsReliablePubTransientWithNoPersistenceGUIDBeh // Wait expecting receiving all data. reader.block_for_all(); + + // Recreate the DataWriter and DataReader + writer.destroy(); + reader.destroy(); + + writer.init(); + reader.init(); + + ASSERT_TRUE(writer.isInitialized()); + ASSERT_TRUE(reader.isInitialized()); + + // Reader should not receive any data + // as the writer is not transient + auto unreceived_data = default_helloworld_data_generator(); + + // Send data + reader.startReception(unreceived_data); + + // Wait expecting not receiving data. + ASSERT_EQ(reader.block_for_all(std::chrono::seconds(2)), 0u); } #ifdef INSTANTIATE_TEST_SUITE_P diff --git a/test/unittest/dds/participant/ParticipantTests.cpp b/test/unittest/dds/participant/ParticipantTests.cpp index 518332901a2..6d35d254852 100644 --- a/test/unittest/dds/participant/ParticipantTests.cpp +++ b/test/unittest/dds/participant/ParticipantTests.cpp @@ -2909,7 +2909,6 @@ TEST(ParticipantTests, GetParticipantNames) /* * This test checks that a topic is not created with a wrong settings. * 1. Check that the topic is not created if a wrong type name is provided. - * 2. Check that the topic is not created if a non supported durability QoS is provided. */ TEST(ParticipantTests, CreateTopicNegativeClauses) { @@ -2931,6 +2930,34 @@ TEST(ParticipantTests, CreateTopicNegativeClauses) ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); } +/* + * This test checks that a topic is created with a valid settings. + * 1. Check that the topic is created if a supported durability QoS is provided. + */ +TEST(ParticipantTests, CreateTopicPositiveClauses) +{ + // Create the participant + DomainParticipant* participant = + DomainParticipantFactory::get_instance()->create_participant( + (uint32_t)GET_PID() % 230, PARTICIPANT_QOS_DEFAULT); + + // Register the type + TypeSupport type(new TopicDataTypeMock()); + type.register_type(participant); + + // Check that the topic is created if a PERSITENT durability QoS is provided + TopicQos tqos; + Topic* topic; + participant->get_default_topic_qos(tqos); + tqos.durability().kind = PERSISTENT_DURABILITY_QOS; + topic = participant->create_topic("footopic", type.get_type_name(), tqos); + ASSERT_NE(topic, nullptr); + + // Cleanup + ASSERT_EQ(participant->delete_topic(topic), RETCODE_OK); + ASSERT_EQ(DomainParticipantFactory::get_instance()->delete_participant(participant), RETCODE_OK); +} + /* * This test checks the contais_entity() DomainParticipant member function. * 1. Check that the participant contains an already created topic in this participant. diff --git a/test/unittest/dds/publisher/DataWriterTests.cpp b/test/unittest/dds/publisher/DataWriterTests.cpp index 6b21bc5dd72..33a96c5ba53 100644 --- a/test/unittest/dds/publisher/DataWriterTests.cpp +++ b/test/unittest/dds/publisher/DataWriterTests.cpp @@ -651,12 +651,6 @@ TEST(DataWriterTests, InvalidQos) DataWriterQos qos; - // qos = DATAWRITER_QOS_DEFAULT; - // qos.durability().kind = PERSISTENT_DURABILITY_QOS; - // Despite PERSISTENT_DURABILITY is not supported yet, - // DataWriter must behave as TRANSIENT - // EXPECT_EQ(unsupported_code, datawriter->set_qos(qos)); - qos = DATAWRITER_QOS_DEFAULT; qos.destination_order().kind = BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS; EXPECT_EQ(unsupported_code, datawriter->set_qos(qos)); @@ -717,6 +711,37 @@ TEST(DataWriterTests, InvalidQos) ASSERT_TRUE(DomainParticipantFactory::get_instance()->delete_participant(participant) == RETCODE_OK); } +TEST(DataWriterTests, PersistentDurabilityIsAValidQoS) +{ + DomainParticipantQos pqos = PARTICIPANT_QOS_DEFAULT; + pqos.entity_factory().autoenable_created_entities = false; + DomainParticipant* participant = DomainParticipantFactory::get_instance()->create_participant(0, pqos); + ASSERT_NE(participant, nullptr); + + Publisher* publisher = participant->create_publisher(PUBLISHER_QOS_DEFAULT); + ASSERT_NE(publisher, nullptr); + + TypeSupport type(new TopicDataTypeMock()); + type.register_type(participant); + + Topic* topic = participant->create_topic("footopic", type.get_type_name(), TOPIC_QOS_DEFAULT); + ASSERT_NE(topic, nullptr); + + DataWriter* datawriter = publisher->create_datawriter(topic, DATAWRITER_QOS_DEFAULT); + ASSERT_NE(datawriter, nullptr); + + DataWriterQos qos; + qos = DATAWRITER_QOS_DEFAULT; + qos.durability().kind = PERSISTENT_DURABILITY_QOS; + // PERSISTENT DataWriter behaves as TRANSIENT + EXPECT_EQ(RETCODE_OK, datawriter->set_qos(qos)); + + // Cleanup + ASSERT_TRUE(publisher->delete_datawriter(datawriter) == RETCODE_OK); + ASSERT_TRUE(participant->delete_topic(topic) == RETCODE_OK); + ASSERT_TRUE(participant->delete_publisher(publisher) == RETCODE_OK); +} + //TODO: Activate the test once PSM API for DataWriter is in place //TEST(DataWriterTests, DISABLED_ChangePSMDataWriterQos) //{ diff --git a/test/unittest/dds/subscriber/DataReaderTests.cpp b/test/unittest/dds/subscriber/DataReaderTests.cpp index 141e793ba6d..eca15be972c 100644 --- a/test/unittest/dds/subscriber/DataReaderTests.cpp +++ b/test/unittest/dds/subscriber/DataReaderTests.cpp @@ -683,12 +683,6 @@ TEST_F(DataReaderTests, InvalidQos) /* Unsupported QoS */ const ReturnCode_t unsupported_code = RETCODE_UNSUPPORTED; - // qos = DATAREADER_QOS_DEFAULT; - // qos.durability().kind = PERSISTENT_DURABILITY_QOS; - // Despite PERSISTENT_DURABILITY is not supported yet, - // DataReader must behave as TRANSIENT - // EXPECT_EQ(unsupported_code, data_reader_->set_qos(qos)); - qos = DATAREADER_QOS_DEFAULT; qos.destination_order().kind = BY_SOURCE_TIMESTAMP_DESTINATIONORDER_QOS; EXPECT_EQ(unsupported_code, data_reader_->set_qos(qos)); @@ -731,6 +725,10 @@ TEST_F(DataReaderTests, InvalidQos) /* Inmutable QoS */ const ReturnCode_t inmutable_code = RETCODE_IMMUTABLE_POLICY; + qos = DATAREADER_QOS_DEFAULT; + qos.durability().kind = PERSISTENT_DURABILITY_QOS; + EXPECT_EQ(inmutable_code, data_reader_->set_qos(qos)); + qos = DATAREADER_QOS_DEFAULT; qos.resource_limits().max_samples = 5000; qos.resource_limits().max_instances = 2; @@ -783,6 +781,21 @@ TEST_F(DataReaderTests, InvalidQos) EXPECT_EQ(inmutable_code, data_reader_->set_qos(qos)); } +TEST_F(DataReaderTests, PersistentDurabilityIsAValidQoS) +{ + DataReaderQos qos; + qos = DATAREADER_QOS_DEFAULT; + qos.durability().kind = PERSISTENT_DURABILITY_QOS; + + create_entities( + nullptr, + qos + ); + + // PERSISTENT DataReader behaves as TRANSIENT + EXPECT_NE(nullptr, data_reader_); +} + /** * This test checks all variants of read / take in several situations for a keyed plain type. */