Skip to content

Commit

Permalink
PubSubAsReliable test fix (#3994) (#4009)
Browse files Browse the repository at this point in the history
* PubSubAsReliable test fix  (#3994)

* Refs #19803: Let descriptor percentages be dynamically configured

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #19803: Fix test

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #19803: address windows warning

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

* Refs #19770: Rev suggestion

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>

---------

Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
(cherry picked from commit ded6cd6)

* 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 <MiguelCompany@eprosima.com>

---------

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>

---------

Signed-off-by: Miguel Company <MiguelCompany@eprosima.com>
Co-authored-by: Mario Domínguez López <116071334+Mario-DL@users.noreply.github.com>
Co-authored-by: Miguel Company <miguelcompany@eprosima.com>
  • Loading branch information
3 people authored Dec 11, 2023
1 parent de8d404 commit f8cf460
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 11 deletions.
24 changes: 16 additions & 8 deletions include/fastdds/rtps/transport/test_UDPv4TransportDescriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct test_UDPv4TransportDescriptor : public SocketTransportDescriptor

//! Test shim parameters
//! Percentage of data messages being dropped
uint8_t dropDataMessagesPercentage;
mutable std::atomic<uint8_t> dropDataMessagesPercentage;
//! Filtering function for dropping data messages
filter drop_data_messages_filter_;
//! Flag to enable dropping of discovery Participant DATA(P) messages
Expand All @@ -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<uint8_t> 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<uint8_t> dropHeartbeatMessagesPercentage;
//! Filtering function for dropping heartbeat messages
filter drop_heartbeat_messages_filter_;
//! Percentage of AckNacks being dropped
uint8_t dropAckNackMessagesPercentage;
mutable std::atomic<uint8_t> dropAckNackMessagesPercentage;
//! Filtering function for dropping AckNacks
filter drop_ack_nack_messages_filter_;
//! Percentage of gap messages being dropped
uint8_t dropGapMessagesPercentage;
mutable std::atomic<uint8_t> 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<uint8_t> percentageOfMessagesToDrop;
// General filtering function for all kind of messages (indiscriminate)
filter messages_filter_;

Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/rtps/transport/test_UDPv4Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/cpp/rtps/transport/test_UDPv4Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,13 @@ class test_UDPv4Transport : public UDPv4Transport
struct PercentageData
{
PercentageData(
uint8_t percent)
std::atomic<uint8_t>& percent)
: percentage(percent)
, accumulator(0)
{
}

uint8_t percentage;
std::atomic<uint8_t>& percentage;
uint8_t accumulator;
};

Expand Down
5 changes: 5 additions & 0 deletions test/blackbox/common/BlackboxTestsPubSubHistory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,6 +992,11 @@ TEST_P(PubSubHistory, PubSubAsReliableKeepLastWithKeyUnorderedReception)
writer.send(data);
ASSERT_TRUE(data.empty());

reader.block_for_at_least(static_cast<size_t>(keys * depth * 0.1));

//! Avoid dropping deterministically the same re-sent samples
testTransport->dropDataMessagesPercentage.store(10);

reader.block_for_all();
reader.stopReception();
}
Expand Down

0 comments on commit f8cf460

Please sign in to comment.