Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make ros_comm unit tests pass #33

Open
lucasw opened this issue Dec 23, 2023 · 16 comments
Open

make ros_comm unit tests pass #33

lucasw opened this issue Dec 23, 2023 · 16 comments

Comments

@lucasw
Copy link
Owner

lucasw commented Dec 23, 2023

export ROS_ROOT=/opt/share/ros  # using debian ros packages
catkin build --catkin-make-args run_tests
catkin_test_results

Possibly catkin_make run_tests will show results more clearly.

Added github action files for ubuntu 20.04 and 22.04 to ros_comm branches- https://github.com/lucasw/ros_comm/tree/noetic_devel_github_action, https://github.com/lucasw/ros_comm/tree/salsa_noetic_aggregated, and https://github.com/lucasw/ros_comm/tree/zenoh_pub_sub_cpp

current results are seen here (every push):
https://github.com/lucasw/ros_comm/actions

Also make them pass locally on 23.04/23.10

lucasw/ros_one2z#7 (comment)

@lucasw
Copy link
Owner Author

lucasw commented Dec 23, 2023

On 23.04 see an error related to not having ROS_ROOT, set that manually just for the tests

ROS_ROOT=`pwd` catkin build --catkin-make-args run_tests
catkin_test_results --all | grep -v "Skipping" | grep fail
build/rosgraph/test_results/rosgraph/nosetests-test.xml: 52 tests, 3 errors, 0 failures, 0 skipped
build/roslaunch/test_results/roslaunch/nosetests-test.unit.xml: 111 tests, 2 errors, 1 failures, 0 skipped
build/xmlrpcpp/test_results/xmlrpcpp/MISSING-gtest-test_base64.xml: 1 tests, 0 errors, 1 failures, 0 skipped
Summary: 905 tests, 5 errors, 2 failures, 0 skipped

@lucasw
Copy link
Owner Author

lucasw commented Dec 23, 2023

Run just one set of tests

ROS_ROOT=`pwd` catkin build roslaunch --no-status --catkin-make-args run_tests
catkin_test_results --all build/roslaunch | grep -v "Skipping" | grep error
test_results/roslaunch/nosetests-test.unit.xml: 111 tests, 2 errors, 0 failures, 0 skipped
Summary: 111 tests, 2 errors, 0 failures, 0 skipped

How about run one single test?

cd ~/ros/ros1_ros_comm/src/ros_comm/tools/roslaunch/test/unit
ROS_ROOT=~/ros/ros1_ros_comm pytest test_roslaunch_child.py
...
======================================== short test summary info ========================================
FAILED test_roslaunch_child.py::TestRoslaunchChild::test_roslaunchChild - AttributeError: 'ProcessMonitorMock' object has no attribute 'exit_code'
===================================== 1 failed, 7 warnings in 0.50s =====================================
  /home/lucasw/ros/ros1_ros_comm/src/ros_comm/tools/roslaunch/test/unit/test_roslaunch_child.py:161: DeprecationWarning: Please use assertTrue instead.

Try another testing command line, still same as pytest

python -m unittest test_roslaunch_child.py

recursive search and replace of assertEquals:

find . -type f -name "*.py" -exec sed -i'' -e 's/assertEquals/assertEqual/g' {} +

specific test

ROS_ROOT=~/ros/ros1_ros_comm pytest test_nodeprocess.py::TestNodeprocess::test_local_process_stop_timeouts
...
>       self.check_stop_timeouts(master_uri, n, run_id, 0.00001, 1.0)

test_nodeprocess.py:239: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
test_nodeprocess.py:281: in check_stop_timeouts
    self.assertSetEqual({signal.SIGINT, signal.SIGTERM}, set(signals.keys()))
E   AssertionError: Items in the first set but not the second:

...


---

sudo apt install python3-mock

@lucasw
Copy link
Owner Author

lucasw commented Dec 23, 2023

Probably missing an install, duplicate this in Docker:

