Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions ros2action/test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@

from launch import LaunchDescription
from launch.actions import ExecuteProcess
from launch.actions import SetEnvironmentVariable

import launch_testing
import launch_testing.actions
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
Expand All @@ -51,23 +53,35 @@ def generate_test_description(rmw_implementation):
os.path.dirname(__file__), 'fixtures', 'fibonacci_action_server.py'
)
additional_env = get_rmw_additional_env(rmw_implementation)
set_env_actions = [SetEnvironmentVariable(k, v) for k, v in additional_env.items()]
return LaunchDescription([
# Always restart daemon to isolate tests.
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',
on_exit=[
ExecuteProcess(
cmd=[sys.executable, path_to_action_server_executable],
additional_env=additional_env,
),
launch_testing.actions.ReadyToTest()
],
additional_env=additional_env,
)
]
),
Expand Down Expand Up @@ -115,8 +129,9 @@ def setUpClass(
):
@contextlib.contextmanager
def launch_action_command(self, arguments):
additional_env = get_rmw_additional_env(rmw_implementation)
additional_env['PYTHONUNBUFFERED'] = '1'
additional_env = {
'PYTHONUNBUFFERED': '1',
}

action_command_action = ExecuteProcess(
cmd=['ros2', 'action', *arguments],
Expand Down
23 changes: 19 additions & 4 deletions ros2action/test/test_echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@

from launch import LaunchDescription
from launch.actions import ExecuteProcess
from launch.actions import SetEnvironmentVariable

import launch_testing
import launch_testing.actions
import launch_testing.asserts
import launch_testing.markers
import launch_testing.tools

from launch_testing_ros.actions import EnableRmwIsolation
import launch_testing_ros.tools

from osrf_pycommon.terminal_color import remove_ansi_escape_sequences
Expand Down Expand Up @@ -221,23 +223,35 @@ def generate_test_description(rmw_implementation):
os.path.dirname(__file__), 'fixtures', 'fibonacci_action_introspection.py'
)
additional_env = get_rmw_additional_env(rmw_implementation)
set_env_actions = [SetEnvironmentVariable(k, v) for k, v in additional_env.items()]
return LaunchDescription([
# Always restart daemon to isolate tests.
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',
on_exit=[
ExecuteProcess(
cmd=[sys.executable, path_to_action_server_executable],
additional_env=additional_env
),
launch_testing.actions.ReadyToTest()
],
additional_env=additional_env
)
]
),
Expand All @@ -256,8 +270,9 @@ def setUpClass(
):
@contextlib.contextmanager
def launch_action_command(self, arguments):
additional_env = get_rmw_additional_env(rmw_implementation)
additional_env['PYTHONUNBUFFERED'] = '1'
additional_env = {
'PYTHONUNBUFFERED': '1',
}
action_command_action = ExecuteProcess(
cmd=['ros2', 'action', *arguments],
name='ros2action-cli', output='screen',
Expand Down
2 changes: 0 additions & 2 deletions ros2cli/ros2cli/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,6 @@ def get_rmw_additional_env(rmw_implementation: str) -> Dict[str, str]:
if rmw_implementation == 'rmw_zenoh_cpp':
return {
'RMW_IMPLEMENTATION': rmw_implementation,
'ZENOH_ROUTER_CHECK_ATTEMPTS': '-1',
'ZENOH_CONFIG_OVERRIDE': 'scouting/multicast/enabled=true',
'RUST_LOG': 'z=error'
}
else:
Expand Down
24 changes: 16 additions & 8 deletions ros2doctor/test/test_qos_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

from launch import LaunchDescription
from launch.actions import ExecuteProcess
from launch.actions import SetEnvironmentVariable

from launch_ros.actions import Node

Expand All @@ -27,6 +28,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
Expand All @@ -49,6 +51,7 @@ def generate_test_description(rmw_implementation):
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()]

