diff --git a/test/blackbox/api/dds-pim/PubSubWriter.hpp b/test/blackbox/api/dds-pim/PubSubWriter.hpp index e39b2cd70a0..9447071437f 100644 --- a/test/blackbox/api/dds-pim/PubSubWriter.hpp +++ b/test/blackbox/api/dds-pim/PubSubWriter.hpp @@ -1418,6 +1418,13 @@ class PubSubWriter return *this; } + PubSubWriter& publisher_groupData( + std::vector group_data) + { + publisher_qos_.group_data() = group_data; + return *this; + } + PubSubWriter& user_data_max_size( uint32_t max_user_data) { diff --git a/test/blackbox/common/BlackboxTestsDiscovery.cpp b/test/blackbox/common/BlackboxTestsDiscovery.cpp index ad8f29561ce..aac78565637 100644 --- a/test/blackbox/common/BlackboxTestsDiscovery.cpp +++ b/test/blackbox/common/BlackboxTestsDiscovery.cpp @@ -1661,3 +1661,51 @@ TEST(Discovery, discovery_cyclone_participant_with_custom_pid) /* Clean up */ factory->delete_participant(participant); } + +//! Using the service to discover that the total sum of USER_DATA and GROUP DATA +//! data exceeds uint16ut byte CDR regression testing +//! Regression test for support case #5154 +TEST_P(Discovery, CdrWriteDataLength) +{ + PubSubReader reader(TEST_TOPIC_NAME); + PubSubWriter writer(TEST_TOPIC_NAME); + + std::size_t user_size = 65500; + std::vector user_data; + user_data.resize(user_size); + std::size_t group_size = 65000; + std::vector group_data; + group_data.resize(group_size); + writer.history_depth(100). + endpoint_userData(user_data).publisher_groupData(group_data).init(); + + ASSERT_TRUE(writer.isInitialized()); + + reader.setOnEndpointDiscoveryFunction([&writer, &user_size, &group_size](WriterDiscoveryStatus /*reason*/, + const PublicationBuiltinTopicData& info) -> bool + { + if (info.guid == writer.datawriter_guid()) + { + std::cout << "Received USER_DATA size from the writer program: " + << info.user_data.size() << std::endl; + std::cout << "Received GROUP_DATA size from the writer program: " + << info.group_data.size() << std::endl; + + return info.user_data.size() == user_size && info.group_data.size() == group_size; + } + + return false; + }); + + reader.history_depth(100). + reliability(eprosima::fastdds::dds::RELIABLE_RELIABILITY_QOS).init(); + + ASSERT_TRUE(reader.isInitialized()); + + + reader.wait_discovery(); + writer.wait_discovery(); + + reader.wait_discovery_result(); + +} \ No newline at end of file