Traceback (most recent call last):
  File "/home/runner/work/ros_comm/ros_comm/install_catkin_ws/build/catkin_tools_prebuild/catkin_generated/generate_cached_setup.py", line 22, in <module>
    code = generate_environment_script('/home/runner/work/ros_comm/ros_comm/install_catkin_ws/devel/.private/catkin_tools_prebuild/env.sh')
  File "/usr/lib/python3/dist-packages/catkin/environment_cache.py", line 63, in generate_environment_script
    env_after = ast.literal_eval(output.decode('utf8'))
  File "/usr/lib/python3.10/ast.py", line 64, in literal_eval
    node_or_string = parse(node_or_string.lstrip(" \t"), mode='eval')
  File "/usr/lib/python3.10/ast.py", line 50, in parse
    return compile(source, filename, mode, flags,
  File "<unknown>", line 1
    ROS_DISTRO was set to 'noetic' before. Please make sure that the environment does not mix paths from different distributions.
               ^^^
SyntaxError: invalid syntax
CMake Error at /usr/share/catkin/cmake/safe_execute_process.cmake:11 (message):
  execute_process(/usr/bin/python3
  "/home/runner/work/ros_comm/ros_comm/install_catkin_ws/build/catkin_tools_prebuild/catkin_generated/generate_cached_setup.py")
  returned error code 1
Call Stack (most recent call first):
  /usr/share/catkin/cmake/all.cmake:221 (safe_execute_process)
  /usr/share/catkin/cmake/catkinConfig.cmake:20 (include)
  CMakeLists.txt:4 (find_package)

-> Don't set ROS_DISTRO to noetic in the action, this avoids the above error

@lucasw
Copy link
Owner Author

lucasw commented Dec 24, 2023

In 22.04 docker and 23.04 local:

/home/lucasw/ros/ros1_ros_comm/src/ros_comm/test/test_roscpp/test/src/service_exception.cpp: In member function ‘virtual void ListAppender::close()’:
/home/lucasw/ros/ros1_ros_comm/src/ros_comm/test/test_roscpp/test/src/service_exception.cpp:25:11: error: ‘class ListAppender’ has no member named ‘closed’; did you mean ‘close’?
   25 |     this->closed = true;
      |           ^~~~~~
      |           close

Just commented those lines out for now,

/home/lucasw/ros/ros1_ros_comm/src/ros_comm/test/test_roscpp/test/src/service_exception.cpp:50:27: error: ‘ObjectPtrT’ in namespace ‘log4cxx::helpers’ does not name a template type; did you mean ‘ObjectPtr’?
   50 | typedef log4cxx::helpers::ObjectPtrT<ListAppender> ListAppenderPtr;
      |                           ^~~~~~~~~~
      |                           ObjectPtr

Need this for log4cxx::helpers::ObjectPtrT

#include <log4cxx/filter/expressionfilter.h>

but then get

/usr/include/log4cxx/filter/expressionfilter.h:28:18: error: ‘ObjectPtrT’ in namespace ‘log4cxx::helpers’ does not name a template type; did you mean ‘ObjectPtr’?
   28 | typedef helpers::ObjectPtrT < Rule > RulePtr;
      |                  ^~~~~~~~~~
      |                  ObjectPtr

How about using C++11?

catkin config --cmake-args -DCMAKE_BUILD_TYPE=Release -Wno-deprecated -DCMAKE_CXX_STANDARD=11

if that works try using it for only that test

No it didn't help, try running the same dockerfile in 20.04

docker build . -f Dockerfile.2004 -t ros_comm_noetic_devel_2004

@lucasw
Copy link
Owner Author

lucasw commented Dec 26, 2023

Try github actions and Docker file on noetic_devel_github_action

docker build . -t ros_comm_noetic_devel

also run 20.04 tests

@lucasw
Copy link
Owner Author

lucasw commented Dec 26, 2023

failed in 20.04 action:

2023-12-26T15:57:32.3949081Z ======================================================================
2023-12-26T15:57:32.3950019Z FAIL: test_offline (test.test_roswtf_command_line_offline.TestRoswtfOffline)
2023-12-26T15:57:32.3951130Z ----------------------------------------------------------------------
2023-12-26T15:57:32.3951823Z Traceback (most recent call last):
2023-12-26T15:57:32.3953365Z   File "/home/runner/work/ros_comm/ros_comm/install_catkin_ws/src/ros_comm/utilities/roswtf/test/test_roswtf_command_line_offline.py", line 107, in test_offline
2023-12-26T15:57:32.3954897Z     self._check_output(output[0])
2023-12-26T15:57:32.3956363Z   File "/home/runner/work/ros_comm/ros_comm/install_catkin_ws/src/ros_comm/utilities/roswtf/test/test_roswtf_command_line_offline.py", line 117, in _check_output
2023-12-26T15:57:32.3957859Z     self.assert_(
2023-12-26T15:57:32.3958453Z AssertionError: False is not true : OUTPUT[Package: roswtf
2023-12-26T15:57:32.3959155Z ]
2023-12-26T15:57:32.3959351Z 
~/ros/ros1_ros_comm/src/ros_comm/utilities/roswtf
pytest

does roswtf even work by itself?

ROS_ROOT=`pwd` roswtf
Loaded plugin tf.tfwtf
ROS_ROOT is invalid: ROS_ROOT [/home/lucasw/ros/ros1_ros_comm/tmp_ros] must end in directory named 'ros'

why does it matter what directory ros_root is?

mkdir ros
ROS_ROOT=~/ros roswtf

WARNING You are missing Debian packages for core ROS Python modules: rosdep2 (python3-rosdep) -- 
WARNING ROS_HOSTNAME may be incorrect: ROS_HOSTNAME [lucaswsys76] resolves to [127.0.1.1], which does not appear to be a local IP address ['127.0.0.1', '192.168.1.100', '192.168.0.36', '10.73.0.5', '172.17.0.1'].

Probably should just add 127.0.1.1 to the list
https://answers.ros.org/question/373348/roswtf-warns-on-hostname-that-resolves-to-127011-when-127001-is-a-local-ip/

@lucasw
Copy link
Owner Author

lucasw commented Dec 26, 2023

Where are these coming from? Don't see any cases of _1 or _2 by themselves

Warnings << message_filters:make /home/runner/work/ros_comm/ros_comm/install_catkin_ws/logs/message_filters/build.make.001.log
In file included from /usr/include/boost/smart_ptr/detail/sp_thread_sleep.hpp:22,
                 from /usr/include/boost/smart_ptr/detail/yield_k.hpp:23,
                 from /usr/include/boost/smart_ptr/detail/spinlock_gcc_atomic.hpp:14,
                 from /usr/include/boost/smart_ptr/detail/spinlock.hpp:42,
                 from /usr/include/boost/smart_ptr/detail/spinlock_pool.hpp:25,
                 from /usr/include/boost/smart_ptr/shared_ptr.hpp:29,
                 from /usr/include/boost/shared_ptr.hpp:17,
                 from /home/runner/work/ros_comm/ros_comm/install_catkin_ws/install/include/ros/forwards.h:37,
                 from /home/runner/work/ros_comm/ros_comm/install_catkin_ws/install/include/ros/init.h:38,
                 from /home/runner/work/ros_comm/ros_comm/install_catkin_ws/src/ros_comm/utilities/message_filters/test/msg_cache_unittest.cpp:38:
/usr/include/boost/bind.hpp:36:1: note: ‘#pragma message: The practice of declaring the Bind placeholders (_1, _2, ...) in the global namespace is deprecated. Please use <boost/bind/bind.hpp> + using namespace boost::placeholders, or define BOOST_BIND_GLOBAL_PLACEHOLDERS to retain the current behavior.’
   36 | BOOST_PRAGMA_MESSAGE(
      | ^~~~~~~~~~~~~~~~~~~~

@lucasw
Copy link
Owner Author

lucasw commented Dec 26, 2023

Current failures in 22.04

build/roswtf/test_results/roswtf/rosunit-roswtf_command_line_online.xml: 2 tests, 0 errors, 1 failures, 0 skipped
build/test_roscpp/test_results/test_roscpp/gtest-test_roscpp-test_poll_set.xml: 14 tests, 0 errors, 0 failures, 2 skipped
build/test_rospy/test_results/test_rospy/rostest-test_rostest_latch_unsubscribe.xml: 1 tests, 0 errors, 1 failures, 0 skipped

Only roswtf is failing in 20.04

source ~/ros/ros1_ros_comm/devel/setup.bash
~/ros/ros1_ros_comm/src/ros_comm/tools/roslaunch$ ROS_ROOT=`pwd`/ros pytest .
...
        if not m.is_running():
>           raise RLException("ERROR: could not contact master [%s]"%m.uri)
E           roslaunch.core.RLException: ERROR: could not contact master ...

Does pytest fail to get the roscore running? No it looks like the test is supposed to launch it, but that isn't working

@lucasw
Copy link
Owner Author

lucasw commented Dec 27, 2023

Switching development over to https://github.com/lucasw/ros_comm/tree/salsa_noetic_aggregated so can run tests 23.04 locally then see how 20.04 and 22.04 actions do

catkin_test_results
build/rosgraph/test_results/rosgraph/nosetests-test.xml: 53 tests, 2 errors, 0 failures, 0 skipped
build/roslaunch/test_results/roslaunch/nosetests-test.unit.xml: 111 tests, 1 errors, 3 failures, 0 skipped
build/rosmsg/test_results/rosmsg/nosetests-test.xml: 31 tests, 0 errors, 1 failures, 0 skipped
build/roswtf/test_results/roswtf/rosunit-roswtf_command_line_online.xml: 2 tests, 0 errors, 1 failures, 0 skipped
build/test_rosbag/test_results/test_rosbag/MISSING-rostest-test_random_record.xml: 1 tests, 0 errors, 1 failures, 0 skipped
build/test_roscpp/test_results/test_roscpp/gtest-test_roscpp-test_poll_set.xml: 14 tests, 0 errors, 0 failures, 2 skipped
build/test_roslaunch/test_results/test_roslaunch/rosunit-env.xml: 1 tests, 0 errors, 1 failures, 0 skipped
build/test_roslaunch/test_results/test_roslaunch/rosunit-roslaunch_command_line_online.xml: 1 tests, 1 errors, 0 failures, 0 skipped
build/test_rospy/test_results/test_rospy/nosetests-test.unit.xml: 91 tests, 0 errors, 1 failures, 0 skipped
build/test_rospy/test_results/test_rospy/rosunit-rospy_client.xml: 10 tests, 0 errors, 1 failures, 0 skipped
build/test_rospy/test_results/test_rospy/rosunit-test_latch_unsubscribe.xml: 1 tests, 0 errors, 1 failures, 0 skipped
build/topic_tools/test_results/topic_tools/rostest-test_transform.xml: 2 tests, 2 errors, 0 failures, 0 skipped
build/topic_tools/test_results/topic_tools/rosunit-transform_.xml: 1 tests, 1 errors, 0 failures, 0 skipped
build/topic_tools/test_results/topic_tools/rosunit-transform_ns.xml: 1 tests, 0 errors, 1 failures, 0 skipped
build/xmlrpcpp/test_results/xmlrpcpp/MISSING-gtest-test_base64.xml: 1 tests, 0 errors, 1 failures, 0 skipped
Summary: 2028 tests, 7 errors, 12 failures, 2 skipped

@lucasw
Copy link
Owner Author

lucasw commented Dec 28, 2023

Switch to catkin_make for running tests

a single package:

catkin_make run_tests_test_rospy

or even more specific

catkin_make run_tests_test_rospy_nosetests

fix roswtf next

catkin_make run_tests_roswtf
...

?[31m?[1mERROR?[0m Not all paths in PYTHONPATH [/home/lucasw/ros/ros1_ros_comm_catkin_make/devel/lib/python3/dist-packages:/home/lucasw/ros/ros1_ros_comm/devel/lib/python3/dist-packages:/home/lucasw/catkin_ws/src/drivers/zed/zed_sdk/python:/home/lucasw/other/install/lib/python3.11/site-packages/] point to a directory: 
 * /home/lucasw/other/install/lib/python3.11/site-packages/
...
  File "/usr/lib/python3.11/unittest/case.py", line 57, in testPartExecutor
    yield
  File "/usr/lib/python3.11/unittest/case.py", line 623, in run
    self._callTestMethod(testMethod)
  File "/usr/lib/python3.11/unittest/case.py", line 579, in _callTestMethod
    if method() is not None:
       ^^^^^^^^
  File "/home/lucasw/ros/ros1_ros_comm_catkin_make/src/ros_comm/utilities/roswtf/test/check_roswtf_command_line_online.py", line 120, in test_offline
    self._check_output([cmd], output.decode(), err.decode())
  File "/home/lucasw/ros/ros1_ros_comm_catkin_make/src/ros_comm/utilities/roswtf/test/check_roswtf_command_line_online.py", line 137, in _check_output
    self.assert_(

Don't set PYTHONPATH to use $DEST unless some other python install creates it? That only occurs locally, don't see that message in the github action

Experiment with docker 20.04 build and see if roswtf can be fixed

docker build . -f Dockerfile.2004_ppa -t ros_comm_2004_ppa
docker run -it -v `pwd`/..:/base_catkin_ws/src ros_comm_2004_ppa:latest /bin/bash
source devel/setup.bash
catkin_make run_tests_roswtf
stderr[Cannot find dependencies for package [roswtf]: missing rosmake
...

where is the rosmake dependency?

@lucasw
Copy link
Owner Author

lucasw commented Dec 28, 2023

  <failure message="Unable to find test results for gtest-test_base64.xml, test did not run.
Expected results in /home/lucasw/ros/ros1_ros_comm_catkin_make/build/test_results/xmlrpcpp/gtest-test_base64.xml" type=""/>
./devel/lib/xmlrpcpp/test_base64
...
[       OK ] Multiline/Base64ErrorTest.DecodeErrors/9 (0 ms)
[ RUN      ] Multiline/Base64ErrorTest.DecodeErrors/10
[       OK ] Multiline/Base64ErrorTest.DecodeErrors/10 (0 ms)
[ RUN      ] Multiline/Base64ErrorTest.DecodeErrors/11
Segmentation fault (core dumped)

The issue is that GetParam() encoded returns a blank stream (which it is supposed to), then the decoder segfaults on that (even though encoded_size is properly 0)

TEST_P(Base64ErrorTest, DecodeErrors) {
  const std::string& in = GetParam().encoded;
  // TODO(lucasw) in is '' which makes the decode fail- which ought to be fixed,
  // it shouldn't segfault on a zero length string
  const int encoded_size = in.length();

  // oversize our output vector (same method used by XmlRpcValue)
  std::vector<char> out;
  out.resize(encoded_size);

  std::cout << in << " " << encoded_size << "\n";
  base64::decoder decoder;
  const int size = decoder.decode(in.c_str(), encoded_size, out.data());
  // Assert that size is greater or equal to 0, to make sure that the follow-up
  // resize will always succeed.
  ASSERT_LE(0, size);
  out.resize(size);

  // FIXME(future work): decode does not report error on garbage input
}
...
                      // Decode should succeed and do nothing on empty string.
                      Base64ErrorData(""),
...

GetParam is from gtest

@lucasw
Copy link
Owner Author

lucasw commented Dec 29, 2023

Calling this done since https://github.com/lucasw/ros_comm/tree/salsa_noetic_aggregated is passing for both 20.04 and 22.04, but need to revisit the failing tests that were disabled

@lucasw
Copy link
Owner Author

lucasw commented Jun 9, 2024

Did a rebase that makes running tests work with python 3.12 (on Ubuntu 24.04), and using more gitlab ros_comm patches from https://salsa.debian.org/science-team/ros-ros-comm/-/tree/master/debian/patches now.

@lucasw lucasw reopened this Jun 9, 2024
@lucasw
Copy link
Owner Author

lucasw commented Jun 9, 2024

->

catkin_make run_tests_test_rospy_rostest_test_rostest_statistics.test
-        self.assertTrueeventually(
+        self.assertTrueEventually(

No that didn't fix it

-> assert_eventually()

@lucasw
Copy link
Owner Author

lucasw commented Jun 9, 2024

I think this has been deprecated

cannot import name 'assert_regexp_matches' from 'nose.tools'

@lucasw
Copy link
Owner Author

lucasw commented Jun 9, 2024

This never finishes, nosetest hangs:

rostest log file is in /home/lucasw/.ros/log/rostest-lucasw-XPS-8940-222371.log
-- run_tests.py: verify result "/home/lucasw/ros/ros1/tmp/catkin_make_ros_comm/build/test_results/test_rosbag/rostest-test_random_play.xml"
[100%] Built target _run_tests_test_rosbag_rostest_test_random_play.xml
[100%] Built target _run_tests_test_rosbag_rostest
[100%] Built target _run_tests_test_rosbag

No it was this one?

run_tests_roslaunch_nosetests_test

Running that standalone also never finishes


Maybe because this?

.../usr/lib/python3.12/unittest/case.py:580: RuntimeWarning: TestResult has no addDuration method

-> nose-devs/nose2#569 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant