-
Notifications
You must be signed in to change notification settings - Fork 138
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
Add timeout for ReadyToTest action #622
Closed
deepanshubansal01
wants to merge
9
commits into
rolling
from
deepanshu/ReadyToTest-action-timeout-config
Closed
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
af24670
add timeout arg for ReadyToTest action
deepanshubansal01 69964b7
minor change
deepanshubansal01 e18f483
new line
deepanshubansal01 88b3ea5
revert styling
deepanshubansal01 77eb548
whitespace
deepanshubansal01 5af2a80
timeout description
deepanshubansal01 ea1f161
unit test
deepanshubansal01 af832ef
try running CI with pytest
deepanshubansal01 3de1312
try running CI
deepanshubansal01 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
29 changes: 29 additions & 0 deletions
29
launch_testing/test/launch_testing/examples/ready_action_timeout_launch_test.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,29 @@ | ||
# Copyright 2022 Apex.AI, 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 launch | ||
import launch_testing | ||
from launch.actions import TimerAction | ||
from launch_testing.actions import ReadyToTest | ||
|
||
import pytest | ||
|
||
|
||
@pytest.mark.launch_test | ||
def generate_test_description(): | ||
# takes 5 sec for the TimerAction process to start | ||
return launch.LaunchDescription([ | ||
launch_testing.util.KeepAliveProc(), | ||
TimerAction(period=5.0, actions=[ReadyToTest()]), | ||
]) |
70 changes: 70 additions & 0 deletions
70
launch_testing/test/launch_testing/test_ready_action_timeout.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,70 @@ | ||
# Copyright 2022 Apex.AI, 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 subprocess | ||
|
||
import ament_index_python | ||
|
||
|
||
def test_ready_action_within_timeout_duration(): | ||
testpath = os.path.join( | ||
ament_index_python.get_package_share_directory('launch_testing'), | ||
'examples', | ||
'ready_action_timeout_launch_test.py', | ||
) | ||
|
||
# the process takes 5sec to start which is within the | ||
# timeout duration of 20sec specified by ReadyToTest action. | ||
completed_process = subprocess.run( | ||
args=[ | ||
'launch_test', | ||
'--timeout', | ||
'20.0', | ||
testpath | ||
], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
|
||
# success | ||
assert 0 == completed_process.returncode | ||
|
||
|
||
# the process takes longer time to startup than the one | ||
# specified by ReadyToTest action timeout duration. | ||
def test_ready_action_exceed_timeout_duration(): | ||
testpath = os.path.join( | ||
ament_index_python.get_package_share_directory('launch_testing'), | ||
'examples', | ||
'ready_action_timeout_launch_test.py', | ||
) | ||
|
||
# the process takes around 5 sec to start which exceeds the | ||
# 2 sec timeout duration specified by ReadyToTest action. | ||
completed_process = subprocess.run( | ||
args=[ | ||
'launch_test', | ||
'--timeout', | ||
'2.0', | ||
testpath | ||
], | ||
stdout=subprocess.PIPE, | ||
stderr=subprocess.PIPE, | ||
) | ||
|
||
# fail | ||
assert 1 == completed_process.returncode | ||
assert 'Timed out waiting for processes to start up' in \ | ||
completed_process.stdout.decode() |
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.
nit (in this way, the diff will not show one deleted line next time):
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!