-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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 tutorial on integration testing #4881
Add tutorial on integration testing #4881
Conversation
Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
This pull request has been mentioned on ROS Discourse. There might be relevant details there: https://discourse.ros.org/t/towards-a-rosdoc-integation-testing-tutorial/40701/2 |
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.
First of all, thank you for the tutorial. This is documentation we really need.
I've left quite a number of comments inline. Please take a look when you get a chance.
* Extend the two basic active tests with one that checks | ||
whether the turtle is responsive to twist commands, | ||
and another that verifies whether the spawn service | ||
sets the turtle to the intended pose | ||
(see the `Turtlesim introduction tutorial <../../Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim>`). | ||
* Instead of Turtlesim, launch the | ||
:doc:`Gazebo simulator <../../Advanced/Simulators/Gazebo/Gazebo>` | ||
and simulate *your* robot in there, automating tests | ||
that would otherwise depend on manually operating your physical robot. | ||
* Go through the | ||
`launch_testing documentation <https://docs.ros.org/en/{DISTRO}/p/launch_testing/index.html>`_ | ||
and explore the many possibilities for integration testing it offers. |
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.
This is basically "homework", and while I don't necessarily disagree with it, this isn't what we do in our other tutorials. I would suggest just removing this for now.
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.
Ah, I see. The 'Next steps' sections in other tutorials point explicitly to other tutorials, while this is indeed more "homework". Removed in 07e9415.
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.
Nice to see this tutorial written up. How do you deal with the DDS matching of topics taking longer than expected and causing test failures?
|
||
def test_publishes_pose(self, proc_output): | ||
"""Check whether pose messages published""" | ||
msgs_rx = [] |
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.
This pattern is what WaitForTopics attempts to help simplify.
ros2/launch_ros#348
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 for pointing this out, I'll look into that.
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.
Mentioned the launch_testing_ros
package and WaitForTopics
in c28db38.
Great initiative! Is there any reason you chose the In my experience the The README there even suggests it's superior to launch_testing is an standalone testing tool, which lacks many features: So if we're going to write an intetgration testing tutorial, I'd start off by recommending the recommended tool 🙂 |
While I agree with you that it would be nice to also have documentation on the |
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.
I don't have much to add here that @clalancette hasn't already said. There is some inconsistency with the capitalization of turtlesim
that needs to be resolved. Assuming the suggestions are merged, and the latter section on color rendering gets broken out to another tutorial (this could be a subsequent pull request), this is good enough to be merged.
A suitable tool to visualize them all together is the | ||
`NodeJS package Xunit Viewer <https://github.com/lukejpreston/xunit-viewer>`_. | ||
It converts the XUnit files to HTML or straight into the terminal. | ||
For example, command and response (without highlighting): | ||
|
||
.. code-block:: console | ||
|
||
$ xunit-viewer -r build/app/test_results -c | ||
app.test_integration.launch_tests | ||
✗ test_publishes_pose time=0.52 | ||
- Traceback (most recent call last): | ||
File "/home/user/ros_workspace/src/app/test/test_integration.py", line 67, in test_publishes_pose | ||
assert len(msgs_rx) > 100 | ||
^^^^^^^^^^^^^^^^^^ | ||
AssertionError | ||
✓ test_exit_codes time=0.0 | ||
✓ test_logs_spawning time=0.197 | ||
|
||
1 failure, 2 passed | ||
Written to: /home/user/ros_workspace/index.html |
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.
I would go with @Ryanf55 here and say that we link it as a follow on tutorial at the end.
sets the turtle to the intended pose | ||
(see the `Turtlesim introduction tutorial <../../Beginner-CLI-Tools/Introducing-Turtlesim/Introducing-Turtlesim>`). | ||
* Instead of Turtlesim, launch the | ||
:doc:`Gazebo simulator <../../Advanced/Simulators/Gazebo/Gazebo>` |
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.
I am not sure this is necessary. The link is just an intro Gazebo and is a bit unsatisfying. If we had a tutorial on running integration tests with Gazebo that would be worth including.
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.
Removed this section as part of #4881 (comment).
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.
besides the comments, linter/doc8 are not happy https://github.com/ros2/ros2_documentation/actions/runs/12104682983/job/33807471087?pr=4881. can you also address those errors?
@clalancette As-is, I wrapped the lines to 80 characters allowing for clean git diffs. This style guide suggest wrapping, but doesn't mention a desired line length for documentation. Is a 100-character limit preferred for documentation?
Such things can happen, though I don't immediately see how this relates specifically to testing. The DDS taking too long to match topics can also arise when deployed, in which case it's a bug, and therefore it's desirable that the integration tests point out that part of our system is failing? @kscottz |
Good question. Our style is generally one-sentence-per-line; that allows future diffs to be easier to read. However, we do allow breaking a single sentence into multiple lines if necessary. We don't have an exact number for line-length here, but I think 80 characters is too short. Generally, my feeling is that if a particular sentence is too long to comfortably fit on one line, then usually the sentence is too long (there are exceptions to this, including when we are embedding URLs into the sentence, in which case the written sentence can get very long and we break it up). I think the best thing to do is look at some of the other tutorials for reference. While they aren't 100% consistent, that should give you a feeling about what we typically do. |
Thanks for the many suggestions and feedback! Applying the suggestions in multiple batches... Co-authored-by: Chris Lalancette <clalancette@gmail.com> Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Signed-off-by: abaeyens <abaeyens@users.noreply.github.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com> Co-authored-by: Katherine Scott <katherineAScott@gmail.com> Signed-off-by: abaeyens <abaeyens@users.noreply.github.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com> Signed-off-by: abaeyens <abaeyens@users.noreply.github.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com> Co-authored-by: Katherine Scott <katherineAScott@gmail.com> Signed-off-by: abaeyens <abaeyens@users.noreply.github.com>
Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
…whitespace Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
8bd4e48
to
07e9415
Compare
…up sentence Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
…isting tutorial Suggestion, or prefer to put this somewhere else? Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
Follow https://docs.ros.org/en/rolling/The-ROS2-Project/Contributing/Code-Style-Language-Versions.html Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
Should cover all packages, not just the 'app' package which may not even exist in the user's workspace. Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
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.
A few more things to fix up. This is getting closer to being merged.
The above command suppresses the test output and exposes little about which tests succeed and which fail. | ||
Therefore while developing tests the ``--event-handlers`` option is useful to print all test output while the tests are running: | ||
|
||
.. code-block:: console | ||
|
||
colcon test --event-handlers console_direct+ | ||
|
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.
This particular change doesn't really have to do with this PR, so let's discuss this in a separate PR.
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.
Sure, addressed in 620dbab.
… PR. Signed-off-by: Arne Baeyens <mail@arnebaeyens.com>
Co-authored-by: Chris Lalancette <clalancette@gmail.com> Signed-off-by: abaeyens <abaeyens@users.noreply.github.com>
Signed-off-by: Chris Lalancette <clalancette@gmail.com>
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.
This looks great, thank you for iterating.
* tutorial/integration_testing: first draft Signed-off-by: Arne Baeyens <mail@arnebaeyens.com> Co-authored-by: Chris Lalancette <clalancette@gmail.com> Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Co-authored-by: Katherine Scott <katherineAScott@gmail.com> (cherry picked from commit 3d4b2ef)
* tutorial/integration_testing: first draft Signed-off-by: Arne Baeyens <mail@arnebaeyens.com> Co-authored-by: Chris Lalancette <clalancette@gmail.com> Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Co-authored-by: Katherine Scott <katherineAScott@gmail.com> (cherry picked from commit 3d4b2ef)
* tutorial/integration_testing: first draft Signed-off-by: Arne Baeyens <mail@arnebaeyens.com> Co-authored-by: Chris Lalancette <clalancette@gmail.com> Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Co-authored-by: Katherine Scott <katherineAScott@gmail.com> (cherry picked from commit 3d4b2ef) Co-authored-by: abaeyens <abaeyens@users.noreply.github.com>
* tutorial/integration_testing: first draft Signed-off-by: Arne Baeyens <mail@arnebaeyens.com> Co-authored-by: Chris Lalancette <clalancette@gmail.com> Co-authored-by: Tomoya Fujita <Tomoya.Fujita@sony.com> Co-authored-by: Katherine Scott <katherineAScott@gmail.com> (cherry picked from commit 3d4b2ef) Co-authored-by: abaeyens <abaeyens@users.noreply.github.com>
Thanks everyone for their efforts it getting this completed and merged, especially @clalancette! I'm glad I could contribute to the ROS documentation. |
This PR adds a tutorial on integration testing with
launch_testing
and complements the two existing tutorials on unit testing. This topic was first discussed in #4827 and thereafter on ROS discourse. This is my first PR for the ROS 2 project, all feedback welcome!Resolves #4827 and closes ros2/launch#812.