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

Make use of ros_testing to test policy generation. #214

Merged
merged 9 commits into from
Jun 21, 2020

Conversation

hidmic
Copy link
Contributor

@hidmic hidmic commented May 14, 2020

This pull request combines #168 and #212 to increase test coverage and reduces test flakiness for sros2 generate_policy verb.

@codecov
Copy link

codecov bot commented May 14, 2020

Codecov Report

Merging #214 into master will increase coverage by 0.17%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #214      +/-   ##
==========================================
+ Coverage   77.95%   78.12%   +0.17%     
==========================================
  Files          16       16              
  Lines         576      576              
  Branches       52       52              
==========================================
+ Hits          449      450       +1     
+ Misses        107      106       -1     
  Partials       20       20              
Flag Coverage Δ
#unittests 78.12% <ø> (+0.17%) ⬆️
Impacted Files Coverage Δ
sros2/sros2/__init__.py 77.77% <0.00%> (+11.11%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef62301...b2a8bcb. Read the comment docs.

@hidmic
Copy link
Contributor Author

hidmic commented May 15, 2020

Both test_nightly CI jobs are failing because librmw_connext_cpp.so cannot be found. I can only guess why the focal PR job failed, it seems like discovery latency to me. Bumped spin times from 1.0 to 2.0 seconds.

@mikaelarguedas
Copy link
Member

Both test_nightly CI jobs are failing because librmw_connext_cpp.so cannot be found.

Noticed this too and confirmed that using an image with connext installed will fix the failing test: https://github.com/ros2/sros2/runs/677227888.

Copy link
Member

@mikaelarguedas mikaelarguedas left a comment

Choose a reason for hiding this comment

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

that's great improvement thanks!

Looks great, left a couple nitpick comments inline

@@ -0,0 +1,63 @@
# Copyright 2019 Canonical Ltd
# Copyright 2020 Open Source Robotics Foundation, Inc.
Copy link
Member

Choose a reason for hiding this comment

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

File has multiple copyright statements but no history

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's a very good point. It is work derived from a source file that was originally developed by Canonical. Do tell how we should proceed with this.

Copy link
Member

Choose a reason for hiding this comment

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

Should it actually share git history with another file? Or is it more of a "I copied that file and turned it into something else" situation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's a modified copy of test_generate_policy.py.

sros2/package.xml Show resolved Hide resolved
import test_msgs.srv


class ClientServiceNode(Node):
Copy link
Member

@kyrofa kyrofa May 15, 2020

Choose a reason for hiding this comment

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

Can this (and other similar constructs) be turned into an actual pytest fixture on a conftest.py somewhere?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Short answer is no, because test_generate_policy*.py is no longer a pytest, but a pytest-run launch test.

])


class SROS2CLITestCase(unittest.TestCase):
Copy link
Member

Choose a reason for hiding this comment

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

The existing tests in this project are all pytest. Why are we using unittest here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because test_generate_policy*.py is no longer a pytest, but a pytest-run launch test. And launch_testing is built on top of unittest. There's a desire to achieve a stronger integration between launch_testing and pytest (even turning the former into a plugin for the latter, see ros2/launch#405), but as of today, we can only include launch tests in pytest runs.

Copy link
Member

Choose a reason for hiding this comment

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

