-
Notifications
You must be signed in to change notification settings - Fork 190
Fujitatomoya/clearup isolated ros2daemon #1098
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fujitatomoya
merged 8 commits into
rolling
from
fujitatomoya/clearup-isolated-ros2daemon
Sep 4, 2025
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
022fe15
Enable RMW isolation for ros2doctor.test_report.
fujitatomoya 3247d58
ResetEnvironment on shutdown is missing.
fujitatomoya d9a3a50
Clean up isolated ros2 daemon process when tests complete.
fujitatomoya f1ea754
Clean up isolated ros2 daemon process for ros2topic.
fujitatomoya b325b62
Clean up isolated ros2 daemon process for ros2action.
fujitatomoya 5e77650
Clean up isolated ros2 daemon process for ros2doctor.
fujitatomoya 40f5645
Clean up isolated ros2 daemon process for ros2lifecycle and ros2node.
fujitatomoya f63ddcb
Clean up isolated ros2 daemon process for ros2param.
fujitatomoya File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +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 | ||
|
|
||
|
|
@@ -32,6 +36,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 +60,33 @@ 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(), | ||
| RegisterEventHandler(OnShutdown(on_shutdown=[ | ||
| # Stop daemon in isolated environment with proper ROS_DOMAIN_ID | ||
| ExecuteProcess( | ||
| cmd=['ros2', 'daemon', 'stop'], | ||
| name='daemon-stop-isolated', | ||
| # Use the same isolated environment | ||
| additional_env=dict(additional_env), | ||
| ), | ||
| # This must be done after stopping the daemon in the isolated environment | ||
| ResetEnvironment(), | ||
| ])), | ||
| 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 +117,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' | ||
| ) | ||
|
|
@@ -130,11 +144,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() | ||
|
|
||
|
Comment on lines
-133
to
-137
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is another fix to support zenoh here. It now uses rmw isolated environment for the test, that will call rmw_zenoh specific setup for the isolation. |
||
| for argument in ['-r', '--report']: | ||
| with self.launch_doctor_command( | ||
| arguments=[argument] | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the fix to avoid leaving the ros2 daemon processes with different ROS_DOMAIN_ID.
Right after the test, it makes sure clean up the ros2 daemon process in isolated environment, in this way we can only shut down the ros2 daemon instantiated by this isolated environment.
ros2 daemon stopabove can stay there to stop the ros2 daemon with default ROS_DOMAIN_ID if that is online.