Skip to content
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

Merged
merged 6 commits into from
Nov 12, 2019
Merged

Conversation

hidmic
Copy link
Contributor

@hidmic hidmic commented Nov 5, 2019

Precisely what the title says. This pull requests adds integration for each and every ros2 lifecycle verb.

It current depends on the lifecycle package in the ros2/demos repository, creating a circular repo dependency. Fixture nodes must be duplicated and relocated, maybe simplifying these in the process.

@hidmic hidmic changed the title [DO NOT MERGE] Add test coverage for ros2lifecycle CLI Add test coverage for ros2lifecycle CLI Nov 5, 2019
@hidmic
Copy link
Contributor Author

hidmic commented Nov 5, 2019

CI up to ros2lifecycle:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@hidmic hidmic changed the title Add test coverage for ros2lifecycle CLI [ros2lifecycle] Add test coverage for CLI Nov 6, 2019
@hidmic
Copy link
Contributor Author

hidmic commented Nov 6, 2019

Well, tests failed because I didn't push a local fix in launch. See ros2/launch#353.

@hidmic
Copy link
Contributor Author

hidmic commented Nov 6, 2019

CI up to ros2lifecycle:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

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,
Copy link
Contributor

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

Copy link
Contributor Author

@hidmic hidmic Nov 11, 2019

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:

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()))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

See #395.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Test fixed in fc5977c.

Copy link
Contributor

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)

Copy link
Contributor Author

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:
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in fc5977c

@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']
Copy link
Contributor

@BMarchi BMarchi Nov 11, 2019

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added in fc5977c.

)

@launch_testing.markers.retry_on_failure(times=5)
def test_get_nonexistent_node_state(self):
Copy link
Contributor

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

Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

@BMarchi BMarchi left a 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>
@hidmic
Copy link
Contributor Author

hidmic commented Nov 11, 2019

@BMarchi thank you for your review! PTAL and sorry for the rebase, I had to pull in CLI fixes.

@hidmic
Copy link
Contributor Author

hidmic commented Nov 11, 2019

CI up to ros2lifecycle:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • macOS Build Status
  • Windows Build Status

@@ -20,7 +20,10 @@
<test_depend>ament_flake8</test_depend>
<test_depend>ament_pep257</test_depend>
<test_depend>ament_xmllint</test_depend>

Copy link
Contributor

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?

Copy link
Contributor Author

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>
@hidmic
Copy link
Contributor Author

hidmic commented Nov 11, 2019

@Karsten1987 want to review? Otherwise, I'll merge

Copy link
Member

@mjcarroll mjcarroll left a comment

Choose a reason for hiding this comment

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

More tests! 🎊

Copy link
Contributor

@Karsten1987 Karsten1987 left a 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");
Copy link
Contributor

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).

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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>
@hidmic
Copy link
Contributor Author

hidmic commented Nov 12, 2019

One last sanity CI run up to ros2lifecycle:

  • Linux Build Status

@hidmic
Copy link
Contributor Author

hidmic commented Nov 12, 2019

Alright, going in!

@hidmic hidmic merged commit 40a7d99 into master Nov 12, 2019
@delete-merged-branch delete-merged-branch bot deleted the hidmic/ros2lifecycle-tests branch November 12, 2019 19:13
jaisontj pushed a commit to aws-ros-dev/ros2cli that referenced this pull request Nov 14, 2019
* 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>
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.

4 participants