Skip to content

Commit 8cf4749

Browse files
authored
fix(test_ros2cli_daemon): add RMW isolation fixture for zenoh router (#1216)
test_ros2cli_daemon.py spawns a daemon subprocess with no explicit env=, so the daemon inherits os.environ. When running with rmw_zenoh_cpp, the daemon and the test node cannot discover each other without a router. Add an autouse session fixture that calls rmw_test_isolation_start() when available; this starts an in-process router and sets ZENOH_CONFIG_OVERRIDE so the daemon inherits the connection endpoint. Signed-off-by: yuanyuyuan <az6980522@gmail.com>
1 parent e88f0eb commit 8cf4749

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

ros2cli/package.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<exec_depend>rclpy</exec_depend>
2424
<exec_depend>fzf</exec_depend>
2525

26+
<test_depend>rmw_test_fixture_implementation</test_depend>
2627
<test_depend>ament_copyright</test_depend>
2728
<test_depend>ament_flake8</test_depend>
2829
<test_depend>ament_pep257</test_depend>

ros2cli/test/test_ros2cli_daemon.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@
2727
from ros2cli.node.daemon import shutdown_daemon
2828
from ros2cli.node.daemon import spawn_daemon
2929

30+
try:
31+
from rmw_test_fixture_implementation import rmw_test_isolation_start
32+
from rmw_test_fixture_implementation import rmw_test_isolation_stop
33+
_HAS_RMW_ISOLATION = True
34+
except ImportError:
35+
_HAS_RMW_ISOLATION = False
36+
3037
import test_msgs.action
3138
import test_msgs.msg
3239
import test_msgs.srv
@@ -56,6 +63,16 @@
5663
TEST_ACTION_TYPE = 'test_msgs/action/Fibonacci'
5764

5865

66+
@pytest.fixture(autouse=True, scope='session')
67+
def rmw_isolation():
68+
"""Start RMW isolation before spawning the daemon."""
69+
if _HAS_RMW_ISOLATION:
70+
rmw_test_isolation_start()
71+
yield
72+
if _HAS_RMW_ISOLATION:
73+
rmw_test_isolation_stop()
74+
75+
5976
@pytest.fixture(autouse=True, scope='module')
6077
def local_node():
6178
with rclpy.init():

0 commit comments

Comments
 (0)