@@ -170,6 +170,101 @@ void test_local_communication_key_dispose(
170170 router.stop ();
171171}
172172
173+
174+ /* *
175+ * Test communication between two DDS Participants hosted in the same device, but which are at different DDS domains.
176+ * This is accomplished by using a DDS Router instance with a Simple Participant deployed at each domain.
177+ *
178+ * The reliable option changes the test behavior to verify that the communication is reliable and all old data is sent
179+ * to Late Joiners.
180+ *
181+ * However, in this test the disposed key messages are sent without payload.
182+ */
183+ void test_local_communication_key_dispose_without_payload (
184+ DdsRouterConfiguration ddsrouter_configuration,
185+ uint32_t samples_to_receive = DEFAULT_SAMPLES_TO_RECEIVE,
186+ uint32_t time_between_samples = DEFAULT_MILLISECONDS_PUBLISH_LOOP,
187+ uint32_t msg_size = DEFAULT_MESSAGE_SIZE)
188+ {
189+ // Check there are no warnings/errors
190+ // TODO: Change threshold to \c Log::Kind::Warning once middleware warnings are solved
191+ // eprosima::ddsrouter::test::TestLogHandler test_log_handler(utils::Log::Kind::Error);
192+ INSTANTIATE_LOG_TESTER (eprosima::utils::Log::Kind::Error, 0 , 0 );
193+
194+ uint32_t samples_sent = 0 ;
195+ std::atomic<uint32_t > samples_received (0 );
196+
197+ // Create a message with size specified by repeating the same string
198+ HelloWorldKeyed msg;
199+ HelloWorldKeyedZeroSizePayloadPubSubType type;
200+
201+ std::string msg_str;
202+
203+ // Add this string as many times as the msg size requires
204+ for (uint32_t i = 0 ; i < msg_size; i++)
205+ {
206+ msg_str += " Testing DdsRouter Blackbox Local Communication ..." ;
207+ }
208+ msg.message (msg_str);
209+ msg.id (666 );
210+
211+ // Create DDS Publisher in domain 0
212+ TestPublisher<HelloWorldKeyed> publisher (type.is_compute_key_provided );
213+
214+ ASSERT_TRUE (publisher.init (0 ));
215+
216+ // Create DDS Subscriber in domain 1
217+ TestSubscriber<HelloWorldKeyed> subscriber (type.is_compute_key_provided );
218+
219+ ASSERT_TRUE (subscriber.init (1 , &msg, &samples_received));
220+
221+ // Create DdsRouter entity
222+ // The DDS Router does not start here in order to test a reliable communication
223+ DdsRouter router (ddsrouter_configuration);
224+
225+ // Start DDS Router
226+ router.start ();
227+
228+ // Start publishing
229+ while (samples_received.load () < samples_to_receive)
230+ {
231+ msg.index (++samples_sent);
232+ ASSERT_EQ (publisher.publish (msg), fastdds::dds::RETCODE_OK) << samples_sent;
233+
234+ // If time is 0 do not wait
235+ if (time_between_samples > 0 )
236+ {
237+ std::this_thread::sleep_for (std::chrono::milliseconds (time_between_samples));
238+ }
239+ }
240+
241+ // All samples received, now dispose key from publisher and check that subscriber has receive it
242+ ASSERT_TRUE (publisher.dispose_key (msg) == fastdds::dds::RETCODE_OK);
243+ std::this_thread::sleep_for (std::chrono::milliseconds (DEFAULT_SUBSCRIBER_MESSAGE_RECEPTION));
244+ samples_received.store (0 );
245+
246+ // Keep publishing
247+ while (samples_received.load () < samples_to_receive)
248+ {
249+ msg.index (++samples_sent);
250+ ASSERT_EQ (publisher.publish (msg), fastdds::dds::RETCODE_OK) << samples_sent;
251+
252+ // If time is 0 do not wait
253+ if (time_between_samples > 0 )
254+ {
255+ std::this_thread::sleep_for (std::chrono::milliseconds (time_between_samples));
256+ }
257+ }
258+
259+ // All samples received, now dispose key from publisher and check that subscriber has receive it
260+ ASSERT_TRUE (publisher.dispose_key (msg) == fastdds::dds::RETCODE_OK);
261+ std::this_thread::sleep_for (std::chrono::milliseconds (DEFAULT_SUBSCRIBER_MESSAGE_RECEPTION));
262+
263+ ASSERT_EQ (2u , subscriber.n_disposed ());
264+
265+ router.stop ();
266+ }
267+
173268} /* namespace test */
174269
175270/* *
@@ -181,6 +276,12 @@ TEST(DDSTestLocalDisposeKey, end_to_end_local_communication_key_dispose)
181276 test::dds_test_simple_configuration ());
182277}
183278
279+ TEST (DDSTestLocalDisposeKey, end_to_end_local_communication_key_dispose_without_payload)
280+ {
281+ test::test_local_communication_key_dispose_without_payload (
282+ test::dds_test_simple_configuration ());
283+ }
284+
184285int main (
185286 int argc,
186287 char ** argv)
0 commit comments