Skip to content

Conversation

@mergify
Copy link

@mergify mergify bot commented Nov 19, 2025

I created this pull request as a proof of concept for the new feature discussed here: #348.
The ticket description is still correct and relevant, but for clarity's sake, let me summarize and expand on it here.

Let us assume there is a node ("NODE under test" in the diagram) which:

  • takes a topic A as input
  • does some calculation
  • publishes another topic B as output

At the moment, there is no way to programmatically test the whole node end-to-end. For that, we need a way to:

  1. inject a message of topic A into the node
  2. wait for the calculation to be over
  3. collect the resulting message of topic B coming out of the node

Currently, the WaitForTopics class provided by this package takes care of 2 and 3, but there is no mechanism to reliably accomplish 1, due to the asynchronous nature of ROS2 publishers and subscribers.

This PR is an attempt to enhance the WaitForTopics class so that it can take care of 1 as well, thus closing the loop. But it might well not be the only solution or the most effective. I am open to any kind of suggestion and guidance.

The main issue behind the implementation of such a feature is that in ROS2 the order of creation of publishers and subscribers does matter. They must either always be created in a specific order or be synchronized in some other way.

Below is a cartoon-style diagram illustrating what the end result should look like:

node-test-diagram


This is an automatic backport of pull request #356 done by Mergify.

…d after starting the subscribers (#356)

Signed-off-by: Giorgio Pintaudi <[email protected]>
(cherry picked from commit 1e33f0a)
…lished (#474)

Signed-off-by: Giorgio Pintaudi <[email protected]>
Signed-off-by: Giorgio Pintaudi <[email protected]>
Signed-off-by: Giorgio Pintaudi <[email protected]>

When testing subscribers and  publishers, usually we do not want to miss any message due to race issues or other network instabilities. So we give the option to the user to specify a QoS profile best suited for the test scenario. The default is to set the durability to transient local, so that the publisher do not drop any packages in case of late joining subscribers.
@ahcorde
Copy link
Contributor

ahcorde commented Nov 19, 2025

I cherre-picked the two other related PRs

are there any other related PR @LastStarDust ?

@ahcorde
Copy link
Contributor

ahcorde commented Nov 19, 2025

Pulls: #504
Gist: https://gist.githubusercontent.com/ahcorde/fd061d0130d4b48dd20fb9f439b6b0bb/raw/37bf7680175faa0503a13f906fe6b267fa051973/ros2.repos
BUILD args: --packages-above-and-dependencies launch_testing_ros
TEST args: --packages-above launch_testing_ros
ROS Distro: jazzy
Job: ci_launcher
ci_launcher ran: https://ci.ros2.org/job/ci_launcher/17527

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@ahcorde ahcorde merged commit bc31627 into jazzy Nov 20, 2025
1 of 3 checks passed
@ahcorde ahcorde deleted the mergify/bp/jazzy/pr-356 branch November 20, 2025 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants