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
2 changes: 2 additions & 0 deletions test_launch_ros/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
<test_depend>composition</test_depend>
<test_depend>demo_nodes_py</test_depend>
<test_depend>launch_ros</test_depend>
<test_depend>launch_testing_ros</test_depend>
<test_depend>launch_xml</test_depend>
<test_depend>launch_yaml</test_depend>
<test_depend>lifecycle</test_depend>
Expand All @@ -34,6 +35,7 @@
<test_depend>python3-yaml</test_depend>
<test_depend>rclcpp_components</test_depend>
<test_depend>rclpy</test_depend>
<test_depend>rmw_test_fixture_implementation</test_depend>
<test_depend>rosgraph_msgs</test_depend>

<export>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
from launch_ros.descriptions import ComposableNode
from launch_ros.utilities import get_node_name_count

from launch_testing_ros.actions import EnableRmwIsolation

import osrf_pycommon.process_utils

TEST_CONTAINER_NAME = 'test_component_container_node_name'
Expand All @@ -34,7 +36,7 @@


def _assert_launch_no_errors(actions, *, timeout_sec=5):
ld = LaunchDescription(actions)
ld = LaunchDescription([EnableRmwIsolation(), *actions])
ls = LaunchService(debug=True)
ls.include_launch_description(ld)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
import rclpy.executors
import rclpy.node

from rmw_test_fixture_implementation import RMWTestIsolator

TEST_CONTAINER_NAME = 'mock_component_container'
TEST_NODE_NAME = 'test_load_composable_nodes_node'

Expand Down Expand Up @@ -103,20 +105,21 @@ def _load_composable_node(

@pytest.fixture
def mock_component_container():
context = rclpy.context.Context()
with rclpy.init(context=context):
executor = rclpy.executors.SingleThreadedExecutor(context=context)

container = MockComponentContainer(context)
executor.add_node(container)

# Start spinning in a thread
thread = threading.Thread(target=lambda executor: executor.spin(), args=(executor,))
thread.start()
yield container
executor.remove_node(container)
executor.shutdown()
thread.join()
with RMWTestIsolator():
context = rclpy.context.Context()
with rclpy.init(context=context):
executor = rclpy.executors.SingleThreadedExecutor(context=context)

container = MockComponentContainer(context)
executor.add_node(container)

# Start spinning in a thread
thread = threading.Thread(target=lambda executor: executor.spin(), args=(executor,))
thread.start()
yield container
executor.remove_node(container)
executor.shutdown()
thread.join()


def test_load_node(mock_component_container):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import pytest
import rclpy
from rclpy.clock import Clock, ClockType
from rmw_test_fixture_implementation import RMWTestIsolator
from rosgraph_msgs.msg import Clock as ClockMsg


Expand Down Expand Up @@ -151,7 +152,7 @@ def test_shutdown_preempts_timers():

@pytest.fixture
def rclpy_node():
with rclpy.init():
with RMWTestIsolator(), rclpy.init():
node = rclpy.create_node('test_ros_timer_action_node')
yield node

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@
import io
import textwrap

from launch import LaunchDescription
from launch import LaunchService
from launch.frontend import Parser
from launch.utilities import perform_substitutions
from launch_ros.utilities import evaluate_parameters
from launch_testing_ros.actions import EnableRmwIsolation
import osrf_pycommon.process_utils
import pytest

Expand Down Expand Up @@ -174,6 +176,7 @@ def test_launch_container_executor_modes(file_factory, container_args):
root_entity, parser = Parser.load(f)
ld = parser.parse_description(root_entity)
ls = LaunchService()
ls.include_launch_description(LaunchDescription([EnableRmwIsolation()]))
ls.include_launch_description(ld)

loop = osrf_pycommon.process_utils.get_loop()
Expand All @@ -196,6 +199,7 @@ def check_launch_component_container(file):
root_entity, parser = Parser.load(file)
ld = parser.parse_description(root_entity)
ls = LaunchService()
ls.include_launch_description(LaunchDescription([EnableRmwIsolation()]))
ls.include_launch_description(ld)

loop = osrf_pycommon.process_utils.get_loop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
import pathlib
import textwrap

from launch import LaunchDescription
from launch import LaunchService
from launch.frontend import Parser
from launch.utilities import type_utils
from launch_ros.actions import LifecycleNode
from launch_ros.utilities import evaluate_parameters
from launch_testing_ros.actions import EnableRmwIsolation
import osrf_pycommon.process_utils

yaml_params = str(pathlib.Path(__file__).parent / 'params.yaml')
Expand Down Expand Up @@ -105,6 +107,7 @@ def check_launch_lifecycle_node(file):
root_entity, parser = Parser.load(file)
ld = parser.parse_description(root_entity)
ls = LaunchService()
ls.include_launch_description(LaunchDescription([EnableRmwIsolation()]))
ls.include_launch_description(ld)

loop = osrf_pycommon.process_utils.get_loop()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
from launch_ros.utilities import add_node_name
from launch_ros.utilities import get_node_name_count

from launch_testing_ros.actions import EnableRmwIsolation

import osrf_pycommon.process_utils

TEST_NODE_NAMESPACE = '/my_namespace'
Expand All @@ -46,6 +48,7 @@ def test_node_name_count():
def _launch(launch_description):
loop = osrf_pycommon.process_utils.get_loop()
ls = LaunchService()
ls.include_launch_description(LaunchDescription([EnableRmwIsolation()]))
ls.include_launch_description(launch_description)
launch_task = loop.create_task(ls.run_async())
loop.run_until_complete(asyncio.sleep(5))
Expand Down