[ros2bag test_record] Gets rid of time.sleep and move to using command.wait_for_output#525
Merged
jaisontj merged 5 commits intoros2:masterfrom Sep 22, 2020
Merged
Conversation
time.sleep in tests Signed-off-by: Jaison Titus <jaisontj@amazon.com>
da88cbb to
1568bb7
Compare
Signed-off-by: Jaison Titus <jaisontj@amazon.com>
to account for cases where wait_for_output is maybe called after the expected output is already printed. Signed-off-by: Jaison Titus <jaisontj@amazon.com>
8ebcb5f to
b15c9fc
Compare
Contributor
Author
|
Each of the tests can also be reduced to: def test_nonexistent_qos_profile(self):
profile_path = PROFILE_PATH / 'foobar.yaml'
output_path = Path(self.tmpdir.name) / 'ros2bag_test_nonexistent'
arguments = ['record', '-a', '--qos-profile-overrides-path', profile_path.as_posix(),
'--output', output_path.as_posix()]
expected_string_regex = re.compile(
r'ros2 bag record: error: argument --qos-profile-overrides-path: can\'t open')
with self.launch_bag_command(arguments=arguments) as bag_command:
condition_result = bag_command.wait_for_output(
condition=lambda output: expected_string_regex.search(output) is not None,
timeout=5)
assert condition_result, print('ros2bag CLI did not produce the expected output')
bag_command.wait_for_shutdown(timeout=5)
assert bag_command.terminated
assert bag_command.exit_code != launch_testing.asserts.EXIT_OKHowever, this can have an edge case where |
dabonnie
suggested changes
Sep 18, 2020
Contributor
dabonnie
left a comment
There was a problem hiding this comment.
Were you able to run the tests repeatedly by any chance?
tests. Signed-off-by: Jaison Titus <jaisontj@amazon.com>
Signed-off-by: Jaison Titus <jaisontj@amazon.com>
Contributor
Author
I've been testing on windows using: |
Contributor
Author
|
Looks like the build failure on |
Contributor
Author
Contributor
Author
Contributor
Author
|
Do note that I was unable to get rid of the |
dabonnie
approved these changes
Sep 21, 2020
jikawa-az
approved these changes
Sep 22, 2020
emersonknapp
pushed a commit
that referenced
this pull request
Feb 2, 2021
…d.wait_for_output (#525) * Uses bag_command.wait_for_output with expected string instead of time.sleep in tests Signed-off-by: Jaison Titus <jaisontj@amazon.com> * Fixes code style errors Signed-off-by: Jaison Titus <jaisontj@amazon.com> * Moves to asserting expected output match outside of the process context to account for cases where wait_for_output is maybe called after the expected output is already printed. Signed-off-by: Jaison Titus <jaisontj@amazon.com> * Defines timeout with variables and better error messages for failed tests. Signed-off-by: Jaison Titus <jaisontj@amazon.com> * Fixes flake8 errors Signed-off-by: Jaison Titus <jaisontj@amazon.com>
emersonknapp
pushed a commit
that referenced
this pull request
Feb 17, 2021
…d.wait_for_output (#525) * Uses bag_command.wait_for_output with expected string instead of time.sleep in tests Signed-off-by: Jaison Titus <jaisontj@amazon.com> * Fixes code style errors Signed-off-by: Jaison Titus <jaisontj@amazon.com> * Moves to asserting expected output match outside of the process context to account for cases where wait_for_output is maybe called after the expected output is already printed. Signed-off-by: Jaison Titus <jaisontj@amazon.com> * Defines timeout with variables and better error messages for failed tests. Signed-off-by: Jaison Titus <jaisontj@amazon.com> * Fixes flake8 errors Signed-off-by: Jaison Titus <jaisontj@amazon.com>
MichaelOrlov
pushed a commit
that referenced
this pull request
May 25, 2023
MichaelOrlov
pushed a commit
that referenced
this pull request
May 25, 2023
MichaelOrlov
pushed a commit
that referenced
this pull request
May 25, 2023
* Fix for CI regression in TestRos2BagRecord - Replace get_actual_qos() to the qos_profile() as it was before #1335 For some reason on Foxy it doesn't work as expected. Probably due to the missing some underlying dependencies in other core packages. Signed-off-by: Michael Orlov <michael.orlov@apex.ai> * Revert "Fix for CI regression in TestRos2BagRecord" This reverts commit f50f46a. Signed-off-by: Michael Orlov <michael.orlov@apex.ai> * Skip test_record_qos_profiles on Windows since they are flaky - test_record_qos_profiles failures is a known issue described in the #454 - To fix those tests need to backport #462, #466, #470, #472, #525 - Skipping them for a while Signed-off-by: Michael Orlov <michael.orlov@apex.ai> --------- Signed-off-by: Michael Orlov <michael.orlov@apex.ai>
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Tries to fix #454
Looks to me that the original problem described at #454 was probably addressed by #466
However, before #466, there was #462 which moved from using different temp directory per test to using one temp directory for all the tests - this PR also introduced the
time.sleepwithin each test and also one within the cleanup block (which deletes the temp directory)In this PR:
time.sleepwithin each tests to usingbag_command.wait_for_outputwhich essentially waits for the given timeout number or seconds for the expected output. This waiting needs to be done one way or another to give the process enough time to execute and print whatever it needs to.test_qos_simpleandtest_incomplete_qos_profilewere only testing if thebag_command.outputwas NOT of the format[ERROR] [ros2bag]. This causes a bug where the test will pass even if bag_command.output is empty ~ which can happen if the process is exited immediately i.e replacetime.sleep(3)with apass