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

Add tests for parameters #14

Merged
merged 1 commit into from
Aug 28, 2015
Merged

Add tests for parameters #14

merged 1 commit into from
Aug 28, 2015

Conversation

tfoote
Copy link
Contributor

@tfoote tfoote commented Jul 7, 2015

This has some basic tests. However I need some help on the RTI Connext Dynamic implmeentation tests which hang.

How much details do we want to implement before we add support for a testing framework like gtest. Writing detailed unit tests with return values only is not very productive.

This is currently running the tests and checking their values only.

Connects to #10

@tfoote tfoote added the in progress Actively being worked on (Kanban column) label Jul 7, 2015
@dirk-thomas
Copy link
Member

Invoking the test launch files directly fails with:

NameError: name 'test_parameters' is not defined

Update: fixed in 2cae78f1d14486a282936774ebe4d08f4f7bf3b0

@dirk-thomas
Copy link
Member

The Python launch file does not follow the style conventions.

PROPERTIES DEPENDS "test_parameters_cpp__${middleware_impl1}"
)


Copy link
Member

Choose a reason for hiding this comment

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

Please remove the two empty lines.

@dirk-thomas
Copy link
Member

Instead of streaming to cout / cerr incrementally this should use printf / fprintf to avoid interleaving.

@dirk-thomas
Copy link
Member

Connext Dynamic fails with the following for me which indicate some type mismatch:

DDS_DynamicData_set_string:type mismatch for field <no name> (id=1)

Update: rmw_connext_dynamic_cpp does not implement arrays of submessages correctly.

@dirk-thomas
Copy link
Member

The Connext dynamic test currently hangs forever since the sync API has no timeouts. May be it would be better to cover the async API in a first test which has timeouts instead.

Update: seems to work now.

@esteve
Copy link
Member

esteve commented Jul 28, 2015

@dirk-thomas I pushed a test that exposes the issue with subscriptions not being fired. The test will hang at the end because we rclcpp::spin_until_future_complete does not support timeouts yet.

@dirk-thomas
Copy link
Member

The current behavior is that rmw_wait() returns when one or multiple samples are ready to be taken. But the executor only takes one of them and then calls rmw_wait() again. This call won't return until new samples arrive.

So either rmw has to always return as long as not yet taken samples are available or the executor has to handle available sample after wait returns. Since the SyncParametersClient currently embeds its own executor it is not feasible to make the executor stateful at the moment.

@esteve
Copy link
Member

esteve commented Jul 29, 2015

@dirk-thomas I have a local branch that modifies the executors so that there's a global default one that can be reused instead of instantiating a new one.

@dirk-thomas
Copy link
Member

#20 contains a test for the spinning problem.

ros2/rmw_connext#62 fixes the behavior of rmw_connext_cpp for subscriptions.

@dirk-thomas
Copy link
Member

@esteve Can you please implement a similar fix as ros2/rmw_connext#62 (and for opensplice) to change the conditions for services too? I would expect that to fix this broken test.

@esteve
Copy link
Member

esteve commented Jul 29, 2015

@dirk-thomas I won't be able to do it today or tomorrow, so if you have the fix fresh in your mind, go for it. Thanks!

@dirk-thomas
Copy link
Member

The patch will look exactly the same way as for the subscription. Nothing new or different, just effort to put it together.

It can wait until you (or @tfoote) have time for it.

@dirk-thomas dirk-thomas mentioned this pull request Jul 30, 2015
@tfoote tfoote force-pushed the test_parameters branch 2 times, most recently from db45df1 to 750b571 Compare July 31, 2015 18:01
@tfoote
Copy link
Contributor Author

tfoote commented Jul 31, 2015

I've updated it to use gtest and actually test the results. It's revealed some underlying errors. The returned parameters have different values than the set parameters.

I will next look at the implementation to try to get the unit tests passing. I triggered a CI job to verify the same behavior on the farm: http://ci.ros2.org/job/ros2_batch_ci_linux/122/

$ ./test_parameters_cpp__rmw_connext_cpp 
[==========] Running 1 test from 1 test case.
[----------] Global test environment set-up.
[----------] 1 test from parameters
[ RUN      ] parameters.test_parametesr
Parameter name: bar
Parameter name: foo
Parameter name: foo.first
/home/tfoote/work/ros2/test_param/src/ros2/system_tests/test_communication/test/test_parameters.cpp:57: Failure
Value of: name == "foo" || name == "bar"
  Actual: false
Expected: true
Parameter name: foo.second
/home/tfoote/work/ros2/test_param/src/ros2/system_tests/test_communication/test/test_parameters.cpp:57: Failure
Value of: name == "foo" || name == "bar"
  Actual: false
Expected: true
footruebool
/home/tfoote/work/ros2/test_param/src/ros2/system_tests/test_communication/test/test_parameters.cpp:69: Failure
Value of: parameter.to_string().c_str()
  Actual: "true"
Expected: "2"
/home/tfoote/work/ros2/test_param/src/ros2/system_tests/test_communication/test/test_parameters.cpp:70: Failure
Value of: parameter.get_type_name().c_str()
  Actual: "bool"
