diff --git a/ddsrouter.repos b/ddsrouter.repos index 233279a98..4f58ff34c 100644 --- a/ddsrouter.repos +++ b/ddsrouter.repos @@ -6,20 +6,20 @@ repositories: fastcdr: type: git url: https://github.com/eProsima/Fast-CDR.git - version: 2.x + version: v2.3.0 fastdds: type: git url: https://github.com/eProsima/Fast-DDS.git - version: 3.x + version: v3.3.0 dev-utils: type: git url: https://github.com/eProsima/dev-utils.git - version: 1.x + version: v1.3.0 ddspipe: type: git url: https://github.com/eProsima/DDS-Pipe.git - version: 1.x + version: v1.3.0 ddsrouter: type: git url: https://github.com/eProsima/DDS-Router.git - version: main + version: v3.3.0 diff --git a/ddsrouter_core/test/blackbox/ddsrouter_core/dds/local/DDSTestLocal.cpp b/ddsrouter_core/test/blackbox/ddsrouter_core/dds/local/DDSTestLocal.cpp index 7b54503f5..6333079ff 100644 --- a/ddsrouter_core/test/blackbox/ddsrouter_core/dds/local/DDSTestLocal.cpp +++ b/ddsrouter_core/test/blackbox/ddsrouter_core/dds/local/DDSTestLocal.cpp @@ -83,7 +83,8 @@ DdsRouterConfiguration dds_test_simple_configuration( topic_keyed.type_name = "HelloWorldKeyed"; topic_keyed.topic_qos.keyed = true; - conf.ddspipe_configuration.builtin_topics.insert(utils::Heritable::make_heritable(topic)); + conf.ddspipe_configuration.builtin_topics.insert(utils::Heritable::make_heritable( + topic)); conf.ddspipe_configuration.builtin_topics.insert(utils::Heritable::make_heritable( topic_keyed)); } @@ -206,6 +207,70 @@ void test_local_communication( router.stop(); } +template +void test_original_writer_forwarding( + DdsRouterConfiguration ddsrouter_configuration) +{ + INSTANTIATE_LOG_TESTER(eprosima::utils::Log::Kind::Error, 0, 0); + + uint32_t samples_sent = 0; + std::atomic samples_received(0); + std::atomic samples_to_receive(1); + + MsgStruct sent_msg; + MsgStruct recv_msg; + MsgStructType type; + std::string msg_str; + msg_str += "Testing DdsRouter Blackbox Local Communication ..."; + sent_msg.message(msg_str); + // Create DDS Publisher in domain 0 + TestPublisher publisher(type.is_compute_key_provided); + + ASSERT_TRUE(publisher.init(0)); + + // Create DDS Subscriber in domain 1 + TestSubscriber subscriber(type.is_compute_key_provided); + ASSERT_TRUE(subscriber.init(1, &recv_msg, &samples_received)); + + // Create DdsRouter entity + DdsRouter router(ddsrouter_configuration); + router.start(); + + // CASE 1: Send message without original_writer_param, should be set to writers guid + sent_msg.index(samples_sent); + ASSERT_EQ(publisher.publish(sent_msg), eprosima::fastdds::dds::RETCODE_OK); + // Watiting for the message to be received + while (samples_received.load() < 1) + { + } + ASSERT_EQ(subscriber.original_writer_guid(), publisher.original_writer_guid()); + + // CASE 2: Send message with original_writer_param set to unknown, should be set to other value + sent_msg.index(samples_sent); + eprosima::fastdds::rtps::WriteParams params; + params.original_writer_guid(eprosima::fastdds::rtps::GUID_t::unknown()); + ASSERT_EQ(publisher.publish_with_params(sent_msg, params), eprosima::fastdds::dds::RETCODE_OK); + // Watiting for the message to be received + while (samples_received.load() < 2) + { + } + ASSERT_EQ(subscriber.original_writer_guid(), publisher.original_writer_guid()); + + // CASE 3: Send message with original_writer_param set to some value, value must be kept + sent_msg.index(samples_sent); + eprosima::fastdds::rtps::WriteParams params_with_og_writer; + eprosima::fastdds::rtps::GUID_t guid({}, 0x12345678); + params_with_og_writer.original_writer_guid(guid); + ASSERT_EQ(publisher.publish_with_params(sent_msg, params_with_og_writer), eprosima::fastdds::dds::RETCODE_OK); + // Watiting for the message to be received + while (samples_received.load() < 2) + { + } + ASSERT_EQ(subscriber.original_writer_guid(), guid); + + router.stop(); +} + } /* namespace test */ /** @@ -322,6 +387,19 @@ TEST(DDSTestLocal, end_to_end_local_communication_transient_local_disable_dynami true); } + +/** + * Test original writer forwarding in HelloWorld topic between two DDS participants created in different domains, + * by using a router with two Simple Participants at each domain. + */ +TEST(DDSTestLocal, end_to_end_local_communication_original_writer_forwarding) +{ + test::test_original_writer_forwarding( + test::dds_test_simple_configuration()); +} + + + int main( int argc, char** argv) diff --git a/ddsrouter_core/test/blackbox/ddsrouter_core/dds/types/test_participants.hpp b/ddsrouter_core/test/blackbox/ddsrouter_core/dds/types/test_participants.hpp index 7a1dba444..267e784ed 100644 --- a/ddsrouter_core/test/blackbox/ddsrouter_core/dds/types/test_participants.hpp +++ b/ddsrouter_core/test/blackbox/ddsrouter_core/dds/types/test_participants.hpp @@ -152,6 +152,18 @@ class TestPublisher return writer_->write(&hello_); } + //! Publish a sample with parameters + eprosima::fastdds::dds::ReturnCode_t publish_with_params( + MsgStruct msg, + eprosima::fastdds::rtps::WriteParams params) + { + hello_.index(msg.index()); + hello_.message(msg.message()); + + + return writer_->write(&hello_, params); + } + //! Dispose instance eprosima::fastdds::dds::ReturnCode_t dispose_key( MsgStruct msg); @@ -162,6 +174,11 @@ class TestPublisher listener_.wait_discovery(n_subscribers); } + eprosima::fastdds::rtps::GUID_t original_writer_guid() const + { + return writer_->guid(); + } + private: MsgStruct hello_; @@ -357,6 +374,11 @@ class TestSubscriber return listener_.n_key_disposed; } + eprosima::fastdds::rtps::GUID_t original_writer_guid() const + { + return listener_.original_writer_guid; + } + private: eprosima::fastdds::dds::DomainParticipant* participant_; @@ -424,6 +446,8 @@ class TestSubscriber { n_key_disposed++; } + + original_writer_guid = iHandle2GUID(info.original_publication_handle); } } @@ -445,6 +469,9 @@ class TestSubscriber //! Placeholder where received data is stored MsgStruct msg_received; + //! Placeholder where original writer GUID is stored + eprosima::fastdds::rtps::GUID_t original_writer_guid; + std::atomic n_key_disposed; //! Reference to the sample sent by the publisher diff --git a/docs/resources/use_cases/ros_cloud/Dockerfile_ddsrouter b/docs/resources/use_cases/ros_cloud/Dockerfile_ddsrouter index 43b70d967..2062637ff 100644 --- a/docs/resources/use_cases/ros_cloud/Dockerfile_ddsrouter +++ b/docs/resources/use_cases/ros_cloud/Dockerfile_ddsrouter @@ -21,7 +21,7 @@ RUN apt-get update && apt-get install -y \ # Download and build DDS-Router RUN mkdir resources && \ - wget https://raw.githubusercontent.com/eProsima/DDS-Router/main/ddsrouter.repos && \ + wget https://raw.githubusercontent.com/eProsima/DDS-Router/v3.3.0/ddsrouter.repos && \ mkdir src && \ vcs import src < ddsrouter.repos && \ colcon build --event-handlers=console_direct+ diff --git a/docs/resources/use_cases/ros_cloud/Dockerfile_ddsrouter_logon b/docs/resources/use_cases/ros_cloud/Dockerfile_ddsrouter_logon index f2e4d8a75..8b0002fe4 100644 --- a/docs/resources/use_cases/ros_cloud/Dockerfile_ddsrouter_logon +++ b/docs/resources/use_cases/ros_cloud/Dockerfile_ddsrouter_logon @@ -21,7 +21,7 @@ RUN apt-get update && apt-get install -y \ # Download and build DDS-Router RUN mkdir resources && \ - wget https://raw.githubusercontent.com/eProsima/DDS-Router/main/ddsrouter.repos && \ + wget https://raw.githubusercontent.com/eProsima/DDS-Router/v3.3.0/ddsrouter.repos && \ mkdir src && \ vcs import src < ddsrouter.repos && \ colcon build --event-handlers=console_direct+ --cmake-args -DLOG_INFO=ON diff --git a/docs/rst/developer_manual/installation/sources/linux.rst b/docs/rst/developer_manual/installation/sources/linux.rst index f85fdc8a1..e40c4e3a6 100644 --- a/docs/rst/developer_manual/installation/sources/linux.rst +++ b/docs/rst/developer_manual/installation/sources/linux.rst @@ -214,7 +214,7 @@ Colcon installation mkdir -p ~/DDS-Router/src cd ~/DDS-Router - wget https://raw.githubusercontent.com/eProsima/DDS-Router/main/ddsrouter.repos + wget https://raw.githubusercontent.com/eProsima/DDS-Router/v3.3.0/ddsrouter.repos vcs import src < ddsrouter.repos .. note:: @@ -258,7 +258,7 @@ Local installation mkdir -p ~/DDS-Router/src mkdir -p ~/DDS-Router/build cd ~/DDS-Router - wget https://raw.githubusercontent.com/eProsima/DDS-Router/main/ddsrouter.repos + wget https://raw.githubusercontent.com/eProsima/DDS-Router/v3.3.0/ddsrouter.repos vcs import src < ddsrouter.repos #. Compile all dependencies using CMake_. diff --git a/docs/rst/developer_manual/installation/sources/windows.rst b/docs/rst/developer_manual/installation/sources/windows.rst index 984cbe762..55caa749c 100644 --- a/docs/rst/developer_manual/installation/sources/windows.rst +++ b/docs/rst/developer_manual/installation/sources/windows.rst @@ -257,7 +257,7 @@ Colcon installation mkdir \DDS-Router cd \DDS-Router mkdir src - wget https://raw.githubusercontent.com/eProsima/DDS-Router/main/ddsrouter.repos + wget https://raw.githubusercontent.com/eProsima/DDS-Router/v3.3.0/ddsrouter.repos vcs import src --input ddsrouter.repos .. note:: @@ -309,7 +309,7 @@ Local installation mkdir \DDS-Router\src mkdir \DDS-Router\build cd \DDS-Router - wget https://raw.githubusercontent.com/eProsima/DDS-Router/main/ddsrouter.repos + wget https://raw.githubusercontent.com/eProsima/DDS-Router/v3.3.0/ddsrouter.repos vcs import src --input ddsrouter.repos #. Compile all dependencies using CMake_. diff --git a/docs/rst/use_cases/ros_cloud.rst b/docs/rst/use_cases/ros_cloud.rst index cc43663e1..e0eb173e8 100644 --- a/docs/rst/use_cases/ros_cloud.rst +++ b/docs/rst/use_cases/ros_cloud.rst @@ -124,7 +124,7 @@ the previously set up ConfigMap. This Docker image needs to be built and made av |ddsrouter|, which can be accomplished by providing the following :download:`Dockerfile <../../resources/use_cases/ros_cloud/Dockerfile_ddsrouter>`. If willing to see log messages in ``STDOUT``, use :download:`Dockerfile <../../resources/use_cases/ros_cloud/Dockerfile_ddsrouter_logon>` instead. -Assuming the name of the generated Docker image is ``ddsrouter:main``, the cloud router will then be deployed with the +Assuming the name of the generated Docker image is ``ddsrouter:v3.3.0``, the cloud router will then be deployed with the following settings: .. literalinclude:: ../../resources/use_cases/ros_cloud/ddsrouter.yaml