Rostest: Test if nodes are running

asked 2020-04-20 08:31:42 -0500

prex gravatar image

updated 2020-04-20 11:21:25 -0500

As an integration test, I would like to launch a launch file with several nodes and test if these nodes properly start and run. This is something which is often failing because people are not properly exporting and installing libraries during development in devel space.

I don't want to test something particular and I think I don't even need a test node. But I'm not sure how I can test if these nodes are properly running in install space. Can I even use rostest in install space?

  • Are the normal (not test nodes) terminated automatically after the test nodes are finished?

  • Why can't I use add_rostest_gtest(test_mynode launch/mynode.launch) without any cpp unit test? The build fails.

  • What would be a good solution to check if my nodes are running? I can think of super-complicated solutions adding an "is_alive" service to each node and checking these with gtests. But I can't believe there is no easier solution. I found the self_test but from the documentation I can't even figure out if this is what I'm looking for or how this can be used.

The self_test::TestRunner class will advertise a service "~self_test". When called, it will perform a check on the node's connection status, and any other checks a developer wants to perform on a node or device.

edit retag flag offensive close merge delete

Comments

Why can't I use add_rostest_gtest(test_mynode launch/mynode.launch) without any cpp unit test?

I would say because a .launch file is not a gtest.

I believe for what you want to test there (is everything installed correctly and findable) you'd use roslaunch_add_file_check(..).

gvdhoorn gravatar image gvdhoorn  ( 2020-04-21 06:02:28 -0500 )edit

Thanks @gvdhoorn for the hint. But roslaunch-check is not doing what I'm looking for.

It's best if I give an example of what condition I'm trying to catch during my Github CI action:

We have a package using SWIG to create some python bindings. One of these bindings is imported by a python ROS node. In devel space, everything works fine when launching the python node, because the library is in devel space. However, the author forgot to install the python binding to install space. So when running the same python node in install space, the SWIG python module can not be imported and the node is not started.

What turned out to be effective for manual testing is launching our product's launch file and seeing if all nodes start and keep running. I'm wondering if I can do something similar for the CI action ...(more)

prex gravatar image prex  ( 2020-04-21 10:19:08 -0500 )edit

Found a workaround. I'm launching my nodes with required="true" and then wait 30s before executing rosnode list. If one node crashed, the other nodes are killed too and rosnode list returns false, leading to a failed integration test.

Only downside is that this requires to have required="true".

prex gravatar image prex  ( 2020-04-22 05:35:36 -0500 )edit