From 050be91292af202a97fd2df148dbf9358ce5a77a Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Fri, 24 May 2024 10:37:15 +0200 Subject: [PATCH] Refs #20972. Improvements in on_sample_lost blackbox tests. Signed-off-by: Miguel Company --- .../common/DDSBlackboxTestsListeners.cpp | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/blackbox/common/DDSBlackboxTestsListeners.cpp b/test/blackbox/common/DDSBlackboxTestsListeners.cpp index 5926bb01ef5..873537a8da3 100644 --- a/test/blackbox/common/DDSBlackboxTestsListeners.cpp +++ b/test/blackbox/common/DDSBlackboxTestsListeners.cpp @@ -674,11 +674,22 @@ TEST_P(DDSStatus, DataAvailableConditions) subscriber_reader.wait_waitset_timeout(); } +// We want to ensure that samples are only lost due to the custom filter we have set in sample_lost_test_dw_init. +// Since we are going to send 300KB samples in the test for fragments, let's increase the buffer size to avoid any +// other possible loss. +static constexpr uint32_t SAMPLE_LOST_TEST_BUFFER_SIZE = + 300ul * 1024ul // sample size + * 13ul // number of samples + * 2ul; // 2x to avoid any possible loss + template void sample_lost_test_dw_init( PubSubWriter& writer) { auto testTransport = std::make_shared(); + testTransport->sendBufferSize = SAMPLE_LOST_TEST_BUFFER_SIZE; + testTransport->receiveBufferSize = SAMPLE_LOST_TEST_BUFFER_SIZE; + testTransport->drop_data_messages_filter_ = [](eprosima::fastrtps::rtps::CDRMessage_t& msg)-> bool { uint32_t old_pos = msg.pos; @@ -777,15 +788,8 @@ void sample_lost_test_init( PubSubWriter& writer, std::function functor) { - // We want to ensure that samples are only lost due to the custom filter we have set in sample_lost_test_dw_init. - // Since we are going to send 300KB samples in the test for fragments, let's increase the buffer size to avoid any - // other possible loss. - constexpr uint32_t BUFFER_SIZE = - 300ul * 1024ul // sample size - * 13ul // number of samples - * 2ul; // 2x to avoid any possible loss - reader.socket_buffer_size(BUFFER_SIZE); - writer.socket_buffer_size(BUFFER_SIZE); + reader.socket_buffer_size(SAMPLE_LOST_TEST_BUFFER_SIZE); + writer.socket_buffer_size(SAMPLE_LOST_TEST_BUFFER_SIZE); sample_lost_test_dw_init(writer); sample_lost_test_dr_init(reader, functor);