Alright, thank you for explaining. I really dislike mixing the two, here. It's complicated enough having both of them in existence and sharing space in my head-- having them both used in the same project will cause no end of confusion. Is there any other way to do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There's not, assuming that testing against multiple RMW implementations is a requirement (I understand it is based on #212 (comment)) and that we're not looking forward to recreate launch and launch_testing using subprocess and pytest just for this one test. I'd rather not do that.

@hidmic
Copy link
Contributor Author

hidmic commented May 19, 2020

CI up to sros2 and test_security:

@hidmic
Copy link
Contributor Author

hidmic commented May 29, 2020

I'm not happy with 3e1bc39, for a few different reasons. But I'm unable to reproduce Windows CI failures in a Windows VM. CC @jacobperron

BMarchi and others added 2 commits June 1, 2020 13:26
Signed-off-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>
Co-authored-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic hidmic force-pushed the hidmic/improve-sros2-generate-policy-tests branch from 09dcdf9 to c68f0a0 Compare June 1, 2020 16:26
@hidmic
Copy link
Contributor Author

hidmic commented Jun 1, 2020

Alright, I corrected the commit history to pass DCO and make sense. CI's green, though tests are being skipped on Windows. FYI @mikaelarguedas @kyrofa. @jacobperron how shall we proceed?

@mikaelarguedas
Copy link
Member

Regarding the move away from pytest and mixing unittest and pytest in the same package, I'm not a fan but it wouldn't be a blocker for me.

However, the fact that this seems to have pretty consistently failed CI on this repo makes me doubt this is having the intended effect of reducing flakeyness. So IMO it can't be merged as is.

I was hoping that the flakeyness was due to adding connext into the mix but several failing tests seem to be related to fastrtps(static or dynamic) so it connext doesn't seem to be the culprit.

We could scale back this to just provide a single RMW with daemon and "long" discovery time. if that proves to reduce flakeyness I'm in favor of merging that as it'll keep covering the cases users will face when using the CLI while improving CI stability.

@hidmic
Copy link
Contributor Author

hidmic commented Jun 3, 2020

I have to circle back and see what's happening with Fast-RTPS now. In all cases, however, the issue (it seems) remains to be discovery latency. Testing with and without a daemon and against multiple RMW implementations only made it more visible.

I agree that to merge as-is isn't viable. I'm not sure I'd test less either just to get jobs to pass. Maybe we need to start ensuring preconditions (in this case, ROS graph state) hold instead of hoping they will within an arbitrary timeout.

This reverts commit c68f0a0.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Contributor Author

hidmic commented Jun 10, 2020

One last try with 1a15522.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Contributor Author

hidmic commented Jun 10, 2020

Let's see how this fares on Windows:

  • Windows Build Status

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Contributor Author

hidmic commented Jun 11, 2020

Had to bump up the timeout for ros2 security generate_policy execution. I've seen it taking ~13 seconds on a pretty much idle Windows Server VM.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Contributor Author

hidmic commented Jun 11, 2020

Ok, b2a8bcb is almost insane. Those that timeout are the ones that use the daemon, and so they have the added overhead of XMLRPC calls. Still, it's ridiculous.

@hidmic
Copy link
Contributor Author

hidmic commented Jun 12, 2020

CI up to sros2 and test_security:

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

@mikaelarguedas @kyrofa PTAL, I think I've managed to remove most flakiness sources. I'm a bit baffled though by the time it takes the verb to complete in Windows.

@dirk-thomas dirk-thomas removed their request for review June 15, 2020 05:56
@mikaelarguedas
Copy link
Member

Ok, b2a8bcb is almost insane. Those that timeout are the ones that use the daemon, and so they have the added overhead of XMLRPC calls. Still, it's ridiculous.

This seems indeed incredible that it takes more than 20seconds to get the accurate state of a graph with 1 node and one Publisher/Subscriber pair... Is the same happening for other tests doing similar things ? or is there something wrong with the way testing is done here ?

I think I've managed to remove most flakiness sources.

As far as CI goes on this repo the latest iterations of this PR seem to yield only green jobs which is a big improvement compared to last review 👍

@hidmic
Copy link
Contributor Author

hidmic commented Jun 15, 2020

Is the same happening for other tests doing similar things ? or is there something wrong with the way testing is done here ?

I think almost all CLI tests are disabled on Windows due to ros2/build_farmer#248.

At any rate, as I mentioned in #214 (comment), I do see ros2 security generate_policy taking 10-15 seconds on a Windows VM by calling it manually. Not sure where those extra 10 seconds come from in CI

@mikaelarguedas
Copy link
Member

I do see ros2 security generate_policy taking 10-15 seconds on a Windows VM by calling it manually

I missed that bit. This seems very long too.. On linux its more on the second scale.

I'm +1 for this change as it increases use cases covered, does not degrade CI here and (IIUC) decreases CI flakyness on ci.ros2.org.

I'll leave it up to @kyrofa for the second review

@hidmic
Copy link
Contributor Author

hidmic commented Jun 18, 2020

@kyrofa friendly ping.

Copy link
Member

@kyrofa kyrofa left a comment

Choose a reason for hiding this comment

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

Alright, while this makes me a bit grumpy (in the nicest possible sense 😛), I definitely see the benefit and understand that there's not a lot we can do about the unittest usage. Thank you for this, @hidmic. We can try to clarify test frameworks in a contribution guide for new devs in a follow-up.

@kyrofa kyrofa merged commit cd234c1 into master Jun 21, 2020
@kyrofa kyrofa deleted the hidmic/improve-sros2-generate-policy-tests branch June 21, 2020 23:01
mikaelarguedas pushed a commit that referenced this pull request Mar 10, 2021
* Make use of ros_testing to test policy generation.

Signed-off-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>
Co-authored-by: Michel Hidalgo <michel@ekumenlabs.com>

* Skip test_generate_policy.py tests on Windows.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Revert "Skip test_generate_policy.py tests on Windows."

This reverts commit c68f0a0.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Wait for expected ROS graph state.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Boost discovery delay.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Please linter.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Skip tests using RTI Connext w/o a daemon.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Bump generate_policy execution timeout on Windows.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Bump generate_policy execution timeout on Windows again.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

Co-authored-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>
jacobperron pushed a commit that referenced this pull request Jan 11, 2022
* Make use of ros_testing to test policy generation.

Signed-off-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>
Co-authored-by: Michel Hidalgo <michel@ekumenlabs.com>

* Skip test_generate_policy.py tests on Windows.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Revert "Skip test_generate_policy.py tests on Windows."

This reverts commit c68f0a0.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Wait for expected ROS graph state.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Boost discovery delay.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Please linter.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Skip tests using RTI Connext w/o a daemon.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Bump generate_policy execution timeout on Windows.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

* Bump generate_policy execution timeout on Windows again.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>

Co-authored-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>

Co-authored-by: Michel Hidalgo <michel@ekumenlabs.com>
Co-authored-by: Brian Ezequiel Marchi <brian.marchi65@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants