diff --git a/include/fastdds/rtps/transport/test_UDPv4TransportDescriptor.h b/include/fastdds/rtps/transport/test_UDPv4TransportDescriptor.h index 8d1d1602003..dafa7798ae8 100644 --- a/include/fastdds/rtps/transport/test_UDPv4TransportDescriptor.h +++ b/include/fastdds/rtps/transport/test_UDPv4TransportDescriptor.h @@ -38,7 +38,7 @@ struct test_UDPv4TransportDescriptor : public SocketTransportDescriptor //! Test shim parameters //! Percentage of data messages being dropped - uint8_t dropDataMessagesPercentage; + mutable std::atomic dropDataMessagesPercentage; //! Filtering function for dropping data messages filter drop_data_messages_filter_; //! Flag to enable dropping of discovery Participant DATA(P) messages @@ -48,26 +48,26 @@ struct test_UDPv4TransportDescriptor : public SocketTransportDescriptor //! Flag to enable dropping of discovery Reader DATA(R) messages bool dropSubscriptionBuiltinTopicData; //! Percentage of data fragments being dropped - uint8_t dropDataFragMessagesPercentage; + mutable std::atomic dropDataFragMessagesPercentage; //! Filtering function for dropping data fragments messages filter drop_data_frag_messages_filter_; //! Percentage of heartbeats being dropped - uint8_t dropHeartbeatMessagesPercentage; + mutable std::atomic dropHeartbeatMessagesPercentage; //! Filtering function for dropping heartbeat messages filter drop_heartbeat_messages_filter_; //! Percentage of AckNacks being dropped - uint8_t dropAckNackMessagesPercentage; + mutable std::atomic dropAckNackMessagesPercentage; //! Filtering function for dropping AckNacks filter drop_ack_nack_messages_filter_; //! Percentage of gap messages being dropped - uint8_t dropGapMessagesPercentage; + mutable std::atomic dropGapMessagesPercentage; //! Filtering function for dropping gap messages filter drop_gap_messages_filter_; // General filtering function for all kind of sub-messages (indiscriminate) filter sub_messages_filter_; // General drop percentage (indiscriminate) - uint8_t percentageOfMessagesToDrop; + mutable std::atomic percentageOfMessagesToDrop; // General filtering function for all kind of messages (indiscriminate) filter messages_filter_; @@ -91,11 +91,19 @@ struct test_UDPv4TransportDescriptor : public SocketTransportDescriptor //! Copy constructor RTPS_DllAPI test_UDPv4TransportDescriptor( - const test_UDPv4TransportDescriptor& t) = default; + const test_UDPv4TransportDescriptor& t) = delete; //! Copy assignment RTPS_DllAPI test_UDPv4TransportDescriptor& operator =( - const test_UDPv4TransportDescriptor& t) = default; + const test_UDPv4TransportDescriptor& t) = delete; + + //! Move constructor + RTPS_DllAPI test_UDPv4TransportDescriptor( + test_UDPv4TransportDescriptor&& t) = delete; + + //! Move assignment + RTPS_DllAPI test_UDPv4TransportDescriptor& operator =( + test_UDPv4TransportDescriptor&& t) = delete; //! Comparison operator // Filters are not included diff --git a/src/cpp/rtps/transport/test_UDPv4Transport.cpp b/src/cpp/rtps/transport/test_UDPv4Transport.cpp index ddd9ea5ad3b..5a14aaf3466 100644 --- a/src/cpp/rtps/transport/test_UDPv4Transport.cpp +++ b/src/cpp/rtps/transport/test_UDPv4Transport.cpp @@ -501,7 +501,7 @@ bool test_UDPv4Transport::log_drop( bool test_UDPv4Transport::should_be_dropped( PercentageData* percent) { - percent->accumulator += percent->percentage; + percent->accumulator += percent->percentage.load(); if (percent->accumulator >= 100u) { percent->accumulator -= 100u; diff --git a/src/cpp/rtps/transport/test_UDPv4Transport.h b/src/cpp/rtps/transport/test_UDPv4Transport.h index b3df3bd39df..956c46fd9b5 100644 --- a/src/cpp/rtps/transport/test_UDPv4Transport.h +++ b/src/cpp/rtps/transport/test_UDPv4Transport.h @@ -73,13 +73,13 @@ class test_UDPv4Transport : public UDPv4Transport struct PercentageData { PercentageData( - uint8_t percent) + std::atomic& percent) : percentage(percent) , accumulator(0) { } - uint8_t percentage; + std::atomic& percentage; uint8_t accumulator; }; diff --git a/test/blackbox/common/BlackboxTestsPubSubHistory.cpp b/test/blackbox/common/BlackboxTestsPubSubHistory.cpp index a7a26d77b94..0a81d350931 100644 --- a/test/blackbox/common/BlackboxTestsPubSubHistory.cpp +++ b/test/blackbox/common/BlackboxTestsPubSubHistory.cpp @@ -992,6 +992,11 @@ TEST_P(PubSubHistory, PubSubAsReliableKeepLastWithKeyUnorderedReception) writer.send(data); ASSERT_TRUE(data.empty()); + reader.block_for_at_least(static_cast(keys * depth * 0.1)); + + //! Avoid dropping deterministically the same re-sent samples + testTransport->dropDataMessagesPercentage.store(10); + reader.block_for_all(); reader.stopReception(); }