-
Notifications
You must be signed in to change notification settings - Fork 249
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
replace info with launch testing #351
Closed
Closed
Changes from 1 commit
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
711a42e
replace info with launch testing
Karsten1987 524fe77
use regular expression for info
Karsten1987 e9b48ae
fix transport test
Karsten1987 512c6fb
wip play end to end
Karsten1987 9c377a8
add bag file for replay
Karsten1987 46e82ba
regex for finding messages in ros2 topic echo
Karsten1987 2b6dac8
make process variables local
Karsten1987 0974b84
add ros2topic dependency
Karsten1987 0d7f8fc
remove std msgs dependency
Karsten1987 7538525
wip testing record end to end
Karsten1987 88906fb
address review comments
Karsten1987 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 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
Binary file added
BIN
+2.61 KB
rosbag2_tests/test/rosbag2_tests/__pycache__/test_rosbag2_info_end_to_end.cpython-37.pyc
Binary file not shown.
81 changes: 0 additions & 81 deletions
81
rosbag2_tests/test/rosbag2_tests/test_rosbag2_info_end_to_end.cpp
This file was deleted.
Oops, something went wrong.
93 changes: 93 additions & 0 deletions
93
rosbag2_tests/test/rosbag2_tests/test_rosbag2_info_end_to_end.py
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,93 @@ | ||
# Copyright 2020 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 os | ||
import unittest | ||
|
||
import launch | ||
import launch.actions | ||
import launch_testing | ||
import launch_testing.actions | ||
import launch_testing.asserts | ||
import launch_testing.markers | ||
|
||
import pytest | ||
|
||
|
||
# This is necessary to get unbuffered output from the process under test | ||
proc_env = os.environ.copy() | ||
proc_env['PYTHONUNBUFFERED'] = '1' | ||
|
||
rosbag_info_process = launch.actions.ExecuteProcess( | ||
cmd=['ros2', 'bag', 'info', launch.substitutions.LaunchConfiguration('bag_file_path')], | ||
output='screen', env=proc_env, | ||
) | ||
|
||
rosbag_info_process_wrong = launch.actions.ExecuteProcess( | ||
cmd=['ros2', 'bag', 'info', '/path/to/non/existing/bag_file'], | ||
output='screen', env=proc_env, | ||
) | ||
|
||
|
||
@pytest.mark.launch_test | ||
@launch_testing.markers.keep_alive | ||
def generate_test_description(): | ||
return launch.LaunchDescription([ | ||
launch.actions.DeclareLaunchArgument( | ||
'bag_file_path', | ||
description='Absolute path to a bag file.', | ||
default_value='../resources/cdr_test' | ||
), | ||
launch_testing.actions.ReadyToTest(), | ||
]) | ||
|
||
|
||
class TestInfo(unittest.TestCase): | ||
|
||
def test_ros2_bag_info(self, launch_service, proc_info, proc_output): | ||
"""Test terminating_proc without command line arguments.""" | ||
print('Running ros2 bag info') | ||
with launch_testing.tools.launch_process( | ||
launch_service, rosbag_info_process, proc_info, proc_output) as command: | ||
assert command.wait_for_shutdown(timeout=3) | ||
assert command.exit_code == launch_testing.asserts.EXIT_OK | ||
# Using the SequentialStdout context manager asserts that the following stdout | ||
# happened in the same order that it's checked | ||
with launch_testing.asserts.assertSequentialStdout(proc_output, rosbag_info_process) as cm: | ||
cm.assertInStdout('Files: cdr_test.db3') | ||
# cm.assertInStdout('Bag size: .*B') | ||
cm.assertInStdout('Storage id: sqlite3') | ||
cm.assertInStdout('Duration: 0.155s') | ||
# cm.assertInStdout('Start: Sep 18 2018 .*:.*:44.241 (1537282604.241)') | ||
# cm.assertInStdout('End Sep 18 2018 .*:.*:44.397 (1537282604.397)') | ||
Karsten1987 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
cm.assertInStdout('Messages: 7') | ||
cm.assertInStdout( | ||
('Topic information: Topic: /test_topic | Type: test_msgs/BasicTypes ' | ||
'| Count: 3 | Serialization Format: cdr')) | ||
cm.assertInStdout( | ||
('Topic: /array_topic | Type: test_msgs/Arrays ' | ||
'| Count: 4 | Serialization Format: cdr')) | ||
# TODO(Karsten1987): Regex doesn't seem to work. | ||
# launch_testing.asserts.assertInStdout( | ||
# proc_output, 'Files:\s+cdr_test.db3', rosbag_info_process) | ||
Karsten1987 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
def test_ros2_bag_info_fail(self, launch_service, proc_info, proc_output): | ||
"""Test ros2 bag info with a non existing bag file.""" | ||
print('Running ros2 bag info with non existing bag file') | ||
with launch_testing.tools.launch_process( | ||
launch_service, rosbag_info_process_wrong, proc_info, proc_output) as command: | ||
assert command.wait_for_shutdown(timeout=3) | ||
assert command.exit_code == 1 | ||
launch_testing.asserts.assertInStderr( | ||
proc_output, 'does not exist', rosbag_info_process_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.
@Karsten1987 nit: I'd move this statement outside the context manager scope
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.
how do I access the exit code if the
command
is out of scope?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.
command
doesn't leave scope after thewith
statement is over :)