-
Notifications
You must be signed in to change notification settings - Fork 237
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
enable/disable rosout logging in each node individually #469
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
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 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,85 @@ | ||
# Copyright 2019 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 pytest | ||
|
||
from rcl_interfaces.msg import Log | ||
import rclpy | ||
from rclpy.executors import SingleThreadedExecutor | ||
|
||
TEST_PARAMETERS = [ | ||
('enable_global_rosout_enable_node_rosout', True, True, True), | ||
('enable_global_rosout_disable_node_rosout', True, False, False), | ||
('disable_global_rosout_enable_node_rosout', False, True, False), | ||
('disable_global_rosout_disable_node_rosout', False, False, False), | ||
] | ||
|
||
raw_subscription_msg = None # None=No result yet | ||
|
||
|
||
def raw_subscription_callback(msg): | ||
global raw_subscription_msg | ||
raw_subscription_msg = msg | ||
|
||
|
||
@pytest.mark.parametrize( | ||
'name,enable_global_rosout_logs,enable_node_rosout,expected_data', | ||
TEST_PARAMETERS) | ||
def test_enable_rosout( | ||
name, | ||
enable_global_rosout_logs, | ||
enable_node_rosout, | ||
expected_data | ||
): | ||
if enable_global_rosout_logs: | ||
args = ['--ros-args', '--enable-rosout-logs'] | ||
else: | ||
args = ['--ros-args', '--disable-rosout-logs'] | ||
|
||
context = rclpy.context.Context() | ||
rclpy.init(context=context, args=args) | ||
executor = SingleThreadedExecutor(context=context) | ||
|
||
# create node | ||
node = rclpy.create_node( | ||
node_name='my_node_'+name, | ||
namespace='/my_ns', | ||
enable_rosout=enable_node_rosout, | ||
context=context | ||
) | ||
executor.add_node(node) | ||
|
||
global raw_subscription_msg | ||
raw_subscription_msg = None | ||
# create subscriber of 'rosout' topic | ||
node.create_subscription( | ||
Log, | ||
'rosout', | ||
raw_subscription_callback, | ||
1, | ||
raw=True | ||
) | ||
|
||
node.get_logger().info('SOMETHING') | ||
executor.spin_once(timeout_sec=1) | ||
|
||
if expected_data: | ||
assert (raw_subscription_msg is not None) | ||
assert (type(raw_subscription_msg) == bytes) | ||
assert (len(raw_subscription_msg) != 0) | ||
else: | ||
assert (raw_subscription_msg is None) | ||
|
||
node.destroy_node() | ||
rclpy.shutdown(context=context) |
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.
@ivanpauno (tagging you because you reviewed it), watch out for things like this. It's really fragile, we're seeing this test fail a lot either due to the timeout before the event or because spinning once does not guarantee that the event you wanted handled was the one that would be handled...
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.
For example: https://ci.ros2.org/job/ci_osx/8540/testReport/rclpy.src.ros2.rclpy.rclpy.test/test_logging_rosout/test_enable_rosout_enable_global_rosout_enable_node_rosout_True_True_True_/
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.
@wjwwood
our bad, sorry about that.
we will submit issue against problem and try to fix it.
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.
Thanks @wjwwood.
I overlooked that when reviewing, but the test is definitely flaky.
I've created an issue #546.
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.
@fujitatomoya if you're not planning to work on a fix in a near future, let me know and I will work on it. Thanks!
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.
@ivanpauno
i think i can work on this early next week, but if you already have idea, you can go ahead.
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.
@wjwwood
Thank you for pointing out my mistake. I will fix it.
@ivanpauno @fujitatomoya
It's my fault. I will fix this problem tomorrow in #546.
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.
No worries, I wasn't trying to call anyone out, just wanted to point it out before I forgot and explain why it is fragile.