Add test_utils file for transition tests#3048
Add test_utils file for transition tests#3048christophfroehlich wants to merge 7 commits intomasterfrom
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #3048 +/- ##
==========================================
+ Coverage 89.35% 89.36% +0.01%
==========================================
Files 158 160 +2
Lines 19392 19538 +146
Branches 1573 1576 +3
==========================================
+ Hits 17327 17460 +133
- Misses 1419 1428 +9
- Partials 646 650 +4
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
jsantoso91
left a comment
There was a problem hiding this comment.
Looks good to me, I looked at the design document for the lifecycle found here
https://design.ros2.org/articles/node_lifecycle.html
There are some discrepancies (mentioned in the line comments) for deactivate and cleanup transitions, but since test cases written for these are passing I assume it is just the issue of outdated documentation.
| { | ||
| case State::PRIMARY_STATE_INACTIVE: | ||
| return true; | ||
| case State::PRIMARY_STATE_ACTIVE: |
There was a problem hiding this comment.
Based on the design document found here https://design.ros2.org/articles/node_lifecycle.html
There is no explicit transition for onDeactivate[FAILURE], but since the test case you wrote for this one seems to PASS I assume the document is the outdated one and the behavior ACTIVE STATE -> Deactivate [Failed] -> ACTIVE STATE is expected.
There was a problem hiding this comment.
there are three return types of the transition callbacks:
https://github.com/ros2/rclcpp/blob/b6e9b4c9b48c48eae09ab79d7b2d4ef95e6c4653/rclcpp_lifecycle/include/rclcpp_lifecycle/node_interfaces/lifecycle_node_interface.hpp#L56-L61
As far as I understood it:
- error: onError transition is called
- failure: no transition is performed (staying in old state).
Here this means that after failure in on_deactivate, it will stay in active mode.
There was a problem hiding this comment.
Thank you for sharing the link.
I guess it makes sense when the state transition fails (and no error is thrown), that the state will stay where it is.
| { | ||
| case State::PRIMARY_STATE_UNCONFIGURED: | ||
| return true; | ||
| case State::PRIMARY_STATE_INACTIVE: |
There was a problem hiding this comment.
Based on the design document found here https://design.ros2.org/articles/node_lifecycle.html
There is no explicit transition for onCleanup[FAILURE], but since the test case you wrote for this one seems to PASS I assume the document is the outdated one and the behavior INACTIVE STATE -> Cleanup [Failed] -> INACTIVE STATE is expected.
There was a problem hiding this comment.
same here, if transition fails it stays in inactive
| case State::PRIMARY_STATE_FINALIZED: | ||
| return true; | ||
| default: | ||
| // if transition returns error or failure, it will anyways end up in the finalized state |
There was a problem hiding this comment.
Is this comment accurate? Based on the diagram included in https://design.ros2.org/articles/node_lifecycle.html
Suppose error is raised during onShutdown() then state will go to ErrorProcessing and further to Unconfigured or Finalized depending on the success/failure of onError.
There was a problem hiding this comment.
this caused some headache, but this was the result of playing around with the tests.
The diagram also shows no [SUCCESS] condition for the shutdown.
There was a problem hiding this comment.
I think you meant to say "The diagram also shows no [FAILURE] condition for the shutdown" ?
I think a more accurate comment for the default branch (at least based on the lifecycle diagram) would be
"if transition returns error, the state will end up in the Unconfigured or Finalized depending on the success/failure of onError"
jsantoso91
left a comment
There was a problem hiding this comment.
Suggested comment change for L157:
"if transition returns error, the state will end up in the Unconfigured or Finalized depending on the success/failure of onError"
Looks good otherwise.
ros-controls/ros2_controllers#1682