Skip to content

Commit

Permalink
Refs #21096: Extend test transport configuration
Browse files Browse the repository at this point in the history
Signed-off-by: Mario Dominguez <mariodominguez@eprosima.com>
  • Loading branch information
Mario-DL committed Jun 3, 2024
1 parent b002c1d commit b690e65
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,16 @@ struct test_UDPv4TransportDescriptor : public SocketTransportDescriptor
//! Test shim parameters
//! Percentage of data messages being dropped
mutable std::atomic<uint8_t> dropDataMessagesPercentage;
//! Percentage of Data[P] messages being dropped
mutable std::atomic<uint8_t> dropParticipantBuiltinDataMessagesPercentage;
//! Percentage of Data[W] messages being dropped
mutable std::atomic<uint8_t> dropPublicationBuiltinDataMessagesPercentage;
//! Percentage of Data[R] messages being dropped
mutable std::atomic<uint8_t> dropSubscriptionBuiltinDataMessagesPercentage;
//! Filtering function for dropping data messages
filter drop_data_messages_filter_;
//! Filtering function for dropping builtin data messages
filter drop_builtin_data_messages_filter_;
//! Flag to enable dropping of discovery Participant DATA(P) messages
bool dropParticipantBuiltinTopicData;
//! Flag to enable dropping of discovery Writer DATA(W) messages
Expand Down
38 changes: 35 additions & 3 deletions src/cpp/rtps/transport/test_UDPv4Transport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ test_UDPv4TransportDescriptor::DestinationLocatorFilter test_UDPv4Transport::loc
test_UDPv4Transport::test_UDPv4Transport(
const test_UDPv4TransportDescriptor& descriptor)
: drop_data_messages_percentage_(descriptor.dropDataMessagesPercentage)
, drop_participant_builtin_data_messages_percentage_(descriptor.dropParticipantBuiltinDataMessagesPercentage)
, drop_publication_builtin_data_messages_percentage_(descriptor.dropPublicationBuiltinDataMessagesPercentage)
, drop_subscription_builtin_data_messages_percentage_(descriptor.dropSubscriptionBuiltinDataMessagesPercentage)
, drop_data_messages_filter_(descriptor.drop_data_messages_filter_)
, drop_builtin_data_messages_filter_(descriptor.drop_builtin_data_messages_filter_)
, drop_participant_builtin_topic_data_(descriptor.dropParticipantBuiltinTopicData)
, drop_publication_builtin_topic_data_(descriptor.dropPublicationBuiltinTopicData)
, drop_subscription_builtin_topic_data_(descriptor.dropSubscriptionBuiltinTopicData)
Expand Down Expand Up @@ -78,13 +82,17 @@ test_UDPv4Transport::test_UDPv4Transport(
test_UDPv4TransportDescriptor::test_UDPv4TransportDescriptor()
: SocketTransportDescriptor(s_maximumMessageSize, s_maximumInitialPeersRange)
, dropDataMessagesPercentage(0)
, dropParticipantBuiltinDataMessagesPercentage(0)
, dropPublicationBuiltinDataMessagesPercentage(0)
, dropSubscriptionBuiltinDataMessagesPercentage(0)
, drop_data_messages_filter_([](CDRMessage_t&)
{
return false;
})
, dropParticipantBuiltinTopicData(false)
, dropPublicationBuiltinTopicData(false)
, dropSubscriptionBuiltinTopicData(false)
, drop_builtin_data_messages_filter_([](CDRMessage_t&)
{
return false;
})
, dropDataFragMessagesPercentage(0)
, drop_data_frag_messages_filter_([](CDRMessage_t&)
{
Expand Down Expand Up @@ -376,20 +384,44 @@ bool test_UDPv4Transport::packet_should_drop(
{
return true;
}
else if (should_be_dropped(&drop_participant_builtin_data_messages_percentage_))
{
return true;
}
else if (drop_builtin_data_messages_filter_(cdrMessage))
{
return true;
}
}
else if (writer_id == fastrtps::rtps::c_EntityId_SEDPPubWriter)
{
if (drop_publication_builtin_topic_data_)
{
return true;
}
else if (should_be_dropped(&drop_publication_builtin_data_messages_percentage_))
{
return true;
}
else if (drop_builtin_data_messages_filter_(cdrMessage))
{
return true;
}
}
else if (writer_id == fastrtps::rtps::c_EntityId_SEDPSubWriter)
{
if (drop_subscription_builtin_topic_data_)
{
return true;
}
else if (should_be_dropped(&drop_subscription_builtin_data_messages_percentage_))
{
return true;
}
else if (drop_builtin_data_messages_filter_(cdrMessage))
{
return true;
}
}
else
{
Expand Down
4 changes: 4 additions & 0 deletions src/cpp/rtps/transport/test_UDPv4Transport.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,11 @@ class test_UDPv4Transport : public UDPv4Transport
};

PercentageData drop_data_messages_percentage_;
PercentageData drop_participant_builtin_data_messages_percentage_;
PercentageData drop_publication_builtin_data_messages_percentage_;
PercentageData drop_subscription_builtin_data_messages_percentage_;
test_UDPv4TransportDescriptor::filter drop_data_messages_filter_;
test_UDPv4TransportDescriptor::filter drop_builtin_data_messages_filter_;
bool drop_participant_builtin_topic_data_;
bool drop_publication_builtin_topic_data_;
bool drop_subscription_builtin_topic_data_;
Expand Down

0 comments on commit b690e65

Please sign in to comment.