Expected: "int"
bar1.450000double
/home/tfoote/work/ros2/test_param/src/ros2/system_tests/test_communication/test/test_parameters.cpp:74: Failure
Value of: parameter.to_string().c_str()
  Actual: "1.450000"
Expected: "hello"
/home/tfoote/work/ros2/test_param/src/ros2/system_tests/test_communication/test/test_parameters.cpp:75: Failure
Value of: parameter.get_type_name().c_str()
  Actual: "double"
Expected: "string"
baz2integer
/home/tfoote/work/ros2/test_param/src/ros2/system_tests/test_communication/test/test_parameters.cpp:79: Failure
Value of: parameter.to_string().c_str()
  Actual: "2"
Expected: "1.45"
/home/tfoote/work/ros2/test_param/src/ros2/system_tests/test_communication/test/test_parameters.cpp:80: Failure
Value of: parameter.get_type_name().c_str()
  Actual: "integer"
Expected: "double"
tested parameters for 0.277822 seconds
[  FAILED  ] parameters.test_parametesr (3384 ms)
[----------] 1 test from parameters (3384 ms total)

[----------] Global test environment tear-down
[==========] 1 test from 1 test case ran. (3384 ms total)
[  PASSED  ] 0 tests.
[  FAILED  ] 1 test, listed below:
[  FAILED  ] parameters.test_parametesr

@tfoote
Copy link
Contributor Author

tfoote commented Aug 3, 2015

ros2/rmw_connext#66 should fix the services issue

@tfoote
Copy link
Contributor Author

tfoote commented Aug 19, 2015

This is blocked by #29 before it can be merged.

@@ -131,6 +133,42 @@ if(AMENT_ENABLE_TESTING)
"rclcpp")
endif()

ament_add_gtest(local_parameters_cpp__${middleware_impl} "test/local_parameters.cpp")
add_dependencies(local_parameters_cpp__${middleware_impl} ${PROJECT_NAME})
Copy link
Member

Choose a reason for hiding this comment

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

Before using the gtest target you must check that it actually exists (e.g. when gtest is not found):

if(TARGET local_parameters_cpp__${middleware_impl})

Same below.

Copy link
Member

Choose a reason for hiding this comment

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

I just added both to CMakeLists.txt, let me know if they look ok and I'll squash and merge this PR.

@esteve
Copy link
Member

esteve commented Aug 28, 2015

I've removed the tests for the to_json functions since it's not clear if ros2/rclcpp#91 will be merged soon as it is. I've pushed the tests to a separate branch https://github.com/ros2/system_tests/tree/test_json

@tfoote
Copy link
Contributor Author

tfoote commented Aug 28, 2015

It looks like we still have intermittent failures in the services.

The OSX build failed with: test_requester_replier_cpp__empty__rmw_opensplice_cpp.test_requester_replier
And the linux build failed with
test_requester_replier_cpp__primitives__rmw_connext_cpp.test_requester_replier

I retriggered the linux and osx jobs:
http://ci.ros2.org/job/ros2_batch_ci_linux/289/
http://ci.ros2.org/job/ros2_batch_ci_osx/214/

Update: the above tests passed

Windows still has 28 failures which is our baseline at the moment.

@esteve
Copy link
Member

esteve commented Aug 28, 2015

@tfoote should we merge this PR? I don't see a reason why not, the intermittent failures are not introduced by this PR, and these changes will just make it easier to watch for errors in the parameters code.

@@ -135,6 +137,46 @@ if(AMENT_ENABLE_TESTING)
"rclcpp")
endif()

if(TARGET local_parameters_cpp__${middleware_impl})
ament_add_gtest(local_parameters_cpp__${middleware_impl} "test/local_parameters.cpp")
Copy link
Member

Choose a reason for hiding this comment

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

The cpp file contains a main function and should therefore not link against gtest's main function.

Copy link
Member

Choose a reason for hiding this comment

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

What's the solution here? Remove the main function from local_parameters.cpp or not add it with ament_add_gtest ?

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 an argument to SKIP_LINKING_MAIN_LIBRARIES I'll take care of that and clean up the whitespace above before we merge.

@tfoote
Copy link
Contributor Author

tfoote commented Aug 28, 2015

I've amended for dirk's comment about the main. And cleared a few whitespace only changes.

CI pending:
http://ci.ros2.org/job/ros2_batch_ci_linux/293/
http://ci.ros2.org/job/ros2_batch_ci_osx/218/
http://ci.ros2.org/job/ros2_batch_ci_windows/292/

@tfoote
Copy link
Contributor Author

tfoote commented Aug 28, 2015

tfoote added a commit that referenced this pull request Aug 28, 2015
@tfoote tfoote merged commit f913262 into master Aug 28, 2015
@tfoote tfoote removed the in progress Actively being worked on (Kanban column) label Aug 28, 2015
@tfoote tfoote deleted the test_parameters branch August 28, 2015 21:05
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.

3 participants