Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags. |
Enabling ROS Epic Fail for a Test
Description: Use ros_epic_fail to catch bag files from a randomly failing test.Tutorial Level: BEGINNER
Initial Considerations
There are a number of things to consider before enabling ros_epic_fail on a test:
- What hudson build will be running it?
- How large are the generated bag files?
Please note that hudson builds require special configuration to run ros_epic_fail. DO NOT USE ROS_EPIC_FAIL WITHOUT CONFIGURING THE BUILD.
Due to the nature of rostest, it is currently impossible to use ros_epic_fail with rostest files that contain multiple tests. To use ros_epic_fail with these tests, please split up the rostest files so each <test> tag has it's own file. For example, files such as:
<launch> <node name="test_me" pkg="mypackage" type="test_me"/> <test test-name="test-one" pkg="mypackage" type="test-one"/> <test test-name="test-two" pkg="mypackage" type="test-two"/> </launch>
Then you could split it into three files:
<launch> <node name="test_me" pkg="mypackage" type="test_me"/> </launch>
<launch> <include file="$(find mypackage)/test_me.launch"/> <test test-name="test-one" pkg="mypackage" type="test-one"/> </launch>
<launch> <include file="$(find mypackage)/test_me.launch"/> <test test-name="test-two" pkg="mypackage" type="test-two"/> </launch>
Adding the Trapper
The trapper is the program that captures the bag files from the test. To add it to a test, you add the following node tag:
<node name="ros_epic_fail_trapper" pkg="ros_epic_fail" type="ros_epic_fail_trapper" args="TEST_NAME TOPIC_LIST" output="screen" />
Where TEST_NAME is the name of the test, and TOPIC_LIST is the list of topics to record. TOPIC_LIST is optional, and if not present every topic will be recorded.
TEST_NAME is in the form of PACKAGE_NAME.TEST-rostest__PATH_TO_FILE_NAME (rostest name). Where:
- PACKAGE_NAME is the name of the package
- PATH_TO_FILE_NAME is the path to the launch file without the extension from the root of the package, with all / replaced with _.
Examples:
Test File |
Test Package |
TEST_NAME |
launch/pr2_door_test.launch |
pr2_doors_gazebo_demo |
pr2_doors_gazebo_demo.TEST-rostest__launch_pr2_door_test |
tests/motion_planners/ompl/freespace_tests.launch |
arm_navigation_tests |
arm_navigation_tests.TEST-rostest__tests_motion_planners_ompl_freespace_tests |
test/test_tester.test |
ros_epic_fail |
TEST-rostest__test_test_tester |
Testing the Trapper
Before starting, please remove all the subdirectories of test_results. This is optional, but greatly decreases the amount of text you will have to sift through. You can delete the test_results by running:
roscd test_results rm -rf *
Run the the test in which the trapper was installed. During the operation of the test, you should see this:
----------------------------------------------------------- ----------------------------------------------------------- ----------------------------------------------------------- ----------------------------------------------------------- ----------------------------------------------------------- ----------------------------------------------------------- --------------------- BAG FILE NAME ----------------------- ----------------------------------------------------------- ----------------------------------------------------------- ----------------------------------------------------------- /u/pratkanis/.ros/test_results/ros_epic_fail_raw_bags/ros_epic_fail.TEST-rostest__test_test_tester (.bag) ----------------------------------------------------------- ----------------------------------------------------------- ----------------------------------------------------------- ------------------- END BAG FILE NAME --------------------- ----------------------------------------------------------- ----------------------------------------------------------- -----------------------------------------------------------
If you do not see this message, you have incorrectly installed the trapper. The test must succeed. If it does not, run the keeper, and try again.
Next, you must run the keeper twice.
rosrun ros_epic_fail ros_epic_fail rosrun ros_epic_fail ros_epic_fail
During in the output of the second run, you should see:
Succeed, file = /u/pratkanis/.ros/test_results/ros_epic_fail_raw_bags/ros_epic_fail.TEST-rostest__test_test_tester.bag
With ros_epic_fail.TEST replaced with your package name.TEST. You should also see your test's file name after the last rostest. Copy the name of the bag file, after "Succeed, file =" and store it in a scratch location (document, etc).
Run your test again. It does not matter if it succeeds or fails as long as it prints out the bag file name message again.
Now, run on:
ls your_bag_file_name_from_previous_step
If you see
ls: cannot access your_bag_file_name_from_previous_step: No such file or directory
This means that your bag file is incorrectly named. You must edit the launch file where the trapper is launched to have the correct test name. This is the bag file name you copied without the extension and absolute path. Then, you must repeat the test procedure.
If ls simply parrots back the file name, you have correctly set up ros_epic_fail for your test! Congratulations. You must now configure the package for ros_epic_fail.