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

Test initializing parameters from command line #274

Merged
merged 16 commits into from
Jun 9, 2018
Merged

Conversation

sloretz
Copy link
Contributor

@sloretz sloretz commented Jun 5, 2018

Requires #272
Connects to ros2/rclcpp#488

This adds tests for parameters initialized via the command line arg __params:=/path/to/yaml.file

@sloretz sloretz added the in progress Actively being worked on (Kanban column) label Jun 5, 2018
@sloretz sloretz added this to the bouncy milestone Jun 5, 2018
@sloretz sloretz self-assigned this Jun 5, 2018
@sloretz sloretz force-pushed the init_params_via_yaml branch from ec67875 to 8592186 Compare June 5, 2018 22:45
@sloretz sloretz added in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels Jun 6, 2018
@wjwwood
Copy link
Member

wjwwood commented Jun 6, 2018

41a5dcc 👍

mikaelarguedas
mikaelarguedas previously approved these changes Jun 6, 2018
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.

lgtm,

I pushed a few nitpicks on init_params_via_yaml_mikael_review feel free to cherry-pick whatever is appropriate

a3687e2: alphabetical dependency order in package.xml
f36e85d: remove unused include
d2b7b76: call unused python loop control variable '_' for readability
4b8c886: reduce test tiemout, I have not see this test take more than a couple seconds on my machine so I supposed that using the default 60 second timeout should be enough
568a6d1: use some negative values for double testing

@sloretz
Copy link
Contributor Author

sloretz commented Jun 6, 2018

@mikaelarguedas merged your branch into this one; thanks for the fixes!

@sloretz
Copy link
Contributor Author

sloretz commented Jun 6, 2018

Limited CI to test if windows issue is fixed: Build Status

Re-implement get_params without blocking when service is not ready
@sloretz
Copy link
Contributor Author

sloretz commented Jun 6, 2018

Another rebuild to check if windows issue is fixed Build Status

@sloretz
Copy link
Contributor Author

sloretz commented Jun 7, 2018

One more windows CI attempt Build Status

@sloretz
Copy link
Contributor Author

sloretz commented Jun 7, 2018

Yet another windows CI attempt

Build Status

@sloretz
Copy link
Contributor Author

sloretz commented Jun 7, 2018

All platforms CI testing this package

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

@sloretz sloretz dismissed mikaelarguedas’s stale review June 7, 2018 21:50

Major changes since review

@sloretz
Copy link
Contributor Author

sloretz commented Jun 7, 2018

@mikaelarguedas here's a summary of the changes to this PR

  1. Added custom NamedTemporaryFile class to util to work around issue with tempfile.NamedTemporaryFile() on windows
    • A temporary file on windows can't be opened by another process without closing it, but it can't be closed without being deleted. The workaround is to create a temporary directory with a normal file inside, then delete the whole directory on __exit__().
  2. Got rid of asycnio and coroutines.
    • I was having trouble debugging the next issue, so I rewrote the tests using subprocess and threading
  3. Every helper executable starts with a different node name
    • I'm not sure what the real bug is, but I don't have time to get to root cause right now. Here's what I know.
      • Every test does the following:
        1. spawns an executable with service server /initial_params_node/get_parameters
        2. creates a client for that service
        3. calls wait_for_service()
        4. calls the service and checks values of parameters returned
        5. destroys the client
        6. shuts down the executable
      • The first test to run passes, but the second test never gets a response from the service server.
      • The issue seems to be lower level than rclpy. The second test's client handle is in the wait set but never becomes ready. I did not check with wireshark to see if the request was actually sent.
      • It's definitely a race condition, adding time.sleep(1) after calling wait_for_service() but before calling the service in the second test solves the issue.
      • Reusing the same client for all tests does not solve the issue.
      • Giving each test a different node name (and therefor a different service name) works around the issue

self._proc.kill()


class NamedTemporaryFile:
Copy link
Member

Choose a reason for hiding this comment

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

The naming of this custom class is kind of confusing. It is the same as the one from the Python library but it behaves differently (doesn't return a file handle but the name). Therefore I would suggest to rename it to something more "custom" to avoid confusion.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TemporaryFileWithContent in deb5998

@dirk-thomas
Copy link
Member

I'm not sure what the real bug is, but I don't have time to get to root cause right now.

Please ticket this problem to investigate it in the future.

@sloretz
Copy link
Contributor Author

sloretz commented Jun 7, 2018

Please ticket this problem to investigate it in the future.

ros2/ros2#502

@sloretz sloretz mentioned this pull request Jun 8, 2018
Copy link
Member

@wjwwood wjwwood left a comment

Choose a reason for hiding this comment

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

lgtm, though I wonder if this could not have been done in rclcpp itself. But maybe there's a reason I missed. Also, why a new package and not just in test_rclcpp (maybe the dependency on rclpy)? Will this package also test the python API in the same way?

<test_depend>ament_cmake_pytest</test_depend>
<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_lint_common</test_depend>
<test_depend>launch</test_depend>
Copy link
Member

Choose a reason for hiding this comment

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

Seems like an unused dependency?

@sloretz
Copy link
Contributor Author

sloretz commented Jun 9, 2018

@wjwwood The intent was to combine test_cli_remapping with testing parameters into test_cli, but #268 was merged first. I'll leave launch as a dependency for the moment and add it as a note to a ticket to combine the two test packages.

@sloretz
Copy link
Contributor Author

sloretz commented Jun 9, 2018

Follow up ticket #279

@sloretz sloretz merged commit 0975759 into master Jun 9, 2018
@sloretz sloretz deleted the init_params_via_yaml branch June 9, 2018 00:24
@dirk-thomas
Copy link
Member

The tests introduced in this PR are failing on the Windows debug nightly: https://ci.ros2.org/view/nightly/job/nightly_win_deb/906/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in review Waiting for review (Kanban column)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants