Skip to content

Commit

Permalink
DataWriter/Reader get_matched_publication/subscription() Test impleme…
Browse files Browse the repository at this point in the history
…ntation (#5264)

* Refs #21710: DataReader get_matched_publications() get_matched_publication_data() test implementation

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

* Refs #21710: DataWriter get_matched_subscriptions() get_matched_subscription_data() test implementation

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

* Refs #21710: Empty APIs in RTPSParticipant, RTPSWriter, RTPSReader

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

* Refs #21710: RTPS APIs tests

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

* Refs #21710: Rename get_matched_guids() method to matched_writers/readers_guids()

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

* Refs #21709: Minor changes to be coherent with latest design updates

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

* Refs #21709: Add one RTPS participant test and Update  comments to latest design

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

* Refs #21709: Add additional proptection to PubSUbParticipant API

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

* Refs #21709: Change userData() to snake case in PubSubWriter/Reader API

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

* Refs #21709: Minor adjustments after feature impl

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

* Refs #21709: Linter

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

* Refs 21710: Apply Ricardo's review

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

* Refs #21710: Apply missing rev comment

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

* Refs #21710: Remove RTPS_Dll API because the class is already marked with it and windows complains

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

* Refs #21710: Avoid docs compilation failure: remove @ref in doxygen for forward declared types

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

---------

Signed-off-by: Mario Dominguez <[email protected]>
  • Loading branch information
Mario-DL authored Oct 8, 2024
1 parent b287e91 commit 9729667
Show file tree
Hide file tree
Showing 24 changed files with 1,276 additions and 11 deletions.
26 changes: 26 additions & 0 deletions include/fastdds/rtps/participant/RTPSParticipant.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ namespace dds {
namespace builtin {

class TypeLookupManager;
struct PublicationBuiltinTopicData;
struct SubscriptionBuiltinTopicData;

} // namespace builtin
} // namespace dds
Expand Down Expand Up @@ -306,6 +308,30 @@ class RTPS_DllAPI RTPSParticipant
*/
std::vector<fastdds::rtps::TransportNetmaskFilterInfo> get_netmask_filter_info() const;

/**
* @brief Fills the provided fastdds::dds::builtin::PublicationBuiltinTopicData with the information of the
* writer identified by writer_guid.
*
* @param[out] data fastdds::dds::builtin::PublicationBuiltinTopicData to fill.
* @param[in] writer_guid GUID of the writer to get the information from.
* @return True if the writer was found and the data was filled.
*/
bool get_publication_info(
fastdds::dds::builtin::PublicationBuiltinTopicData& data,
const GUID_t& writer_guid) const;

/**
* @brief Fills the provided fastdds::dds::builtin::SubscriptionBuiltinTopicData with the information of the
* reader identified by reader_guid.
*
* @param[out] data fastdds::dds::builtin::SubscriptionBuiltinTopicData to fill.
* @param[in] reader_guid GUID of the reader to get the information from.
* @return True if the reader was found and the data was filled.
*/
bool get_subscription_info(
fastdds::dds::builtin::SubscriptionBuiltinTopicData& data,
const GUID_t& reader_guid) const;

#if HAVE_SECURITY

/**
Expand Down
9 changes: 9 additions & 0 deletions include/fastdds/rtps/reader/RTPSReader.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,15 @@ class RTPSReader
data_filter_ = filter;
}

/**
* @brief Fills the provided vector with the GUIDs of the matched writers.
*
* @param[out] guids Vector to be filled with the GUIDs of the matched writers.
* @return True if the operation was successful.
*/
RTPS_DllAPI bool matched_writers_guids(
std::vector<GUID_t>& guids) const;

/*!
* @brief Returns there is a clean state with all Writers.
* It occurs when the Reader received all samples sent by Writers. In other words,
Expand Down
9 changes: 9 additions & 0 deletions include/fastdds/rtps/writer/RTPSWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,15 @@ class RTPSWriter
return false;
}

/**
* @brief Fills the provided vector with the GUIDs of the matched readers.
*
* @param[out] guids Vector to be filled with the GUIDs of the matched readers.
* @return True if the operation was successful.
*/
RTPS_DllAPI bool matched_readers_guids(
std::vector<GUID_t>& guids) const;

/**
* Tries to remove a change waiting a maximum of the provided microseconds.
* @param max_blocking_time_point Maximum time to wait for.
Expand Down
14 changes: 14 additions & 0 deletions src/cpp/rtps/participant/RTPSParticipant.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,20 @@ std::vector<fastdds::rtps::TransportNetmaskFilterInfo> RTPSParticipant::get_netm
return mp_impl->get_netmask_filter_info();
}

bool RTPSParticipant::get_publication_info(
fastdds::dds::builtin::PublicationBuiltinTopicData&,
const GUID_t&) const
{
return false;
}

bool RTPSParticipant::get_subscription_info(
fastdds::dds::builtin::SubscriptionBuiltinTopicData&,
const GUID_t&) const
{
return false;
}

#if HAVE_SECURITY

bool RTPSParticipant::is_security_enabled_for_writer(
Expand Down
6 changes: 6 additions & 0 deletions src/cpp/rtps/reader/RTPSReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,12 @@ bool RTPSReader::is_sample_valid(
return true;
}

bool RTPSReader::matched_writers_guids(
std::vector<GUID_t>&) const
{
return false;
}

#ifdef FASTDDS_STATISTICS

bool RTPSReader::add_statistics_listener(
Expand Down
6 changes: 6 additions & 0 deletions src/cpp/rtps/writer/RTPSWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,12 @@ bool RTPSWriter::send_nts(
locator_selector.locator_selector.end(), max_blocking_time_point);
}

bool RTPSWriter::matched_readers_guids(
std::vector<GUID_t>&) const
{
return false;
}

#ifdef FASTDDS_STATISTICS

bool RTPSWriter::add_statistics_listener(
Expand Down
12 changes: 12 additions & 0 deletions test/blackbox/api/dds-pim/PubSubParticipant.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,12 @@ class PubSubParticipant
return false;
}

if (publisher_topicname_.empty())
{
EPROSIMA_LOG_ERROR(PUBSUBPARTICIPANT, "Publisher topic name not set");
return false;
}

eprosima::fastdds::dds::Topic* topic =
dynamic_cast<eprosima::fastdds::dds::Topic*>(participant_->lookup_topicdescription(
publisher_topicname_));
Expand Down Expand Up @@ -371,6 +377,12 @@ class PubSubParticipant
return false;
}

if (subscriber_topicname_.empty())
{
EPROSIMA_LOG_ERROR(PUBSUBPARTICIPANT, "Subscriber topic name not set");
return false;
}

eprosima::fastdds::dds::Topic* topic =
dynamic_cast<eprosima::fastdds::dds::Topic*>(participant_->lookup_topicdescription(
subscriber_topicname_));
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/api/dds-pim/PubSubReader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1453,7 +1453,7 @@ class PubSubReader
return *this;
}

PubSubReader& userData(
PubSubReader& user_data(
std::vector<eprosima::fastrtps::rtps::octet> user_data)
{
participant_qos_.user_data() = user_data;
Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/api/dds-pim/PubSubWriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1391,7 +1391,7 @@ class PubSubWriter
return *this;
}

PubSubWriter& userData(
PubSubWriter& user_data(
std::vector<eprosima::fastrtps::rtps::octet> user_data)
{
participant_qos_.user_data() = user_data;
Expand Down
33 changes: 32 additions & 1 deletion test/blackbox/common/BlackboxTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@

#include <gtest/gtest.h>

#include <fastdds/dds/builtin/topic/BuiltinTopicKey.hpp>
#include <fastdds/dds/log/Log.hpp>
#include <fastrtps/rtps/RTPSDomain.h>
#include <fastrtps/xmlparser/XMLProfileManager.h>
#include <fastdds/dds/log/Log.hpp>

#include <thread>
#include <memory>
Expand Down Expand Up @@ -85,6 +86,36 @@ class BlackboxEnvironment : public ::testing::Environment

};

void entity_id_to_builtin_topic_key(
eprosima::fastdds::dds::builtin::BuiltinTopicKey_t& bt_key,
const eprosima::fastrtps::rtps::EntityId_t& entity_id)
{
bt_key.value[0] = 0;
bt_key.value[1] = 0;
bt_key.value[2] = static_cast<uint32_t>(entity_id.value[0]) << 24
| static_cast<uint32_t>(entity_id.value[1]) << 16
| static_cast<uint32_t>(entity_id.value[2]) << 8
| static_cast<uint32_t>(entity_id.value[3]);
}

void guid_prefix_to_builtin_topic_key(
eprosima::fastdds::dds::builtin::BuiltinTopicKey_t& bt_key,
const eprosima::fastrtps::rtps::GuidPrefix_t& guid_prefix)
{
bt_key.value[0] = static_cast<uint32_t>(guid_prefix.value[0]) << 24
| static_cast<uint32_t>(guid_prefix.value[1]) << 16
| static_cast<uint32_t>(guid_prefix.value[2]) << 8
| static_cast<uint32_t>(guid_prefix.value[3]);
bt_key.value[1] = static_cast<uint32_t>(guid_prefix.value[4]) << 24
| static_cast<uint32_t>(guid_prefix.value[5]) << 16
| static_cast<uint32_t>(guid_prefix.value[6]) << 8
| static_cast<uint32_t>(guid_prefix.value[7]);
bt_key.value[2] = static_cast<uint32_t>(guid_prefix.value[8]) << 24
| static_cast<uint32_t>(guid_prefix.value[9]) << 16
| static_cast<uint32_t>(guid_prefix.value[10]) << 8
| static_cast<uint32_t>(guid_prefix.value[11]);
}

int main(
int argc,
char** argv)
Expand Down
23 changes: 23 additions & 0 deletions test/blackbox/common/BlackboxTests.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@
#include <list>
#include <functional>

namespace eprosima {
namespace fastdds {
namespace dds {
namespace builtin {

struct BuiltinTopicKey_t;

} // namespace builtin
} // namespace dds
} // namespace fastdds
} // namespace eprosima

#if HAVE_SECURITY
extern void blackbox_security_init();
#endif // if HAVE_SECURITY
Expand Down Expand Up @@ -202,4 +214,15 @@ void print_non_received_messages(

/***** End auxiliary lambda function *****/

/****** Auxiliary conversion helpers *******/
void entity_id_to_builtin_topic_key(
eprosima::fastdds::dds::builtin::BuiltinTopicKey_t& bt_key,
const eprosima::fastrtps::rtps::EntityId_t& entity_id);

void guid_prefix_to_builtin_topic_key(
eprosima::fastdds::dds::builtin::BuiltinTopicKey_t& bt_key,
const eprosima::fastrtps::rtps::GuidPrefix_t& guid_prefix);

/****** End Auxiliary conversion helpers *******/

#endif // __BLACKBOX_BLACKBOXTESTS_HPP__
2 changes: 1 addition & 1 deletion test/blackbox/common/BlackboxTestsDiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,7 +934,7 @@ TEST_P(Discovery, PubSubAsReliableHelloworldUserData)
PubSubWriter<HelloWorldPubSubType> writer(TEST_TOPIC_NAME);

writer.history_depth(100).
userData({'a', 'b', 'c', 'd'}).init();
user_data({'a', 'b', 'c', 'd'}).init();

ASSERT_TRUE(writer.isInitialized());

Expand Down
6 changes: 3 additions & 3 deletions test/blackbox/common/BlackboxTestsPubSubBasic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@ TEST_P(PubSubBasic, ReceivedDynamicDataWithNoSizeLimit)

writer.history_depth(100)
.partition("A").partition("B").partition("C")
.userData({'a', 'b', 'c', 'd'}).init();
.user_data({'a', 'b', 'c', 'd'}).init();


ASSERT_TRUE(writer.isInitialized());
Expand Down Expand Up @@ -418,7 +418,7 @@ TEST_P(PubSubBasic, ReceivedDynamicDataWithinSizeLimit)

writer.history_depth(100)
.partition("A").partition("B").partition("C")
.userData({'a', 'b', 'c', 'd'}).init();
.user_data({'a', 'b', 'c', 'd'}).init();


ASSERT_TRUE(writer.isInitialized());
Expand Down Expand Up @@ -452,7 +452,7 @@ TEST_P(PubSubBasic, ReceivedUserDataExceedsSizeLimit)
PubSubWriter<HelloWorldPubSubType> writer(TEST_TOPIC_NAME);

writer.history_depth(100)
.userData({'a', 'b', 'c', 'd', 'e', 'f'}).init();
.user_data({'a', 'b', 'c', 'd', 'e', 'f'}).init();

ASSERT_TRUE(writer.isInitialized());

Expand Down
2 changes: 1 addition & 1 deletion test/blackbox/common/BlackboxTestsSecurity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2706,7 +2706,7 @@ TEST_P(Security, BuiltinAuthenticationAndCryptoPlugin_user_data)
pub_property_policy.properties().emplace_back("rtps.endpoint.payload_protection_kind", "ENCRYPT");

writer.history_depth(100).
userData({ 'a', 'b', 'c', 'd', 'e' }).
user_data({ 'a', 'b', 'c', 'd', 'e' }).
property_policy(pub_part_property_policy).
entity_property_policy(pub_property_policy).init();

Expand Down
Loading

0 comments on commit 9729667

Please sign in to comment.