fix: autoware_test_manager:Fix flaky No subscriber for <topic> failure#1181
fix: autoware_test_manager:Fix flaky No subscriber for <topic> failure#1181liuXinGangChina wants to merge 2 commits into
Conversation
|
Thank you for contributing to the Autoware project! 🚧 If your pull request is in progress, switch it to draft mode. Please ensure:
|
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1181 +/- ##
==========================================
+ Coverage 60.38% 61.98% +1.60%
==========================================
Files 422 416 -6
Lines 25149 24442 -707
Branches 11911 11824 -87
==========================================
- Hits 15185 15150 -35
+ Misses 6999 6684 -315
+ Partials 2965 2608 -357
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
2ed08b2 to
cb324c0
Compare
There was a problem hiding this comment.
Pull request overview
This PR reduces CI flakiness in autoware_planning_test_manager tests by making topic discovery/subscriber matching more robust before publishing, and by ensuring ROS context lifecycle is handled reliably even when a test fails.
Changes:
- Add a bounded spin/wait loop in
publishToTargetNode()to wait for subscriber discovery before publishing. - Introduce a
PlanningTestManagerTestgtest fixture that managesrclcpp::init()/rclcpp::shutdown()viaSetUp()/TearDown(). - Convert affected tests from
TEST()toTEST_F()to use the fixture.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| testing/autoware_test_utils/include/autoware_test_utils/autoware_test_utils.hpp | Waits for subscriber discovery before publishing to avoid DDS discovery races and dropped messages under volatile QoS. |
| testing/autoware_planning_test_manager/test/test_planning_test_manager.cpp | Uses a fixture to ensure ROS context shutdown happens even when a test fails mid-body. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| while (rclcpp::ok() && (std::chrono::steady_clock::now() - start) < kTimeout) { | ||
| if (target_node->count_subscribers(topic_name) > 0) { | ||
| break; | ||
| } | ||
| rclcpp::spin_some(test_node); | ||
| rclcpp::spin_some(target_node); | ||
| std::this_thread::sleep_for(kWaitInterval); | ||
| } |
3180766 to
af211b1
Compare
…s in autoware_planning_test_manager CI tests (closes autowarefoundation#1177) Signed-off-by: liuXinGangChina <lxg19892021@gmail.com>
af211b1 to
cb74e3c
Compare
Description
Fix flaky
No subscriber for <topic>failures inautoware_planning_test_managerCI tests.Two causes are addressed:
1. Race condition in
publishToTargetNode()autoware_test_utils.hpp:565-571publishes a message and then immediately checkscount_subscribers()once. DDS graph discovery is asynchronous — when the subscription is created moments earlier bysubscribeOutput(), the node's graph cache may not yet reflect it. On loaded CI runners discovery can lag, causing a false-negativeNo subscriberexception. Publishing before confirming the subscription also means the message is dropped under volatile QoS.Fix: replace the single
count_subscribers()check with a spin/wait loop (5s timeout, 100ms interval) that actively drives DDS discovery, and publish only after the subscription is confirmed.2. No RAII guard for
rclcpp::init/rclcpp::shutdownEach
TEST()body manually callsrclcpp::init()andrclcpp::shutdown(). When the exception from (1) is thrown,shutdown()is skipped, leaving the ROS context initialized. All subsequent tests then fail withcontext is already initialized.Fix: introduce a
PlanningTestManagerTestfixture withSetUp/TearDownmanaging the ROS context lifecycle, and convertTEST()→TEST_F().Related links
Parent Issue:
How was this PR tested?
Built and tested in official core development Docker images:
ghcr.io/autowarefoundation/autoware:core-devel-jazzyNotes for reviewers
autoware_test_utilsis a shared testing library. FixingpublishToTargetNode()in the helper eliminates the same race for all downstream packages that use it.Interface changes
None.
Effects on system behavior
None.