Skip to content

Commit e1c74b7

Browse files
tylerjwrhaschkedavetcoleman
authored
Tutorial for debugging a failing test using docker (#489)
* tutorial for debugging a failing test using docker * Update doc/test_debugging/test_debugging_tutorial.rst Co-authored-by: Robert Haschke <[email protected]> * Update doc/test_debugging/test_debugging_tutorial.rst Co-authored-by: Robert Haschke <[email protected]> * Update doc/test_debugging/test_debugging_tutorial.rst Co-authored-by: Robert Haschke <[email protected]> * Update doc/test_debugging/test_debugging_tutorial.rst Co-authored-by: Robert Haschke <[email protected]> * remove ros_distro env variable * fix grammar/spelling errors * Apply suggestions from code review * Fix sphynx bug Co-authored-by: Robert Haschke <[email protected]> Co-authored-by: Dave Coleman <[email protected]>
1 parent 22711b2 commit e1c74b7

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
Debugging Tests
2+
===============
3+
4+
How to debug when a test is failing.
5+
6+
**Note:** *This is not meant as an exhaustive tutorial on software testing, instead this focuses on methods that will help you debug tests in MoveIt or similar ROS projects.*
7+
8+
Getting Started
9+
---------------
10+
If you haven't already done so, make sure you've completed the steps in `Getting Started <../getting_started/getting_started.html>`_.
11+
12+
CI Failures
13+
-----------
14+
15+
Our CI runs in Travis and uses scripts found in the `moveit_ci repo <https://github.com/ros-planning/moveit_ci.git>`. These tests build and run various tests in various environments. Often something that works locally won't work in CI in a different environment. To troubleshoot a failure from CI it is useful to use docker to run in the same environment.
16+
17+
For troubleshooting a specific travis test it is helpful to look at the .travis.yml config file and test output to understand what environment variables are being set in your test.
18+
19+
Launch Docker Environment
20+
-------------------------
21+
22+
To start docker container for kinetic:
23+
24+
docker pull moveit/moveit:kinetic-ci
25+
docker run -it moveit/moveit:kinetic-ci /bin/bash
26+
27+
To start docker container for melodic:
28+
29+
docker pull moveit/moveit:melodic-ci
30+
docker run -it moveit/moveit:melodic-ci /bin/bash
31+
32+
Setup Environment
33+
-----------------
34+
35+
The first thing you should do is update debians and install tools you'll need for debugging. The update is important because that is what we do in CI.
36+
37+
apt-get update
38+
apt-get dist-upgrade
39+
apt-get install -y python-catkin-tools ssh git gdb valgrind vim
40+
41+
Next create the folder structure for your ROS environment:
42+
43+
CATKIN_WS=/root/ros_ws
44+
mkdir -p ${CATKIN_WS}/src
45+
cd ${CATKIN_WS}/src
46+
47+
Checkout Code
48+
-------------
49+
50+
In this step we use git and wstool to get the code we will be testing. You'll replace the remote and branch with yours if you are debugging a PR. Note that on the wstool update step we'll need to skip replacing moveit if we are testing a specific branch from a PR.
51+
52+
cd ${CATKIN_WS}/src
53+
wstool init .
54+
git clone https://github.com/ros-planning/moveit.git -b master
55+
wstool merge -t . moveit/moveit.rosinstall
56+
wstool update
57+
58+
Install Dependencies
59+
--------------------
60+
61+
Here we install debian dependencies with rosdep:
62+
63+
cd ${CATKIN_WS}/src
64+
rosdep install -y -q -n --from-paths . --ignore-src --rosdistro ${ROS_DISTRO}
65+
66+
Configure and Build
67+
-------------------
68+
69+
Now we configure and build our workspace. Note that we set extra CXXFLAGS to be the same as the ones used by moveit_ci.
70+
71+
cd $CATKIN_WS
72+
export CXXFLAGS="-Wall -Wextra -Wwrite-strings -Wunreachable-code -Wpointer-arith -Wredundant-decls"
73+
catkin config --extend /opt/ros/${ROS_DISTRO} --no-install --cmake-args -DCMAKE_BUILD_TYPE=Debug
74+
catkin build --summarize
75+
76+
Build the Tests
77+
---------------
78+
79+
Here is the command to build the tests in the workspace:
80+
81+
cd ${CATKIN_WS}
82+
catkin build --summarize --make-args tests
83+
84+
Run the Tests
85+
-------------
86+
87+
To run all the tests we can use the run_tests cmake arg. Here we should specify a specific package we want to test as that will speed up this run.
88+
89+
catkin build --summarize --catkin-make-args run_tests -- moveit_ros_planning_interface
90+
91+
Run One Test
92+
------------
93+
94+
You can also use rostest to run a specific test. The text argument sends output to the console instead of an xml output file. To do this you'll have to source the devel workspace.
95+
96+
cd ${CATKIN_WS}
97+
source devel/setup.bash
98+
rostest moveit_ros_planning_interface move_group_pick_place_test.test --text
99+

index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ Miscellaneous
9494
doc/realtime_servo/realtime_servo_tutorial
9595
doc/benchmarking/benchmarking_tutorial
9696
doc/tests/tests_tutorial
97+
doc/test_debugging/test_debugging_tutorial
9798

9899
Attribution
99100
-----------

0 commit comments

Comments
 (0)