Skip to content

fix: Failing service and subscription tests#1147

Merged
bjsowa merged 7 commits into
ros2from
fix/unadvertise-service-test
Feb 19, 2026
Merged

fix: Failing service and subscription tests#1147
bjsowa merged 7 commits into
ros2from
fix/unadvertise-service-test

Conversation

@bjsowa
Copy link
Copy Markdown
Member

@bjsowa bjsowa commented Feb 11, 2026

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.

@bjsowa bjsowa changed the title fix: Failing unadvertise service test fix: Failing service and subscription tests Feb 11, 2026
@bjsowa bjsowa requested a review from Copilot February 11, 2026 16:48
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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_request to 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.

Comment thread rosbridge_library/src/rosbridge_library/capabilities/advertise_service.py Outdated
Comment thread rosbridge_library/test/internal/subscribers/test_subscriber_manager.py Outdated
@bjsowa
Copy link
Copy Markdown
Member Author

bjsowa commented Feb 11, 2026

I've rerun the workflow 10 times, no more randomly failing tests... I hope.

@bjsowa bjsowa enabled auto-merge (squash) February 19, 2026 11:11
@bjsowa
Copy link
Copy Markdown
Member Author

bjsowa commented Feb 19, 2026

@MatthijsBurgh Could you approve the changes?

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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.

@bjsowa bjsowa merged commit 01387e1 into ros2 Feb 19, 2026
24 checks passed
@bjsowa bjsowa deleted the fix/unadvertise-service-test branch February 19, 2026 14:17
bjsowa added a commit that referenced this pull request Feb 19, 2026
* 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
MatthijsBurgh pushed a commit that referenced this pull request Feb 19, 2026
* 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
bjsowa added a commit that referenced this pull request Feb 21, 2026
bjsowa added a commit that referenced this pull request Feb 22, 2026
* 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
bjsowa added a commit that referenced this pull request Feb 22, 2026
* 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
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