From f8cf46014b6f7ddf26496238930ad862e253b48e Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Mon, 11 Dec 2023 07:08:26 +0100 Subject: [PATCH] PubSubAsReliable test fix (#3994) (#4009) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * PubSubAsReliable test fix (#3994) * Refs #19803: Let descriptor percentages be dynamically configured Signed-off-by: Mario Dominguez * Refs #19803: Fix test Signed-off-by: Mario Dominguez * Refs #19803: address windows warning Signed-off-by: Mario Dominguez * Refs #19770: Rev suggestion Signed-off-by: Mario Dominguez --------- Signed-off-by: Mario Dominguez (cherry picked from commit ded6cd6257404a4089c70860f820aaf14be4bc06) * Make `test_UDPv4TransportDescriptor` non-copyable and non-moveable (#4017) * Make `test_UDPv4TransportDescriptor` non-copyable and default moveable * Make test_UDPv4TransportDescriptor non-moveable Signed-off-by: Miguel Company --------- Signed-off-by: Miguel Company --------- Signed-off-by: Miguel Company Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com> Co-authored-by: Miguel Company --- .../transport/test_UDPv4TransportDescriptor.h | 24 ++++++++++++------- .../rtps/transport/test_UDPv4Transport.cpp | 2 +- src/cpp/rtps/transport/test_UDPv4Transport.h | 4 ++-- .../common/BlackboxTestsPubSubHistory.cpp | 5 ++++ 4 files changed, 24 insertions(+), 11 deletions(-) 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(); }