tier4 / nebula

A universal LiDAR and radar driver for ROS 2, supporting Hesai, Velodyne, Robosense and Continental sensors.
https://tier4.github.io/nebula/
Apache License 2.0
55 stars 53 forks source link

test(hesai): dependency-injectable TCP socket, HW interface testability #234

Open mojomex opened 4 days ago

mojomex commented 4 days ago

PR Type

Related Links

Description

:warning: #231, #232, #233 have to be merged before this :warning:

Previously, testing Nebula's HW interfaces has been difficult because all hardware drivers were hard-coded. This meant that during test time, a real network connection would have to be used, or, that LD_PRELOAD or macro trickery had to be used.

This PR adds a dependency-injectable TCP socket implementation (currently just a wrapper around transport_drivers), which allows mocking the TCP socket at test time.

Since the TCP socket is still very Hesai-specific, I have added the new socket and refactored it into nebula_ros and nebula_hw_interfaces_hesai already.

Basic unit tests to prove testability have been added. More will be added in a future PR.

Review Procedure

Remarks

Pre-Review Checklist for the PR Author

PR Author should check the checkboxes below when creating the PR.

Checklist for the PR Reviewer

Reviewers should check the checkboxes below before approval.

Post-Review Checklist for the PR Author

PR Author should check the checkboxes below before merging.

CI Checks

codecov[bot] commented 4 days ago

Codecov Report

Attention: Patch coverage is 50.83333% with 177 lines in your changes missing coverage. Please review.

Project coverage is 27.52%. Comparing base (47efeed) to head (81ad961).

Files with missing lines Patch % Lines
.../nebula_hesai_hw_interfaces/hesai_hw_interface.cpp 13.79% 50 Missing :warning:
...es/nebula_hw_interfaces_common/connections/udp.hpp 60.83% 24 Missing and 23 partials :warning:
nebula_hw_interfaces/test/common/test_udp.cpp 63.51% 7 Missing and 20 partials :warning:
...ces/nebula_hw_interfaces_hesai/connections/tcp.hpp 0.00% 20 Missing :warning:
...la_ros/include/nebula_ros/common/rclcpp_logger.hpp 0.00% 16 Missing :warning:
...n/include/nebula_common/loggers/console_logger.hpp 0.00% 8 Missing :warning:
...ebula_hw_interfaces/test/common/test_udp/utils.hpp 84.00% 0 Missing and 4 partials :warning:
nebula_ros/src/hesai/hw_interface_wrapper.cpp 0.00% 3 Missing :warning:
...ula_hw_interfaces/test/hesai/test_ptc/ptc_test.hpp 87.50% 1 Missing :warning:
...ula_hw_interfaces/test/hesai/test_ptc/tcp_mock.hpp 75.00% 1 Missing :warning:
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #234 +/- ## ========================================== + Coverage 26.10% 27.52% +1.42% ========================================== Files 100 109 +9 Lines 9218 9481 +263 Branches 2215 2770 +555 ========================================== + Hits 2406 2610 +204 - Misses 6423 6433 +10 - Partials 389 438 +49 ``` | [Flag](https://app.codecov.io/gh/tier4/nebula/pull/234/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tier4) | Coverage Δ | | |---|---|---| | [differential](https://app.codecov.io/gh/tier4/nebula/pull/234/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tier4) | `27.52% <50.83%> (?)` | | | [total](https://app.codecov.io/gh/tier4/nebula/pull/234/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tier4) | `?` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tier4#carryforward-flags-in-the-pull-request-comment) to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.


🚨 Try these New Features: