@@ -206,6 +206,65 @@ void test_local_communication(
206206 router.stop ();
207207}
208208
209+ template <class MsgStruct , class MsgStructType >
210+ void test_original_writer_forwarding (
211+ DdsRouterConfiguration ddsrouter_configuration)
212+ {
213+ INSTANTIATE_LOG_TESTER (eprosima::utils::Log::Kind::Error, 0 , 0 );
214+
215+ uint32_t samples_sent = 0 ;
216+ std::atomic<uint32_t > samples_received (0 );
217+ std::atomic<uint32_t > samples_to_receive (1 );
218+
219+ MsgStruct sent_msg;
220+ MsgStruct recv_msg;
221+ MsgStructType type;
222+ std::string msg_str;
223+ msg_str += " Testing DdsRouter Blackbox Local Communication ..." ;
224+ sent_msg.message (msg_str);
225+ // Create DDS Publisher in domain 0
226+ TestPublisher<MsgStruct> publisher (type.is_compute_key_provided );
227+
228+ ASSERT_TRUE (publisher.init (0 ));
229+
230+ // Create DDS Subscriber in domain 1
231+ TestSubscriber<MsgStruct> subscriber (type.is_compute_key_provided );
232+ ASSERT_TRUE (subscriber.init (1 , &recv_msg, &samples_received));
233+
234+ // Create DdsRouter entity
235+ DdsRouter router (ddsrouter_configuration);
236+ router.start ();
237+
238+ // CASE 1: Send message without original_writer_param, should be set to writers guid
239+ sent_msg.index (samples_sent);
240+ ASSERT_EQ (publisher.publish (sent_msg), eprosima::fastdds::dds::RETCODE_OK );
241+ // Watiting for the message to be received
242+ while (samples_received.load () < 1 ){};
243+ ASSERT_EQ (subscriber.original_writer_guid (), publisher.original_writer_guid ());
244+
245+ // CASE 2: Send message with original_writer_param set to unknown, should be set to other value
246+ sent_msg.index (samples_sent);
247+ eprosima::fastdds::rtps::WriteParams params;
248+ params.original_writer_guid (eprosima::fastdds::rtps::GUID_t::unknown ());
249+ ASSERT_EQ (publisher.publish_with_params (sent_msg, params), eprosima::fastdds::dds::RETCODE_OK );
250+ // Watiting for the message to be received
251+ while (samples_received.load () < 2 ){};
252+ ASSERT_EQ (subscriber.original_writer_guid (), publisher.original_writer_guid ());
253+
254+ // CASE 3: Send message with original_writer_param set to some value, value must be kept
255+ sent_msg.index (samples_sent);
256+ eprosima::fastdds::rtps::WriteParams params_with_og_writer;
257+ eprosima::fastdds::rtps::GUID_t guid ({}, 0x12345678 );
258+ params_with_og_writer.original_writer_guid (guid);
259+ ASSERT_EQ (publisher.publish_with_params (sent_msg, params_with_og_writer), eprosima::fastdds::dds::RETCODE_OK );
260+ // Watiting for the message to be received
261+ while (samples_received.load () < 2 ){};
262+ ASSERT_EQ (subscriber.original_writer_guid (), guid);
263+
264+ router.stop ();
265+ }
266+
267+
209268} /* namespace test */
210269
211270/* *
@@ -322,6 +381,19 @@ TEST(DDSTestLocal, end_to_end_local_communication_transient_local_disable_dynami
322381 true );
323382}
324383
384+
385+ /* *
386+ * Test original writer forwarding in HelloWorld topic between two DDS participants created in different domains,
387+ * by using a router with two Simple Participants at each domain.
388+ */
389+ TEST (DDSTestLocal, end_to_end_local_communication_original_writer_forwarding)
390+ {
391+ test::test_original_writer_forwarding<HelloWorld, HelloWorldPubSubType>(
392+ test::dds_test_simple_configuration ());
393+ }
394+
395+
396+
325397int main (
326398 int argc,
327399 char ** argv)
0 commit comments