From 022fe15d5153ea87f42206585d251e09d432c849 Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Thu, 4 Sep 2025 17:00:55 +0900 Subject: [PATCH 1/2] Enable RMW isolation for ros2doctor.test_report. Signed-off-by: Tomoya Fujita --- ros2doctor/test/test_report.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ros2doctor/test/test_report.py b/ros2doctor/test/test_report.py index b3e7052db..7cc0f8e98 100644 --- a/ros2doctor/test/test_report.py +++ b/ros2doctor/test/test_report.py @@ -24,6 +24,7 @@ from launch import LaunchDescription from launch import LaunchService from launch.actions import ExecuteProcess +from launch.actions import SetEnvironmentVariable from launch_ros.actions import Node @@ -32,6 +33,7 @@ import launch_testing.asserts import launch_testing.markers import launch_testing.tools +from launch_testing_ros.actions import EnableRmwIsolation import launch_testing_ros.tools import pytest @@ -55,21 +57,22 @@ def generate_test_description(rmw_implementation: str) -> Tuple[LaunchDescriptio path_to_fixtures = os.path.join(os.path.dirname(__file__), 'fixtures') additional_env = get_rmw_additional_env(rmw_implementation) additional_env['PYTHONUNBUFFERED'] = '1' + set_env_actions = [SetEnvironmentVariable(k, v) for k, v in additional_env.items()] return LaunchDescription([ ExecuteProcess( cmd=['ros2', 'daemon', 'stop'], name='daemon-stop', on_exit=[ + *set_env_actions, + EnableRmwIsolation(), ExecuteProcess( cmd=['ros2', 'daemon', 'start'], name='daemon-start', - additional_env=additional_env, on_exit=[ Node( executable=sys.executable, arguments=[os.path.join(path_to_fixtures, 'report_node.py')], - additional_env=additional_env ), launch_testing.actions.ReadyToTest() ] @@ -100,11 +103,8 @@ def launch_doctor_command( self, arguments ) -> Generator[launch_testing.tools.process.ProcessProxy, None, None]: - additional_env = get_rmw_additional_env(rmw_implementation) - additional_env['PYTHONUNBUFFERED'] = '1' doctor_command_action = ExecuteProcess( cmd=['ros2', 'doctor', *arguments], - additional_env=additional_env, name='ros2doctor-cli', output='screen' ) From 3247d58ce31f59de3de84394ddf48d9c17a6bf5a Mon Sep 17 00:00:00 2001 From: Tomoya Fujita Date: Thu, 4 Sep 2025 18:43:12 +0900 Subject: [PATCH 2/2] ResetEnvironment on shutdown is missing. Signed-off-by: Tomoya Fujita --- ros2doctor/test/test_report.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/ros2doctor/test/test_report.py b/ros2doctor/test/test_report.py index 7cc0f8e98..0ff79b3b3 100644 --- a/ros2doctor/test/test_report.py +++ b/ros2doctor/test/test_report.py @@ -24,7 +24,10 @@ from launch import LaunchDescription from launch import LaunchService from launch.actions import ExecuteProcess +from launch.actions import RegisterEventHandler +from launch.actions import ResetEnvironment from launch.actions import SetEnvironmentVariable +from launch.event_handlers import OnShutdown from launch_ros.actions import Node @@ -64,6 +67,7 @@ def generate_test_description(rmw_implementation: str) -> Tuple[LaunchDescriptio cmd=['ros2', 'daemon', 'stop'], name='daemon-stop', on_exit=[ + RegisterEventHandler(OnShutdown(on_shutdown=ResetEnvironment())), *set_env_actions, EnableRmwIsolation(), ExecuteProcess( @@ -130,11 +134,6 @@ def test_check(self) -> None: @launch_testing.markers.retry_on_failure(times=5, delay=1) def test_report(self) -> None: - # TODO(@fujitatomoya): rmw_zenoh_cpp is instable to find the endpoints, it does not - # matter if DaemonNode or DirectNode is used. For now, skip the test for rmw_zenoh_cpp. - if self.rmw_implementation == 'rmw_zenoh_cpp': - raise unittest.SkipTest() - for argument in ['-r', '--report']: with self.launch_doctor_command( arguments=[argument]