forked from ros2/ros1_bridge
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate launch tests to new launch_testing features & API (ros2#179)
* Update after launch_testing features becoming legacy. Signed-off-by: Michel Hidalgo <[email protected]> * Rename launch based tests in preparation for a refactor. Signed-off-by: Michel Hidalgo <[email protected]> * Migrate tests to new launch_testing API. Signed-off-by: Michel Hidalgo <[email protected]> Signed-off-by: Dhananjay Sathe <[email protected]>
- Loading branch information
1 parent
9fc9bf8
commit b3ef823
Showing
5 changed files
with
218 additions
and
203 deletions.
There are no files selected for viewing
This file contains 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 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 was deleted.
Oops, something went wrong.
This file contains 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 |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# Copyright 2016 Open Source Robotics Foundation, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
import unittest | ||
|
||
from launch import LaunchDescription | ||
from launch.actions import ExecuteProcess | ||
from launch.actions import OpaqueFunction | ||
|
||
import launch_testing | ||
|
||
|
||
TEST_BRIDGE_ROS1_ENV = '@TEST_BRIDGE_ROS1_ENV@' | ||
TEST_BRIDGE_ROSCORE = '@TEST_BRIDGE_ROSCORE@' | ||
TEST_BRIDGE_ROS1_CLIENT = '@TEST_BRIDGE_ROS1_CLIENT@' | ||
TEST_BRIDGE_ROS1_SERVER = '@TEST_BRIDGE_ROS1_SERVER@' | ||
TEST_BRIDGE_DYNAMIC_BRIDGE = '@TEST_BRIDGE_DYNAMIC_BRIDGE@' | ||
TEST_BRIDGE_ROS2_CLIENT = '@TEST_BRIDGE_ROS2_CLIENT@' | ||
TEST_BRIDGE_ROS2_SERVER = '@TEST_BRIDGE_ROS2_SERVER@' | ||
|
||
|
||
@launch_testing.parametrize('test_name,server_cmd,client_cmd', [ | ||
('ros1_server_ros2_client_across_dynamic_bridge', | ||
[TEST_BRIDGE_ROS1_ENV, TEST_BRIDGE_ROS1_SERVER], | ||
[TEST_BRIDGE_ROS2_CLIENT]), | ||
('ros2_server_ros1_client_across_dynamic_bridge', | ||
[TEST_BRIDGE_ROS2_SERVER], | ||
[TEST_BRIDGE_ROS1_ENV, TEST_BRIDGE_ROS1_CLIENT]), | ||
]) | ||
def generate_test_description(test_name, server_cmd, client_cmd, ready_fn): | ||
launch_description = LaunchDescription() | ||
|
||
# ROS 1 core | ||
launch_description.add_action(ExecuteProcess( | ||
cmd=[TEST_BRIDGE_ROS1_ENV, TEST_BRIDGE_ROSCORE], | ||
name=test_name + '__roscore', | ||
)) | ||
|
||
# dynamic bridge | ||
rosbridge_process = ExecuteProcess( | ||
cmd=[TEST_BRIDGE_ROS1_ENV, TEST_BRIDGE_DYNAMIC_BRIDGE], | ||
name=test_name + '__dynamic_bridge', | ||
) | ||
launch_description.add_action(rosbridge_process) | ||
|
||
server_process = ExecuteProcess( | ||
cmd=server_cmd, name=test_name + '__server', | ||
) | ||
launch_description.add_action(server_process) | ||
|
||
client_process = ExecuteProcess( | ||
cmd=client_cmd, name=test_name + '__client', | ||
) | ||
launch_description.add_action(client_process) | ||
|
||
launch_description.add_action( | ||
OpaqueFunction(function=lambda context: ready_fn()) | ||
) | ||
return launch_description, locals() | ||
|
||
|
||
class TestServicesAcrossDynamicBridge(unittest.TestCase): | ||
def test_client_process_terminates_after_a_finite_amount_of_time(self, client_process): | ||
"""Test that the client executables terminates after a finite amount of time.""" | ||
self.proc_info.assertWaitForShutdown(process=client_process, timeout=30) | ||
|
||
|
||
@launch_testing.post_shutdown_test() | ||
class TestServicesAcrossDynamicBridgeAfterShutdown(unittest.TestCase): | ||
|
||
def test_processes_finished_gracefully(self, proc_info, rosbridge_process, | ||
server_process, client_process): | ||
"""Test that both executables finished gracefully.""" | ||
launch_testing.asserts.assertExitCodes(proc_info, process=rosbridge_process) | ||
launch_testing.asserts.assertExitCodes(proc_info, process=server_process) | ||
launch_testing.asserts.assertExitCodes(proc_info, process=client_process) |
Oops, something went wrong.