@@ -206,6 +206,71 @@ void test_local_communication(
206206 router.stop ();
207207}
208208
209+
210+ template <class MsgStruct , class MsgStructType >
211+ void test_original_writer_forwarding (
212+ DdsRouterConfiguration ddsrouter_configuration)
213+ {
214+ INSTANTIATE_LOG_TESTER (eprosima::utils::Log::Kind::Error, 0 , 0 );
215+
216+ uint32_t samples_sent = 0 ;
217+ std::atomic<uint32_t > samples_received (0 );
218+ std::atomic<uint32_t > samples_to_receive (1 );
219+
220+ MsgStruct sent_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 , true );
232+ ASSERT_TRUE (subscriber.init (1 , &sent_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+ {
244+ }
245+ ASSERT_EQ (subscriber.original_writer_guid (), publisher.original_writer_guid ());
246+
247+ // CASE 2: Send message with original_writer_param set to unknown, should be set to other value
248+ sent_msg.index (++samples_sent);
249+ eprosima::fastdds::rtps::WriteParams params;
250+ params.original_writer_info (eprosima::fastdds::rtps::OriginalWriterInfo::unknown ());
251+ ASSERT_EQ (publisher.publish_with_params (sent_msg, params), eprosima::fastdds::dds::RETCODE_OK );
252+ // Waiting for the message to be received
253+ while (samples_received.load () < 2 )
254+ {
255+ }
256+ ASSERT_EQ (subscriber.original_writer_guid (), publisher.original_writer_guid ());
257+
258+ // CASE 3: Send message with original_writer_param set to some value, value must be kept
259+ sent_msg.index (++samples_sent);
260+ eprosima::fastdds::rtps::WriteParams params_with_og_writer;
261+ eprosima::fastdds::rtps::GUID_t guid ({}, 0x12345678 );
262+ params_with_og_writer.original_writer_info ().original_writer_guid (guid);
263+ ASSERT_EQ (publisher.publish_with_params (sent_msg, params_with_og_writer), eprosima::fastdds::dds::RETCODE_OK );
264+ // Waiting for the message to be received
265+ while (samples_received.load () < 3 )
266+ {
267+ }
268+ ASSERT_EQ (subscriber.original_writer_guid (), guid);
269+
270+
271+ router.stop ();
272+ }
273+
209274} /* namespace test */
210275
211276/* *
@@ -322,6 +387,16 @@ TEST(DDSTestLocal, end_to_end_local_communication_transient_local_disable_dynami
322387 true );
323388}
324389
390+ /* *
391+ * Test original writer forwarding in HelloWorld topic between two DDS participants created in different domains,
392+ * by using a router with two Simple Participants at each domain.
393+ */
394+ TEST (DDSTestLocal, end_to_end_local_communication_original_writer_forwarding)
395+ {
396+ test::test_original_writer_forwarding<HelloWorld, HelloWorldPubSubType>(
397+ test::dds_test_simple_configuration ());
398+ }
399+
325400int main (
326401 int argc,
327402 char ** argv)
0 commit comments