Add ament_add_pytest_isolated and ament_add_gtest_isolated#3
Add ament_add_pytest_isolated and ament_add_gtest_isolated#3wjwwood merged 6 commits intoros2:masterfrom
Conversation
- Add a domain_coordinator package containing the functionality from launch_testing and
a run_test_isolated.py script that can be used by the isolated cmake test functions instead
of the default run_test.py
- Add ament_cmake_gtest_isolated to run gtests with ROS_DOMAIN_ID isolation
- Add ament_cmake_pytest_isolated to run pytests with ROS_DOMAIN_ID isolation
Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
1ea6217 to
973a713
Compare
ivanpauno
left a comment
There was a problem hiding this comment.
I let a few comments about domain_coordinator package.
I didn't review the rest.
|
@ivanpauno what if I add one more package - ament_cmake_test_isolated, which would provide run_test_isolated.py in a way that its path could be referenced by cmake. Then domain_coordinator could indeed be made into an ament_python package |
mmm, I don't know either (without creating a FindDomainCoordinator.cmake and installing it from setup.py).
If it's not way to looking up the path when changing the package to be Your option of adding an extra package is also good. |
- Make domain_coordinator an ament_python package - remove run_test_isolated.py from domain_coordinator - Add a new cmake package that provides run_test_isolated.py Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
|
@ivanpauno Ok - domain_coordinator is an ament_python package now. It can be moved to another repo if you wish. Package dependencies are not my strongest skill, so I hope I got the transitive dependency on domain_coordinator from ament_cmake_test_isolated right (see comment above) |
ivanpauno
left a comment
There was a problem hiding this comment.
LGTM, I let some minor comments.
It's fine for me to leave the domain_coordinator package here.
|
|
||
| author='Pete Baughman', | ||
| author_email='pete.baughman@apex.ai', | ||
|
|
There was a problem hiding this comment.
I think that it would be good to add url, download_url, long_description, license, etc. See https://github.com/ros2/launch/blob/master/launch/setup.py as an example.
There was a problem hiding this comment.
Sorry for my lazy "etc". keywords, classifiers and install_requires are missing. The three can be copied from the example.
- Fix copyright date from 2017->2019 - Simplify dependencies of isolated test packages - Put more information in domain_coordinator setup.py Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
|
@ivanpauno Thanks for your help with the dependency stuff. I believe I've done all of your feedback. I also updated the |
|
@ivanpauno I'm having some trouble with this following the merge of the PR in ament_cmake. . . investigating |
|
Ok, False alarm above - a few files got deleted from my local workspace when I did a clean build. I've now successfully re-tested this with the merged ament_cmake changes. This is now free of blockers and ready to go! |
|
|
||
| author='Pete Baughman', | ||
| author_email='pete.baughman@apex.ai', | ||
|
|
There was a problem hiding this comment.
Sorry for my lazy "etc". keywords, classifiers and install_requires are missing. The three can be copied from the example.
Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
|
@ivanpauno Oh, whoops - sorry - it has all the same fields as launch setup.py now |
wjwwood
left a comment
There was a problem hiding this comment.
lgtm
Just some thoughts on the names (I don't think we need to change them but I wanted to note my thoughts in case others agree and want to change them):
ament_cmake_*_isolated strikes me as a bit broad, since it really only does isolation for ROS stuff, and I was expecting either ament_cmake_ros_*_isolated or maybe ament_cmake_*_ros_isolated. My very slight concern is that people will assume isolated means what it means for our build tools (merged vs isolated install for example) or that it has something to do with threading or test result output, rather than specifically being about ROS isolation. The first time you see anything about ROS is in the doc block of the cmake functions of similar name.
Also, domain_coordinator could similarly be more specific as ros_domain_coordinator, but again it's not that critical.
Just some food for thought, but I think the pr as-is is ok (aside from perhaps moving the documentation as I suggested in my comment).
|
Just to clarify the intended follow up: do you plan to update any / all existing calls to the non-isolated version of the CMake functions? If yes, I think we should be very confident in the naming of the function. Changing it later will be difficult. Maybe using a suffix like |
@dirk-thomas |
|
Maybe for some of those cases it would make sense to actually update the tests instead? |
|
@dirk-thomas Maybe - that's the route I initially started to go down but after fixing up a few tests, I determined that that solving the more general problem of how to isolate ROS tests from one-another would be a cheaper way to accomplish the same thing. I will keep my eyes peeled for tests with 'easy' fixes - but the rosbag2 tests in particular do not like to have any other publishers running on the system. |
- Give a better name so this doesn't seem like the same thing as build isolated vs build merge install - Add the explanation of how ROS_DOMAIN_ID is selected in the cmake function documentation Signed-off-by: Pete Baughman <pete.baughman@apex.ai>
b07a4d9 to
2b1af8d
Compare
|
Ok, this is ready to go again. We can squash the commits when we merge, right? |
|
I'll re-review and run a new set of CI before merging but yes we squash when we merge. |
|
CI: With settings:
|
|
sigh
|
|
Never mind about the above - I'm a big dummy who typo'd the name of this package when I tried to use it. |
|
Do we really need separate packages for each of these functions? And another one with #4? I would suggest to rather move them into |
| use ROS2 without unexpected cross-talk between processes. | ||
| This is similar to the ROS1 rostest behavior of putting the ROS master on a unique port. | ||
|
|
||
| Users of get_coordintaed_gomain_id must keep the returned object alive. If the returned |
There was a problem hiding this comment.
This is conceptionally really broken. In Python you can't rely on when an instance which isn't referenced anymore is being garbage collected. As a result the tests even warn about the sockets never being closed: https://ci.ros2.org/view/All/job/test_ci_windows/196/pytest-warnings/
See #9 for the follow up ticket.
There was a problem hiding this comment.
@dirk-thomas The open port shouldn't outlive the run_test_isolated.py wrapper. The port will be returned to the pool of available ports when run_test_isolated.py is terminated
I agree that another use of the domain_coordinator object might consider a ROS_DOMAIN_ID "taken" for longer than you'd otherwise expect though. If someone changed how run_test_isolated.py works, or tries to re-use the domain_coordinator elsewhere they might be surprised.
There was a problem hiding this comment.
Obviously the resource doesn't outlive the process lifetime. But that doesn't solve the API problem which in its current form results in warnings about unclosed handles.
There was a problem hiding this comment.
Yeah - sorry, I edited at the same time you replied. The API documentation does kind of write a check that the implementation can't cash right now. I also agree that useless warnings are bad noise.
This PR depends on:
Add runner option to ament_add_test ament/ament_cmake#174Already MergedThis PR blocks
Use the new 'RUNNER' argument provided in ament_cmake PR 174 to create new versions of
ament_add_gtestandament_add_pytest_testthat runs with ROS_DOMAIN_ID isolation if no ROS_DOMAIN_ID is already set.This will also coordinate domain IDs with the ros2test tool
Testing
I've tested this PR in conjunction with ament_cmake 174 by changing rcl and rclpy to use the 'isolated' version of these macros, then running
And verifying in the test logs that we see tests using ROS_DOMAIN_ID 1 as well as ROS_DOMAIN_ID 2
Test Cases:
colcon testcommands in parallel and verify that different ROS_DOMAIN_IDs are chosenExample usage
In rclpy:
In rcl: