From 88fc9dc887e11c80804722eebbd234d59e2dc7d8 Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 7 Aug 2023 13:07:47 +0200 Subject: [PATCH 1/4] Refs #19358. Only account for WLP heartbeats and acknacks. Signed-off-by: Miguel Company --- .../common/BlackboxTestsDiscovery.cpp | 52 ++++++++++++++++--- 1 file changed, 44 insertions(+), 8 deletions(-) diff --git a/test/blackbox/common/BlackboxTestsDiscovery.cpp b/test/blackbox/common/BlackboxTestsDiscovery.cpp index 0bec190d67f..54fc1997d92 100644 --- a/test/blackbox/common/BlackboxTestsDiscovery.cpp +++ b/test/blackbox/common/BlackboxTestsDiscovery.cpp @@ -1813,30 +1813,66 @@ TEST(Discovery, RemoteBuiltinEndpointHonoring) uint32_t num_reader_heartbeat = 0; uint32_t num_reader_acknack = 0; - reader_test_transport->drop_heartbeat_messages_filter_ = [&num_reader_heartbeat](CDRMessage_t&) + reader_test_transport->drop_heartbeat_messages_filter_ = [&num_reader_heartbeat](CDRMessage_t& msg) { - num_reader_heartbeat++; + auto old_pos = msg.pos; + msg.pos += 4; + eprosima::fastrtps::rtps::EntityId_t writer_entity_id; + eprosima::fastrtps::rtps::CDRMessage::readEntityId(&msg, &writer_entity_id); + msg.pos = old_pos; + + if (eprosima::fastrtps::rtps::c_EntityId_WriterLiveliness == writer_entity_id) + { + num_reader_heartbeat++; + } return false; }; - reader_test_transport->drop_ack_nack_messages_filter_ = [&num_reader_acknack](CDRMessage_t&) + reader_test_transport->drop_ack_nack_messages_filter_ = [&num_reader_acknack](CDRMessage_t& msg) { - num_reader_acknack++; + auto old_pos = msg.pos; + msg.pos += 4; + eprosima::fastrtps::rtps::EntityId_t writer_entity_id; + eprosima::fastrtps::rtps::CDRMessage::readEntityId(&msg, &writer_entity_id); + msg.pos = old_pos; + + if (eprosima::fastrtps::rtps::c_EntityId_WriterLiveliness == writer_entity_id) + { + num_reader_acknack++; + } return false; }; uint32_t num_writer_heartbeat = 0; uint32_t num_writer_acknack = 0; - writer_test_transport->drop_heartbeat_messages_filter_ = [&num_writer_heartbeat](CDRMessage_t&) + writer_test_transport->drop_heartbeat_messages_filter_ = [&num_writer_heartbeat](CDRMessage_t& msg) { - num_writer_heartbeat++; + auto old_pos = msg.pos; + msg.pos += 4; + eprosima::fastrtps::rtps::EntityId_t writer_entity_id; + eprosima::fastrtps::rtps::CDRMessage::readEntityId(&msg, &writer_entity_id); + msg.pos = old_pos; + + if (eprosima::fastrtps::rtps::c_EntityId_WriterLiveliness == writer_entity_id) + { + num_writer_heartbeat++; + } return false; }; - writer_test_transport->drop_ack_nack_messages_filter_ = [&num_writer_acknack](CDRMessage_t&) + writer_test_transport->drop_ack_nack_messages_filter_ = [&num_writer_acknack](CDRMessage_t& msg) { - num_writer_acknack++; + auto old_pos = msg.pos; + msg.pos += 4; + eprosima::fastrtps::rtps::EntityId_t writer_entity_id; + eprosima::fastrtps::rtps::CDRMessage::readEntityId(&msg, &writer_entity_id); + msg.pos = old_pos; + + if (eprosima::fastrtps::rtps::c_EntityId_WriterLiveliness == writer_entity_id) + { + num_writer_acknack++; + } return false; }; From 828bf155a3bb78764c55796d5f96f9d2fbb33efc Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 7 Aug 2023 13:10:55 +0200 Subject: [PATCH 2/4] Refs #19358. Change test expectations. Signed-off-by: Miguel Company --- test/blackbox/common/BlackboxTestsDiscovery.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/blackbox/common/BlackboxTestsDiscovery.cpp b/test/blackbox/common/BlackboxTestsDiscovery.cpp index 54fc1997d92..317ff799920 100644 --- a/test/blackbox/common/BlackboxTestsDiscovery.cpp +++ b/test/blackbox/common/BlackboxTestsDiscovery.cpp @@ -1892,10 +1892,10 @@ TEST(Discovery, RemoteBuiltinEndpointHonoring) std::this_thread::sleep_for(std::chrono::seconds(5)); - ASSERT_EQ(num_reader_heartbeat, 3u); - ASSERT_EQ(num_reader_acknack, 3u); - ASSERT_EQ(num_writer_heartbeat, 3u); - ASSERT_EQ(num_writer_acknack, 3u); + ASSERT_EQ(num_reader_heartbeat, 0u); + ASSERT_EQ(num_reader_acknack, 0u); + ASSERT_EQ(num_writer_heartbeat, 0u); + ASSERT_EQ(num_writer_acknack, 0u); } //! Regression test for redmine issue 10674 From f206d29ec71c754b61c9fc8049e94d3b57d4254a Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 7 Aug 2023 13:14:57 +0200 Subject: [PATCH 3/4] Refs #19358. Rename counters. Signed-off-by: Miguel Company --- .../common/BlackboxTestsDiscovery.cpp | 32 +++++++++---------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/test/blackbox/common/BlackboxTestsDiscovery.cpp b/test/blackbox/common/BlackboxTestsDiscovery.cpp index 317ff799920..27dbc902d88 100644 --- a/test/blackbox/common/BlackboxTestsDiscovery.cpp +++ b/test/blackbox/common/BlackboxTestsDiscovery.cpp @@ -1810,10 +1810,10 @@ TEST(Discovery, RemoteBuiltinEndpointHonoring) auto reader_test_transport = std::make_shared(); auto writer_test_transport = std::make_shared(); - uint32_t num_reader_heartbeat = 0; - uint32_t num_reader_acknack = 0; + uint32_t num_wlp_reader_heartbeat = 0; + uint32_t num_wlp_reader_acknack = 0; - reader_test_transport->drop_heartbeat_messages_filter_ = [&num_reader_heartbeat](CDRMessage_t& msg) + reader_test_transport->drop_heartbeat_messages_filter_ = [&num_wlp_reader_heartbeat](CDRMessage_t& msg) { auto old_pos = msg.pos; msg.pos += 4; @@ -1823,12 +1823,12 @@ TEST(Discovery, RemoteBuiltinEndpointHonoring) if (eprosima::fastrtps::rtps::c_EntityId_WriterLiveliness == writer_entity_id) { - num_reader_heartbeat++; + num_wlp_reader_heartbeat++; } return false; }; - reader_test_transport->drop_ack_nack_messages_filter_ = [&num_reader_acknack](CDRMessage_t& msg) + reader_test_transport->drop_ack_nack_messages_filter_ = [&num_wlp_reader_acknack](CDRMessage_t& msg) { auto old_pos = msg.pos; msg.pos += 4; @@ -1838,15 +1838,15 @@ TEST(Discovery, RemoteBuiltinEndpointHonoring) if (eprosima::fastrtps::rtps::c_EntityId_WriterLiveliness == writer_entity_id) { - num_reader_acknack++; + num_wlp_reader_acknack++; } return false; }; - uint32_t num_writer_heartbeat = 0; - uint32_t num_writer_acknack = 0; + uint32_t num_wlp_writer_heartbeat = 0; + uint32_t num_wlp_writer_acknack = 0; - writer_test_transport->drop_heartbeat_messages_filter_ = [&num_writer_heartbeat](CDRMessage_t& msg) + writer_test_transport->drop_heartbeat_messages_filter_ = [&num_wlp_writer_heartbeat](CDRMessage_t& msg) { auto old_pos = msg.pos; msg.pos += 4; @@ -1856,12 +1856,12 @@ TEST(Discovery, RemoteBuiltinEndpointHonoring) if (eprosima::fastrtps::rtps::c_EntityId_WriterLiveliness == writer_entity_id) { - num_writer_heartbeat++; + num_wlp_writer_heartbeat++; } return false; }; - writer_test_transport->drop_ack_nack_messages_filter_ = [&num_writer_acknack](CDRMessage_t& msg) + writer_test_transport->drop_ack_nack_messages_filter_ = [&num_wlp_writer_acknack](CDRMessage_t& msg) { auto old_pos = msg.pos; msg.pos += 4; @@ -1871,7 +1871,7 @@ TEST(Discovery, RemoteBuiltinEndpointHonoring) if (eprosima::fastrtps::rtps::c_EntityId_WriterLiveliness == writer_entity_id) { - num_writer_acknack++; + num_wlp_writer_acknack++; } return false; }; @@ -1892,10 +1892,10 @@ TEST(Discovery, RemoteBuiltinEndpointHonoring) std::this_thread::sleep_for(std::chrono::seconds(5)); - ASSERT_EQ(num_reader_heartbeat, 0u); - ASSERT_EQ(num_reader_acknack, 0u); - ASSERT_EQ(num_writer_heartbeat, 0u); - ASSERT_EQ(num_writer_acknack, 0u); + ASSERT_EQ(num_wlp_reader_heartbeat, 0u); + ASSERT_EQ(num_wlp_reader_acknack, 0u); + ASSERT_EQ(num_wlp_writer_heartbeat, 0u); + ASSERT_EQ(num_wlp_writer_acknack, 0u); } //! Regression test for redmine issue 10674 From 3992e66c17e7472bb150d7c18164c7d78951793a Mon Sep 17 00:00:00 2001 From: Miguel Company Date: Mon, 7 Aug 2023 13:16:42 +0200 Subject: [PATCH 4/4] Refs #19358. Whitelist localhost to ensure only the two test participants communicate. Signed-off-by: Miguel Company --- test/blackbox/common/BlackboxTestsDiscovery.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/test/blackbox/common/BlackboxTestsDiscovery.cpp b/test/blackbox/common/BlackboxTestsDiscovery.cpp index 27dbc902d88..69f3f0b14d0 100644 --- a/test/blackbox/common/BlackboxTestsDiscovery.cpp +++ b/test/blackbox/common/BlackboxTestsDiscovery.cpp @@ -1843,6 +1843,8 @@ TEST(Discovery, RemoteBuiltinEndpointHonoring) return false; }; + reader_test_transport->interfaceWhiteList.push_back("127.0.0.1"); + uint32_t num_wlp_writer_heartbeat = 0; uint32_t num_wlp_writer_acknack = 0; @@ -1876,6 +1878,8 @@ TEST(Discovery, RemoteBuiltinEndpointHonoring) return false; }; + writer_test_transport->interfaceWhiteList.push_back("127.0.0.1"); + reader.disable_builtin_transport().add_user_transport_to_pparams(reader_test_transport). use_writer_liveliness_protocol(false); writer.disable_builtin_transport().add_user_transport_to_pparams(writer_test_transport);