Skip to content

Commit

Permalink
PubSubAsReliable test fix (#3994)
Browse files Browse the repository at this point in the history
* Refs #19803: Let descriptor percentages be dynamically configured

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #19803: Fix test

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #19803: address windows warning

Signed-off-by: Mario Dominguez <[email protected]>

* Refs #19770: Rev suggestion

Signed-off-by: Mario Dominguez <[email protected]>

---------

Signed-off-by: Mario Dominguez <[email protected]>
(cherry picked from commit ded6cd6)
  • Loading branch information
Mario-DL authored and mergify[bot] committed Nov 13, 2023
1 parent 3c0d443 commit edaca5f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
12 changes: 6 additions & 6 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 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 @@ -486,7 +486,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 @@ -988,6 +988,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 edaca5f

Please sign in to comment.