← Back to Pull requests

Add TypeObject V2 tests to Connext RMW, fix initialization of Connext type plugins #253

Merged
oliviadorenczrti merged 5 files (627 lines) on Sep 08, 2026 09:06 UTC
View on GitHub
oliviadorenczrti oliviadorenczrti commented on Sep 02, 2026 20:46 UTC
Author

Description

Adds tests to test send/receive using TypeObject V2 between Connext participant and ROS participants.

Fix initialization issue where isRecursiveType was never set in the type plugin, causing undefined behavior when using TypeObject V2.

Is this user-facing behavior change?

No

Did you use Generative AI?

Yes: GitHub Copilot + Opus 4.6

Additional Information

Diff: 627 lines (+615 / -12) across 5 files Reviewer: fgallegosalido Review duration: 7939m
All Vouch review confidence checks passed
Residual risk 0.15 = Change Risk (0.52) × (1 − Review Confidence (0.71)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 627 lines diff across 5 files
0.52
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.45 · 5 substantive comment(s)
0.45
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
70%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.385
Ai Authored ai_authored
0.050
Real PR Conversation Timeline
19 items
oliviadorenczrti oliviadorenczrti commented on Sep 02, 2026 20:47 UTC
Author

@fujitatomoya can you launch a validation for these changes?

fgallegosalido fgallegosalido commented on code on Sep 03, 2026 10:03 UTC
Code Review
rmw_connextdds/test/test_keyed_topics.cpp:1
@@ -292,12 +293,10 @@ TYPED_TEST(TestKeyedTopics, test_keyhash)
   ASSERT_TRUE(
     rmw_connextdds::test::wait_for(
       [&] {
-        auto sample_data = dds::core::xtypes::DynamicData(*publication_listener->get_type());
-        auto sample_info = dds::sub::SampleInfo();
-        while (reader.extensions().take(sample_data, sample_info)) {
-          if (sample_info.valid()) {
-            dds_received_messages_from_ros.first.push_back(sample_info.instance_handle());
-            dds_received_messages_from_ros.second.push_back(sample_data);
+        for (const auto & sample : reader.take()) {

Undo this change as in 998325f39a62dccdc0722968b3711748765c659c. Otherwise we break Windows.

fgallegosalido fgallegosalido commented on code on Sep 03, 2026 10:04 UTC
Code Review
rmw_connextdds/test/test_keyed_topics.cpp:1
@@ -322,12 +321,10 @@ TYPED_TEST(TestKeyedTopics, test_keyhash)
   ASSERT_TRUE(
     rmw_connextdds::test::wait_for(
       [&] {
-        auto sample_data = dds::core::xtypes::DynamicData(*publication_listener->get_type());
-        auto sample_info = dds::sub::SampleInfo();
-        while (reader.extensions().take(sample_data, sample_info)) {
-          if (sample_info.valid()) {
-            dds_received_messages_from_dds.first.push_back(sample_info.instance_handle());
-            dds_received_messages_from_dds.second.push_back(sample_data);
+        for (const auto & sample : reader.take()) {
fgallegosalido fgallegosalido commented on code on Sep 03, 2026 10:30 UTC
Code Review
rmw_connextdds/test/test_utils.hpp:1
@@ -72,18 +90,48 @@ class ROSTypeFinderListener
 
       type_ = sample_data.extensions().type().value();
       reader.set_listener(nullptr);
-      break;

This is needed to early break once we find the type.

fgallegosalido fgallegosalido commented on code on Sep 03, 2026 10:31 UTC
Code Review
rmw_connextdds/test/test_utils.hpp:1
@@ -47,20 +49,36 @@ bool wait_for(
   return false;
 }
 
+template<typename BuiltinTopicData>
 class ROSTypeFinderListener
-  : public dds::sub::NoOpDataReaderListener<
-    dds::topic::PublicationBuiltinTopicData>
+  : public dds::sub::NoOpDataReaderListener<BuiltinTopicData>
 {
 public:
   explicit ROSTypeFinderListener(const std::string & topic_name)
   : topic_name_(topic_name) {}
 
-  // This gets called when a subscriber has been discovered
   void on_data_available(
-    dds::sub::DataReader<dds::topic::PublicationBuiltinTopicData> & reader) override
+    dds::sub::DataReader<BuiltinTopicData> & reader) override
+  {
+    std::scoped_lock lock(mutex_);
+    if (type_) {

As we are removing the listener from the reader (reader.set_listener(nullptr);) once the type is found, we don't really need to check this anymore. It doesn't do any harm, but just to keep it in mind.

fgallegosalido fgallegosalido commented on code on Sep 03, 2026 13:41 UTC
Code Review
rmw_connextdds/test/test_typeobject_v2.cpp:1
@@ -0,0 +1,535 @@
+// Copyright 2026 Real-Time Innovations, Inc. (RTI)
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+// Test TypeObject V2 type compatibility between evolved types.
+//
+// Each test runs independently with fresh participants to avoid TypeObject caching.
+// The four combinations test RMW and Connext endpoints:
+// - "RMW" endpoint: created via rmw_create_publisher/rmw_create_subscription
+// - "Connext" endpoint: DDS entity on a standalone participant with an evolved type
+//
+// The Connext side discovers the RMW type via built-in topics, then builds
+// a superset or subset dynamic type to test TypeObject V2 assignability.
+
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+#include <vector>
+
+#include "test_utils.hpp"
+
+#include "gtest/gtest.h"
+
+#include "osrf_testing_tools_cpp/scope_exit.hpp"
+
+#include "test_msgs/msg/keyed_long.hpp"
+
+#include "rosidl_typesupport_cpp/message_type_support.hpp"
+
+#include "rmw/rmw.h"
+#include "rmw/error_handling.h"
+
+#include "rcutils/allocator.h"
+#include "rcutils/strdup.h"
+
+#include <dds/core/xtypes/DynamicData.hpp>
+#include <dds/dds.hpp>
+#include <rti/rti.hpp>
+
+namespace
+{
+
+constexpr auto ros_node_name = "test_node";
+constexpr auto ros_node_namespace = "/test_namespace";
+constexpr auto ros_topic_name = "/test_typeobject_v2";
+constexpr auto connext_topic_name = "rt/test_typeobject_v2";
+constexpr auto num_samples = std::size_t{3};
+
+// Reader type: struct A { long x; } with mutable extensibility (for pure DDS test)
+dds::core::xtypes::StructType make_reader_type()
+{
+  auto type = dds::core::xtypes::StructType("A");
+  type.extensibility_kind(dds::core::xtypes::ExtensibilityKind::MUTABLE);
+  type.add_member(dds::core::xtypes::Member("x", dds::core::xtypes::primitive_type<int32_t>()));
+  return type;
+}
+
+// Writer type: struct A { long x; long y; } with mutable extensibility (for pure DDS test)
+dds::core::xtypes::StructType make_writer_type()
+{
+  auto type = dds::core::xtypes::StructType("A");
+  type.extensibility_kind(dds::core::xtypes::ExtensibilityKind::MUTABLE);
+  type.add_member(dds::core::xtypes::Member("x", dds::core::xtypes::primitive_type<int32_t>()));
+  type.add_member(dds::core::xtypes::Member("y", dds::core::xtypes::primitive_type<int32_t>()));
+  return type;
+}
+
+// Build a superset type from the discovered type by appending an extra int32 field
+dds::core::xtypes::StructType make_superset_type(
+  const dds::core::xtypes::StructType & base)
+{
+  auto type = dds::core::xtypes::StructType(base.name());
+  type.extensibility_kind(base.extensibility_kind());
+  for (uint32_t i = 0; i < base.member_count(); ++i) {
+    type.add_member(base.member(i));
+  }
+  type.add_member(
+    dds::core::xtypes::Member("extra_field", dds::core::xtypes::primitive_type<int32_t>()));
+  return type;
+}
+
+// Build a subset type from the discovered type by keeping only the first field
+dds::core::xtypes::StructType make_subset_type(
+  const dds::core::xtypes::StructType & base)
+{
+  auto type = dds::core::xtypes::StructType(base.name());
+  type.extensibility_kind(base.extensibility_kind());
+  type.add_member(base.member(0));
+  return type;
+}
+
+}  // namespace
+
+// Each test gets a fresh RMW context (and thus a fresh DDS participant) to avoid
+// TypeObject state caching between tests.
+class TypeObjectV2Test : public ::testing::Test
+{
+protected:
+  void SetUp() override
+  {
+    // Use the "never" participant QoS override policy so the RMW does not force
+    // TypeObject V1 length or channel restrictions. Use NDDS_QOS_PROFILES to
+    // explicitly enable TypeObject V2: LENGTH_AUTO for
+    // type_object_max_serialized_length and the TypeLookup Service builtin channel
+    // for enabled_builtin_channels.
+    setenv("RMW_CONNEXT_PARTICIPANT_QOS_OVERRIDE_POLICY", "never", 1);

Use rcutils_set_env instead for both setting and unsetting environmetn variables. Apply in other places.

fgallegosalido fgallegosalido requested changes on Sep 03, 2026 13:43 UTC
Changes Requested Reviewer

Requested changes.

oliviadorenczrti oliviadorenczrti commented on code on Sep 03, 2026 20:49 UTC
Code Review
rmw_connextdds/test/test_utils.hpp:1
@@ -47,20 +49,36 @@ bool wait_for(
   return false;
 }
 
+template<typename BuiltinTopicData>
 class ROSTypeFinderListener
-  : public dds::sub::NoOpDataReaderListener<
-    dds::topic::PublicationBuiltinTopicData>
+  : public dds::sub::NoOpDataReaderListener<BuiltinTopicData>
 {
 public:
   explicit ROSTypeFinderListener(const std::string & topic_name)
   : topic_name_(topic_name) {}
 
-  // This gets called when a subscriber has been discovered
   void on_data_available(
-    dds::sub::DataReader<dds::topic::PublicationBuiltinTopicData> & reader) override
+    dds::sub::DataReader<BuiltinTopicData> & reader) override
+  {
+    std::scoped_lock lock(mutex_);
+    if (type_) {

Fair, I will leave it in case we change this logic in the future

fgallegosalido fgallegosalido approved these changes on Sep 04, 2026 08:18 UTC
Approved Reviewer

Approved these changes.

ahcorde ahcorde commented on Sep 04, 2026 10:20 UTC
Contributor

Pulls: ros2/rmw_connextdds#253
Gist: https://gist.githubusercontent.com/ahcorde/3e30a6c68e43741b19c1a6cb86cb1cb8/raw/dcf90e31c99a028310855889ec9250465d82c4a3/ros2.repos
BUILD args: --packages-above-and-dependencies rmw_connextdds rmw_connextdds_common
TEST args: --packages-above rmw_connextdds rmw_connextdds_common
ROS Distro: rolling
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/20333
Linux ![Build Status](http://ci.ros2.org/job/ci_linux/30428/)
Linux-aarch64 ![Build Status](http://ci.ros2.org/job/ci_linux-aarch64/23125/)
Linux-rhel ![Build Status](http://ci.ros2.org/job/ci_linux-rhel/10229/)
Windows ![Build Status](http://ci.ros2.org/job/ci_windows/29305/)

fujitatomoya fujitatomoya approved these changes on Sep 05, 2026 00:52 UTC
Approved Reviewer

lgtm with green CI.

fgallegosalido fgallegosalido commented on Sep 07, 2026 14:25 UTC
Contributor

@ahcorde I added the fix for the formatting, which should not affect the new CI build

fgallegosalido fgallegosalido commented on Sep 08, 2026 08:48 UTC
Contributor

@ahcorde the test failures don't seem related to the Connext RMW. Also, I fixed the formatting issue and checked locally it is correct. I think we can merge this.

ahcorde ahcorde approved these changes on Sep 08, 2026 09:05 UTC
Approved Reviewer

Approved these changes.

ahcorde ahcorde commented on Sep 08, 2026 09:06 UTC
Contributor

should we backport this one ?

fgallegosalido fgallegosalido commented on Sep 08, 2026 09:56 UTC
Contributor

Not really, as we would also have to backport https://github.com/ros2/rmw_connextdds/pull/247, and it is not necessary.

Assignees
oliviadorenczrti oliviadorenczrti
Labels
risk: low confidence: 70.8% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 52.4% (MEDIUM) · Higher = larger blast radius
52.4%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 70.8% · Lower = rushed or shallow review
70.8%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 15.3% · Safe to merge
15.3%