Skip to content

Commit

Permalink
Apply Miguel's rev
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Dominguez <[email protected]>
  • Loading branch information
Mario-DL committed Sep 23, 2024
1 parent 0d592d1 commit fca47eb
Show file tree
Hide file tree
Showing 7 changed files with 98 additions and 25 deletions.
4 changes: 0 additions & 4 deletions src/cpp/fastdds/publisher/DataWriterImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 0 additions & 4 deletions src/cpp/fastdds/subscriber/DataReaderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
4 changes: 0 additions & 4 deletions src/cpp/fastdds/topic/TopicImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
20 changes: 20 additions & 0 deletions test/blackbox/common/DDSBlackboxTestsPersistence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 28 additions & 1 deletion test/unittest/dds/participant/ParticipantTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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.
Expand Down
37 changes: 31 additions & 6 deletions test/unittest/dds/publisher/DataWriterTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
//{
Expand Down
25 changes: 19 additions & 6 deletions test/unittest/dds/subscriber/DataReaderTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*/
Expand Down

0 comments on commit fca47eb

Please sign in to comment.