Hi The Construct Team,
I am currently working on GTest Framework for ROS2 course, currently on Unit 4 - Full-System and Sub-System Tests.
Followed the notes as instructed on the notes for every step until “4.9 Build and run the system tests”.
After completing the my_system_test
package,
colcon build --packages-select my_system_test
succeeds.
But,
colcon test --packages-select my_system_test --event-handler=console_direct+
fails.
Here is the (first) output:
user:~$ cd ros2_ws/
user:~/ros2_ws$ colcon build --packages-select my_system_test
Starting >>> my_system_test
Finished <<< my_system_test [0.25s]
Summary: 1 package finished [0.40s]
user:~/ros2_ws$ colcon test --packages-select my_system_test --event-handler=console_direct+
Starting >>> my_system_test
UpdateCTestConfiguration from :/home/user/ros2_ws/build/my_system_test/CTestConfiguration.ini
Parse Config file:/home/user/ros2_ws/build/my_system_test/CTestConfiguration.ini
Site: 2_xterm
Build name: (empty)
Add coverage exclude regular expressions.
SetCTestConfiguration:CMakeCommand:/usr/bin/cmake
Create new tag: 20221228-0743 - Experimental
UpdateCTestConfiguration from :/home/user/ros2_ws/build/my_system_test/CTestConfiguration.ini
Parse Config file:/home/user/ros2_ws/build/my_system_test/CTestConfiguration.ini
Test project /home/user/ros2_ws/build/my_system_test
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 1
Start 1: test_bt_navigator
1: Test command: /usr/bin/python3 "-u" "/opt/ros/galactic/share/ament_cmake_test/cmake/run_test.py" "/home/user/ros2_ws/build/my_system_test/test_results/my_system_test/test_bt_navigator.xml" "--package-name" "my_system_test" "--generate-result-on-success" "--env" "TEST_DIR=/home/user/ros2_ws/src/my_system_test/src/my_full_system_test" "TESTER=tester_node.py" "TEST_MAP=/home/user/ros2_ws/src/my_system_test/maps/map_circular.yaml" "TEST_WORLD=/home/user/ros2_ws/src/my_system_test/worlds/turtlebot3_ros2_demo.world" "BT_NAVIGATOR_XML=navigate_to_pose_w_replanning_and_recovery.xml" "GAZEBO_MODEL_PATH=/home/user/ros2_ws/src/my_system_test/models" "ASTAR=True" "CONTROLLER=nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController" "PLANNER=nav2_navfn_planner/NavfnPlanner" "--command" "/home/user/ros2_ws/src/my_system_test/src/my_full_system_test/test_system_launch.py"
1: Test timeout computed to be: 180
1: -- run_test.py: extra environment variables:
1: - ASTAR=True
1: - BT_NAVIGATOR_XML=navigate_to_pose_w_replanning_and_recovery.xml
1: - CONTROLLER=nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController
1: - GAZEBO_MODEL_PATH=/home/user/ros2_ws/src/my_system_test/models
1: - PLANNER=nav2_navfn_planner/NavfnPlanner
1: - TESTER=tester_node.py
1: - TEST_DIR=/home/user/ros2_ws/src/my_system_test/src/my_full_system_test
1: - TEST_MAP=/home/user/ros2_ws/src/my_system_test/maps/map_circular.yaml
1: - TEST_WORLD=/home/user/ros2_ws/src/my_system_test/worlds/turtlebot3_ros2_demo.world
1: -- run_test.py: invoking following command in '/home/user/ros2_ws/build/my_system_test/src/my_full_system_test':
1: - /home/user/ros2_ws/src/my_system_test/src/my_full_system_test/test_system_launch.py
1: File "/home/user/ros2_ws/src/my_system_test/src/my_full_system_test/test_system_launch.py", line 29
1: from launch_testing.legacy import LaunchTestServicenav2_bringup package
1: ^
1: SyntaxError: invalid syntax
1: -- run_test.py: return code 1
1: -- run_test.py: generate result file '/home/user/ros2_ws/build/my_system_test/test_results/my_system_test/test_bt_navigator.xml' with failed test
1: -- run_test.py: verify result file '/home/user/ros2_ws/build/my_system_test/test_results/my_system_test/test_bt_navigator.xml'
1/1 Test #1: test_bt_navigator ................***Failed 0.12 sec
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 0.12 sec
The following tests FAILED:
1 - test_bt_navigator (Failed)
Errors while running CTest
--- stderr: my_system_test
Errors while running CTest
---
Finished <<< my_system_test [0.19s] [ with test failures ]
Summary: 1 package finished [0.41s]
1 package had stderr output: my_system_test
1 package had test failures: my_system_test
user:~/ros2_ws$
From the about output I noted that the test_system_launch.py
file had some problem in line 29:
So I changed the following line (line 29):
from launch_testing.legacy import LaunchTestServicenav2_bringup package
To the following line (commented the last words nav2_bringup package - I believe that was probably a typing error):
from launch_testing.legacy import LaunchTestService # nav2_bringup package
I then built and tested again.
Here is my (second) output:
user:~/ros2_ws$ colcon build --packages-select my_system_test
Starting >>> my_system_test
Finished <<< my_system_test [0.24s]
Summary: 1 package finished [0.39s]
user:~/ros2_ws$ colcon test --packages-select my_system_test --event-handler=console_direct+
Starting >>> my_system_test
UpdateCTestConfiguration from :/home/user/ros2_ws/build/my_system_test/CTestConfiguration.ini
Parse Config file:/home/user/ros2_ws/build/my_system_test/CTestConfiguration.ini
Site: 2_xterm
Build name: (empty)
Add coverage exclude regular expressions.
SetCTestConfiguration:CMakeCommand:/usr/bin/cmake
Create new tag: 20221228-0749 - Experimental
UpdateCTestConfiguration from :/home/user/ros2_ws/build/my_system_test/CTestConfiguration.ini
Parse Config file:/home/user/ros2_ws/build/my_system_test/CTestConfiguration.ini
Test project /home/user/ros2_ws/build/my_system_test
Constructing a list of tests
Done constructing a list of tests
Updating test list for fixtures
Added 0 tests to meet fixture requirements
Checking test dependency graph...
Checking test dependency graph end
test 1
Start 1: test_bt_navigator
1: Test command: /usr/bin/python3 "-u" "/opt/ros/galactic/share/ament_cmake_test/cmake/run_test.py" "/home/user/ros2_ws/build/my_system_test/test_results/my_system_test/test_bt_navigator.xml" "--package-name" "my_system_test" "--generate-result-on-success" "--env" "TEST_DIR=/home/user/ros2_ws/src/my_system_test/src/my_full_system_test" "TESTER=tester_node.py" "TEST_MAP=/home/user/ros2_ws/src/my_system_test/maps/map_circular.yaml" "TEST_WORLD=/home/user/ros2_ws/src/my_system_test/worlds/turtlebot3_ros2_demo.world" "BT_NAVIGATOR_XML=navigate_to_pose_w_replanning_and_recovery.xml" "GAZEBO_MODEL_PATH=/home/user/ros2_ws/src/my_system_test/models" "ASTAR=True" "CONTROLLER=nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController" "PLANNER=nav2_navfn_planner/NavfnPlanner" "--command" "/home/user/ros2_ws/src/my_system_test/src/my_full_system_test/test_system_launch.py"
1: Test timeout computed to be: 180
1: -- run_test.py: extra environment variables:
1: - ASTAR=True
1: - BT_NAVIGATOR_XML=navigate_to_pose_w_replanning_and_recovery.xml
1: - CONTROLLER=nav2_regulated_pure_pursuit_controller::RegulatedPurePursuitController
1: - GAZEBO_MODEL_PATH=/home/user/ros2_ws/src/my_system_test/models
1: - PLANNER=nav2_navfn_planner/NavfnPlanner
1: - TESTER=tester_node.py
1: - TEST_DIR=/home/user/ros2_ws/src/my_system_test/src/my_full_system_test
1: - TEST_MAP=/home/user/ros2_ws/src/my_system_test/maps/map_circular.yaml
1: - TEST_WORLD=/home/user/ros2_ws/src/my_system_test/worlds/turtlebot3_ros2_demo.world
1: -- run_test.py: invoking following command in '/home/user/ros2_ws/build/my_system_test/src/my_full_system_test':
1: - /home/user/ros2_ws/src/my_system_test/src/my_full_system_test/test_system_launch.py
1: [INFO] [launch]: All log files can be found below /home/user/.ros/log/2022-12-28-07-49-28-318057-2_xterm-2759
1: [INFO] [launch]: Default logging verbosity is set to INFO
1: Task exception was never retrieved
1: future: <Task finished name='Task-2' coro=<LaunchService._process_one_event() done, defined at /opt/ros/galactic/lib/python3.8/site-packages/launch/launch_service.py:226> exception=AttributeError("'tuple' object has no attribute 'visit'")>
1: Traceback (most recent call last):
1: File "/opt/ros/galactic/lib/python3.8/site-packages/launch/launch_service.py", line 228, in _process_one_event
1: await self.__process_event(next_event)
1: File "/opt/ros/galactic/lib/python3.8/site-packages/launch/launch_service.py", line 248, in __process_event
1: visit_all_entities_and_collect_futures(entity, self.__context))
1: File "/opt/ros/galactic/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
1: futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
1: File "/opt/ros/galactic/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 45, in visit_all_entities_and_collect_futures
1: futures_to_return += visit_all_entities_and_collect_futures(sub_entity, context)
1: File "/opt/ros/galactic/lib/python3.8/site-packages/launch/utilities/visit_all_entities_and_collect_futures_impl.py", line 38, in visit_all_entities_and_collect_futures
1: sub_entities = entity.visit(context)
1: AttributeError: 'tuple' object has no attribute 'visit'
1: -- run_test.py: return code 1
1: -- run_test.py: generate result file '/home/user/ros2_ws/build/my_system_test/test_results/my_system_test/test_bt_navigator.xml' with failed test
1: -- run_test.py: verify result file '/home/user/ros2_ws/build/my_system_test/test_results/my_system_test/test_bt_navigator.xml'
1/1 Test #1: test_bt_navigator ................***Failed 0.60 sec
0% tests passed, 1 tests failed out of 1
Total Test time (real) = 0.60 sec
The following tests FAILED:
1 - test_bt_navigator (Failed)
Errors while running CTest
--- stderr: my_system_test
Errors while running CTest
---
Finished <<< my_system_test [0.66s] [ with test failures ]
Summary: 1 package finished [0.92s]
1 package had stderr output: my_system_test
1 package had test failures: my_system_test
user:~/ros2_ws$
This time I had no idea what the problem was, and therefore I have posted it here!
Please help.
Thanks,
Girish