Skip to content

Properly test get_service_names_and_types_by_node in rclcpp_lifecycle#2599

Merged
christophebedard merged 1 commit intorollingfrom
christophebedard/fix-test-lifecycle-service-client-get-names-and-types-by-node
Aug 8, 2024
Merged

Properly test get_service_names_and_types_by_node in rclcpp_lifecycle#2599
christophebedard merged 1 commit intorollingfrom
christophebedard/fix-test-lifecycle-service-client-get-names-and-types-by-node

Conversation

@christophebedard
Copy link
Copy Markdown
Member

@christophebedard christophebedard commented Aug 7, 2024

The current TestLifecycleServiceClient.get_service_names_and_types_by_node test was using LifecycleServiceClient, which is just a normal rclcpp::Node with some rclcpp::Clients, to test NodeGraph::get_service_names_and_types_by_node(). However, NodeGraph::get_service_names_and_types_by_node() is for service servers, not clients. The test just ended up checking the built-in services of an rclcpp::Node, since it wasn't actually checking the names of the services, and not checking the clients of the LifecycleServiceClient or the built-in services of a rclcpp_lifecycle::LifecycleNode. I believe this was probably not the intention, since this is an rclcpp_lifecycle test.

Instead, use an actual rclcpp_lifecycle::LifecycleNode and check its service servers by calling
NodeGraph::get_service_names_and_types_by_node() through LifecycleNode::get_service_names_and_types_by_node().

@christophebedard christophebedard self-assigned this Aug 7, 2024
@christophebedard christophebedard marked this pull request as ready for review August 7, 2024 20:47
@christophebedard christophebedard force-pushed the christophebedard/fix-test-lifecycle-service-client-get-names-and-types-by-node branch 2 times, most recently from 3d43045 to d2c5a49 Compare August 7, 2024 21:11
@christophebedard
Copy link
Copy Markdown
Member Author

christophebedard commented Aug 7, 2024

I thought that maybe this should instead test NodeGraph::get_client_names_and_types_by_node(), but it was added in #1484 after this test was added in #1240, and it's not exposed through rclcpp_lifecycle::LifecycleNode. Also, as I mentioned in the PR description, I think this is meant to check the built-in services of an rclcpp_lifecycle::LifecycleNode.

@Barry-Xu-2018
Copy link
Copy Markdown
Collaborator

A small suggestion. The current test code only checks whether LifecycleNode::get_service_names_and_types_by_node() is called successfully. Should we pick services (such as /lc_talker/get_state, /lc_talker/change_state) to check if their names exist and their types are correct ?

@christophebedard christophebedard force-pushed the christophebedard/fix-test-lifecycle-service-client-get-names-and-types-by-node branch 2 times, most recently from 2e86fc6 to 6221368 Compare August 8, 2024 17:35
@christophebedard
Copy link
Copy Markdown
Member Author

good idea, done.

The current
`TestLifecycleServiceClient.get_service_names_and_types_by_node` test
was using `LifecycleServiceClient`, which is just a normal
`rclcpp::Node` with some `rclcpp::Client`s, to test
`NodeGraph::get_service_names_and_types_by_node()`. However,
`NodeGraph::get_service_names_and_types_by_node()` is for service
servers, not clients. The test just ended up checking the built-in
services of an `rclcpp::Node`, since it wasn't actually checking the
names of the services, and not checking the clients of the
`LifecycleServiceClient` or the built-in services of a
`rclcpp_lifecycle::LifecycleNode`. I believe this was probably not the
intention, since this is an `rclcpp_lifecycle` test.

Instead, use an actual `rclcpp_lifecycle::LifecycleNode` and check its
service servers by calling
`NodeGraph::get_service_names_and_types_by_node()` through
`LifecycleNode::get_service_names_and_types_by_node()`.

Signed-off-by: Christophe Bedard <christophe.bedard@apex.ai>
@christophebedard christophebedard force-pushed the christophebedard/fix-test-lifecycle-service-client-get-names-and-types-by-node branch from 6221368 to cccc995 Compare August 8, 2024 17:48
Copy link
Copy Markdown
Collaborator

@fujitatomoya fujitatomoya left a comment

Choose a reason for hiding this comment

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

lgtm with green CI

@christophebedard
Copy link
Copy Markdown
Member Author

  • Linux Build Status
  • Linux-aarch64 Build Status
  • Linux-rhel Build Status
  • Windows Build Status

@christophebedard christophebedard merged commit ab7cf87 into rolling Aug 8, 2024
@christophebedard christophebedard deleted the christophebedard/fix-test-lifecycle-service-client-get-names-and-types-by-node branch August 8, 2024 20:01
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

Successfully merging this pull request may close these issues.

3 participants