-
Notifications
You must be signed in to change notification settings - Fork 162
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ros2lifecycle] Add test coverage for CLI #391
Conversation
Well, tests failed because I didn't push a local fix in |
assert lifecycle_command.wait_for_shutdown(timeout=10) | ||
assert lifecycle_command.exit_code == launch_testing.asserts.EXIT_OK | ||
assert launch_testing.tools.expect_output( | ||
expected_lines=ALL_LIFECYCLE_NODE_TRANSITIONS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should not return any transition since you didn't give the --include-hidden-nodes
argument
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's true, which makes me wonder how's this test passing. Looks like ros2 lifecycle list
is simply ignoring the --include-hidden-nodes
flag:
ros2cli/ros2lifecycle/ros2lifecycle/verb/list.py
Lines 43 to 64 in 9ce402d
def main(self, *, args): # noqa: D102 | |
with NodeStrategy(args) as node: | |
node_names = get_node_names( | |
node=node, include_hidden_nodes=args.include_hidden_nodes) | |
with DirectNode(args) as node: | |
if args.all: | |
transitions = call_get_transition_graph( | |
node=node, states={args.node_name: None}) | |
else: | |
transitions = call_get_available_transitions( | |
node=node, states={args.node_name: None}) | |
transitions = transitions[args.node_name] | |
if isinstance(transitions, Exception): | |
return 'Exception while calling service of node ' \ | |
"'{args.node_name}': {transitions}" \ | |
.format_map(locals()) | |
for t in transitions: | |
print( | |
'- {t.transition.label} [{t.transition.id}]\n' | |
'\tStart: {t.start_state.label}\n' | |
'\tGoal: {t.goal_state.label}'.format_map(locals())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #395.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test fixed in fc5977c.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make the same tests but without the hidden flag? To ensure the proper functionality of the flag (I'm seeing that it will work, but just in case)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in eb2f8d3
|
||
@launch_testing.markers.retry_on_failure(times=5) | ||
def test_count_all_lifecycle_nodes(self): | ||
with self.launch_lifecycle_command(arguments=['nodes', '-a', '-c']) as lifecycle_command: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a test counting without the -a flag checking that it doesn't count the hidden node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in fc5977c
ros2lifecycle/test/test_cli.py
Outdated
@launch_testing.markers.retry_on_failure(times=5) | ||
def test_set_lifecycle_node_invalid_transition(self): | ||
with self.launch_lifecycle_command( | ||
arguments=['set', '/lc_node', 'noop'] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add another test by checking a valid set
without the hidden flag with the hidden node
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in fc5977c.
ros2lifecycle/test/test_cli.py
Outdated
) | ||
|
||
@launch_testing.markers.retry_on_failure(times=5) | ||
def test_get_nonexistent_node_state(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There should be a get without the hidden flag checking for a hidden node test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, there's no get
test valid. It's coupled with the test_node_lifecycle
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added in fc5977c. It's a bit annoying to not have proper fixture scoping.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some tests that need to be added
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
…kage. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
67ea30a
to
fc5977c
Compare
@BMarchi thank you for your review! PTAL and sorry for the rebase, I had to pull in CLI fixes. |
ros2lifecycle/package.xml
Outdated
@@ -20,7 +20,10 @@ | |||
<test_depend>ament_flake8</test_depend> | |||
<test_depend>ament_pep257</test_depend> | |||
<test_depend>ament_xmllint</test_depend> | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any particular reason for this newline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not really, fixed in eb2f8d3
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@Karsten1987 want to review? Otherwise, I'll merge |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More tests! 🎊
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a nit, but looks good to me.
|
||
rclcpp::init(argc, argv); | ||
|
||
auto lc_node = std::make_shared<SimpleLifecycleNode>("lc_node"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth renaming the node to something more specific (and different from the lifecycle talker exec in the lifecycle
demo package).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I use "simple_lc_node"
on launch
, does that sound reasonable? Or would you rather be more specific?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's okay I guess. I personally like to prefix them with test
or the name of the test package in this case, but either way is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See 046d82c
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Alright, going in! |
* Add test coverage for ros2lifecycle CLI. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Add ros2lifecycle_test_fixtures package. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Use ros2lifecycle_test_fixtures package instead of demo lifecycle package. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Add a few more ros2lifecycle test cases. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Address last few peer review comments. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com> * Rename ros2lifecycle tests fixture node. Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Precisely what the title says. This pull requests adds integration for each and every
ros2 lifecycle
verb.It current depends on thelifecycle
package in theros2/demos
repository, creating a circular repo dependency. Fixture nodes must be duplicated and relocated, maybe simplifying these in the process.