path_to_incompatible_talker_node_script = os.path.join(
path_to_fixtures, 'talker_node_with_best_effort_qos.py')
Expand All @@ -62,25 +65,21 @@ def generate_test_description(rmw_implementation):
executable=sys.executable,
arguments=[path_to_compatible_talker_node_script],
remappings=[('chatter', 'compatible_chatter')],
additional_env=additional_env
)
listener_node_compatible = Node(
executable=sys.executable,
arguments=[path_to_listener_node_script],
remappings=[('chatter', 'compatible_chatter')],
additional_env=additional_env
)
talker_node_incompatible = Node(
executable=sys.executable,
arguments=[path_to_incompatible_talker_node_script],
remappings=[('chatter', 'incompatible_chatter')],
additional_env=additional_env
)
listener_node_incompatible = Node(
executable=sys.executable,
arguments=[path_to_listener_node_script],
remappings=[('chatter', 'incompatible_chatter')],
additional_env=additional_env
)

return LaunchDescription([
Expand All @@ -89,6 +88,19 @@ def generate_test_description(rmw_implementation):
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',
Expand All @@ -100,7 +112,6 @@ def generate_test_description(rmw_implementation):
listener_node_compatible,
launch_testing.actions.ReadyToTest()
],
additional_env=additional_env
)
]
),
Expand Down Expand Up @@ -128,11 +139,8 @@ def setUpClass(

@contextlib.contextmanager
def launch_doctor_command(self, arguments):
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'
)
Expand Down
24 changes: 19 additions & 5 deletions ros2lifecycle/test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@

from launch import LaunchDescription
from launch.actions import ExecuteProcess
from launch.actions import SetEnvironmentVariable
from launch_ros.actions import Node

import launch_testing
import launch_testing.actions
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
Expand Down Expand Up @@ -124,12 +126,26 @@
@launch_testing.parametrize('rmw_implementation', get_available_rmw_implementations())
def generate_test_description(rmw_implementation):
additional_env = get_rmw_additional_env(rmw_implementation)
set_env_actions = [SetEnvironmentVariable(k, v) for k, v in additional_env.items()]
return LaunchDescription([
# Always restart daemon to isolate tests.
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',
Expand All @@ -140,18 +156,15 @@ def generate_test_description(rmw_implementation):
executable='simple_lifecycle_node',
name='test_lifecycle_node',
output='screen',
additional_env=additional_env
),
Node(
package='ros2lifecycle_test_fixtures',
executable='simple_lifecycle_node',
name='_hidden_test_lifecycle_node',
output='screen',
additional_env=additional_env
),
launch_testing.actions.ReadyToTest()
],
additional_env=additional_env
)
]
),
Expand All @@ -170,8 +183,9 @@ def setUpClass(
):
@contextlib.contextmanager
def launch_lifecycle_command(self, arguments):
additional_env = get_rmw_additional_env(rmw_implementation)
additional_env['PYTHONUNBUFFERED'] = '1'
additional_env = {
'PYTHONUNBUFFERED': '1',
}
lifecycle_command_action = ExecuteProcess(
cmd=['ros2', 'lifecycle', *arguments],
additional_env=additional_env,
Expand Down
24 changes: 19 additions & 5 deletions ros2node/test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

from launch import LaunchDescription
from launch.actions import ExecuteProcess
from launch.actions import SetEnvironmentVariable

from launch_ros.actions import Node

Expand All @@ -29,6 +30,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
Expand All @@ -52,12 +54,26 @@ def generate_test_description(rmw_implementation):
os.path.dirname(__file__), 'fixtures', 'complex_node.py'
)
additional_env = get_rmw_additional_env(rmw_implementation)
set_env_actions = [SetEnvironmentVariable(k, v) for k, v in additional_env.items()]
return LaunchDescription([
# Always restart daemon to isolate tests.
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',
Expand All @@ -67,17 +83,14 @@ def generate_test_description(rmw_implementation):
executable=sys.executable,
arguments=[path_to_complex_node_script],
name='complex_node',
additional_env=additional_env
),
Node(
executable=sys.executable,
arguments=[path_to_complex_node_script],
name='_hidden_complex_node',
additional_env=additional_env
),
launch_testing.actions.ReadyToTest()
],
additional_env=additional_env
)
]
),
Expand All @@ -96,8 +109,9 @@ def setUpClass(
):
@contextlib.contextmanager
def launch_node_command(self, arguments):
additional_env = get_rmw_additional_env(rmw_implementation)
additional_env['PYTHONUNBUFFERED'] = '1'
additional_env = {
'PYTHONUNBUFFERED': '1',
}

node_command_action = ExecuteProcess(
cmd=['ros2', 'node', *arguments],
Expand Down
Loading