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

Fixed wait set test on zenoh #2644

Open
wants to merge 1 commit into
base: rolling
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions rclcpp/test/rclcpp/test_wait_set.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,10 @@ TEST_F(TestWaitSet, add_guard_condition_to_two_different_wait_set) {
}, std::runtime_error);

rclcpp::PublisherOptions po;
po.event_callbacks.deadline_callback = [](rclcpp::QOSDeadlineOfferedInfo &) {};
std::string rmw_implementation_str = std::string(rmw_get_implementation_identifier());
if (rmw_implementation_str != "rmw_zenoh_cpp") {
po.event_callbacks.deadline_callback = [](rclcpp::QOSDeadlineOfferedInfo &) {};
}
Comment on lines +263 to +266
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ahcorde i am not really sure what needs to be avoided here... what happens if this if statement is not there, exception? and this is user application does to configure PublisherOptions, that means just switching rmw would break the user application?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe if we run this test with rmw_zenoh, an exception will be thrown when rcl will initialize a liveliness or deadline event since we don't support this yet. This happens when we set certain event callbacks in pub/sub options which internally invoke rmw_publisher_event_init/rmw_subscription_event_init. See below.

108: C++ exception with description "Failed to initialize event: provided event_type 7 is not supported by rmw_zenoh_cpp, at /home/yadunund/ros2_rolling/src/ros2/rmw_zenoh/rmw_zenoh_cpp/src/rmw_event.cpp:60" thrown in the test body.

Having said that I think the way to address this would be to set the matched or qos_incompatible callbacks for po.event_callbacks and subscription_options.event_callbacks. instead of the liveliness or deadlines one if rmw_implementation_str == "rmw_zenoh_cpp"

auto pub = node->create_publisher<test_msgs::msg::BasicTypes>("~/test", 1, po);
auto qos_event = pub->get_event_handlers().begin()->second;
wait_set1.add_waitable(qos_event, pub);
Expand All @@ -276,6 +279,8 @@ TEST_F(TestWaitSet, add_guard_condition_to_two_different_wait_set) {
* Testing adding each entity and waiting, and removing each entity and waiting
*/
TEST_F(TestWaitSet, add_remove_wait) {
std::string rmw_implementation_str = std::string(rmw_get_implementation_identifier());

rclcpp::WaitSet wait_set;
auto node = std::make_shared<rclcpp::Node>("add_remove_wait");

Expand All @@ -284,8 +289,10 @@ TEST_F(TestWaitSet, add_remove_wait) {

// For coverage reasons, this subscription should have event handlers
rclcpp::SubscriptionOptions subscription_options;
subscription_options.event_callbacks.deadline_callback = [](auto) {};
subscription_options.event_callbacks.liveliness_callback = [](auto) {};
if (rmw_implementation_str != "rmw_zenoh_cpp") {
subscription_options.event_callbacks.deadline_callback = [](auto) {};
subscription_options.event_callbacks.liveliness_callback = [](auto) {};
}
auto do_nothing = [](std::shared_ptr<const test_msgs::msg::BasicTypes>) {};
auto sub =
node->create_subscription<test_msgs::msg::BasicTypes>(
Expand All @@ -302,8 +309,10 @@ TEST_F(TestWaitSet, add_remove_wait) {
node->create_service<rcl_interfaces::srv::ListParameters>("~/test", srv_do_nothing);

rclcpp::PublisherOptions publisher_options;
publisher_options.event_callbacks.deadline_callback =
[](rclcpp::QOSDeadlineOfferedInfo &) {};
if (rmw_implementation_str != "rmw_zenoh_cpp") {
publisher_options.event_callbacks.deadline_callback =
[](rclcpp::QOSDeadlineOfferedInfo &) {};
}
auto pub = node->create_publisher<test_msgs::msg::BasicTypes>(
"~/test", 1, publisher_options);
auto qos_event = pub->get_event_handlers().begin()->second;
Expand Down