fix: Failing service and subscription tests#1147
Conversation
There was a problem hiding this comment.
Pull request overview
Updates rosbridge_library tests and service-advertisement handling to align with recent rclpy coroutine/exception propagation behavior, fixing previously failing service and subscription-related tests.
Changes:
- Replace fixed sleeps in subscriber tests with polling assertions for subscribed/unsubscribed state.
- Update
test_unadvertise_with_live_requestto assert timeout behavior for in-flight requests and immediate rejection for subsequent calls. - Add error logging for exceptions while awaiting advertised-service responses and adjust service teardown to use
node_handle.destroy_service(...).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| rosbridge_library/test/internal/subscribers/test_subscriber_manager.py | Adds polling-based subscription assertions and updates tests to use them instead of direct checks. |
| rosbridge_library/test/internal/subscribers/test_multi_subscriber.py | Adds the same polling-based assertions and updates multi-subscriber tests accordingly. |
| rosbridge_library/test/capabilities/test_service_capabilities.py | Adjusts service timeout behavior and updates unadvertise-with-inflight-request expectations. |
| rosbridge_library/src/rosbridge_library/capabilities/advertise_service.py | Logs exceptions while awaiting responses and changes service destruction mechanism during shutdown. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I've rerun the workflow 10 times, no more randomly failing tests... I hope. |
|
@MatthijsBurgh Could you approve the changes? |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 5 out of 5 changed files in this pull request and generated no new comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
* Add error logging when service is unadvertised during in-flight request * Fix service destruction method in AdvertisedServiceHandler * Fix unadvertise service test * Try to fix failing topic subscription assertions by adding a timeout * Remove redundant sleeps * Remove extra call to destroy service after graceful shutdown * Re-raise original exception in handle_request
* Add error logging when service is unadvertised during in-flight request * Fix service destruction method in AdvertisedServiceHandler * Fix unadvertise service test * Try to fix failing topic subscription assertions by adding a timeout * Remove redundant sleeps * Remove extra call to destroy service after graceful shutdown * Re-raise original exception in handle_request
* Add error logging when service is unadvertised during in-flight request * Fix service destruction method in AdvertisedServiceHandler * Fix unadvertise service test * Try to fix failing topic subscription assertions by adding a timeout * Remove redundant sleeps * Remove extra call to destroy service after graceful shutdown * Re-raise original exception in handle_request
* fix: Failing service and subscription tests (backport #1147) * Add error logging when service is unadvertised during in-flight request * Fix service destruction method in AdvertisedServiceHandler * Fix unadvertise service test * Try to fix failing topic subscription assertions by adding a timeout * Remove redundant sleeps * Remove extra call to destroy service after graceful shutdown * Re-raise original exception in handle_request * fix: Suppress RuntimeError during rclpy spin in service capabilities tests
Public API Changes
None
Description
Recent changes related to coroutines in rclpy (ros2/rclpy#1469) fixed (at least partially) exception propagation. Executor no longer throws an exception when the service handler awaits a future that resulted in exception (this is a good thing). This, however, uncovered another problem with the test as it falsy expects to receive a message after sending
unadvertise_service.This PR fixes the test and adds a comment explaining current limitations of the implementation.
EDIT: Also modified the subscription asserts to add a timeout. This should hopefully fix the flaky tests.