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

Added basic architecture for common tests #357

Merged
merged 10 commits into from
Jun 20, 2022

Conversation

ahcorde
Copy link
Contributor

@ahcorde ahcorde commented Jun 15, 2022

Signed-off-by: ahcorde [email protected]

🎉 New feature

Summary

This PR is a simplifycation of this other PR #354

This draft PR try to set up a common arquitecture to test all physics engine under the same tests avoiding duplication and improving coverage.

Test it

colcon test --merge-install --event-handlers console_direct+ --packages-select ignition-physics6 --ctest-args -R COMMON

Checklist

  • Signed all commits for DCO
  • Added tests
  • Added example and/or tutorial
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • Consider updating Python bindings (if the library has them)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

@ahcorde ahcorde added DART DART engine TPE Trivial Physics Engine Bullet Bullet engine labels Jun 15, 2022
@ahcorde ahcorde self-assigned this Jun 15, 2022
@ahcorde ahcorde requested a review from mjcarroll June 15, 2022 14:18
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Jun 15, 2022
@mjcarroll
Copy link
Contributor

I like this, it's very much in line with what we discussed.

@scpeters what do you think?

Signed-off-by: ahcorde <[email protected]>
@codecov
Copy link

codecov bot commented Jun 15, 2022

Codecov Report

Merging #357 (fd9ddc2) into main (e51974d) will decrease coverage by 0.91%.
The diff coverage is 3.94%.

❗ Current head fd9ddc2 differs from pull request most recent head 8510048. Consider uploading reports for the commit 8510048 to get more accurate results

@@            Coverage Diff             @@
##             main     #357      +/-   ##
==========================================
- Coverage   75.46%   74.55%   -0.92%     
==========================================
  Files         128      128              
  Lines        5552     5628      +76     
==========================================
+ Hits         4190     4196       +6     
- Misses       1362     1432      +70     
Impacted Files Coverage Δ
bullet/src/EntityManagementFeatures.cc 9.09% <3.94%> (-5.84%) ⬇️
dartsim/src/EntityManagementFeatures.cc 79.47% <0.00%> (+0.99%) ⬆️

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 e51974d...8510048. Read the comment docs.

@ahcorde ahcorde marked this pull request as ready for review June 15, 2022 15:36
Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

This approach reminds me of the approach in gazebo11, which has a hard-coded list of physics engines to use. I've been envisioning an executable like the hello_world_loader that takes the path to a physics plugin as an input and uses FindFeatures::From to identify the plugin names within that file that implement the specified FeatureList. The main difference from hello_world_loader is that it would be a gtest executable (if possible) and run test expectations against the APIs implemented by the plugin.

Eventually, I had imagined that this test executable could be installed somewhere not on the PATH (like libexec) and exposed as part of an ign physics test command for use by 3rd-party physics plugin developers, but that we would also have cmake logic to add tests that run this test executable directly with paths to the dartsim, bullet, and tpe-plugin binaries in the build folder.

gz::physics::TestValues())

static const std::vector<const char *> kPhysicsEngineTestValues
{"bullet", "dartsim", "tpe"};
Copy link
Member

Choose a reason for hiding this comment

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

this reminds me of gazebo11's approach

}

INSTANTIATE_TEST_CASE_P(EntityManagementFeatures, EntityManagementFeaturesTest,
PHYSICS_ENGINE_VALUES,
Copy link
Member

Choose a reason for hiding this comment

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

this reminds me of gazebo11's approach

@ahcorde ahcorde requested a review from scpeters June 17, 2022 07:44
@ahcorde
Copy link
Contributor Author

ahcorde commented Jun 17, 2022

@scpeters what do you think about this logic ?

Signed-off-by: ahcorde <[email protected]>
Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

environment variables are a little easier to set from cmake, but if possible I think it would be nice to use CLI arguments to specify the library name and optional plugin name. We can save that for a later refactoring though

{
gz::common::Console::SetVerbosity(4);

if (!gz::common::env("PHYSICS_ENGINE_NAME", physicsEngineName))
Copy link
Member

Choose a reason for hiding this comment

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

I think we shouldn't need to specify PHYSICS_ENGINE_NAME. If it's not specified, we should use FindFeatures3d to identify the plugin names contained within the LIB_TO_TEST and then test each of those plugins. To support this, we should get the list of pluginNames in SetUp and move the gz::plugin::Loader instantiation and LoadLib call to a loop in the test case

  • // Look for 3d plugins
    auto pluginNames = ignition::physics::FindFeatures3d<Features>::From(pl);
    if (pluginNames.empty())
    {
    std::cerr << "No plugins with required features found in "
    << pluginPath
    << std::endl;
    }
    for (const std::string &name : pluginNames)
    {
    std::cout << "Testing plugin: " << name << std::endl;
    ignition::plugin::PluginPtr plugin = pl.Instantiate(name);

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Signed-off-by: ahcorde <[email protected]>
@ahcorde
Copy link
Contributor Author

ahcorde commented Jun 17, 2022

@scpeters I'm not really sure about adding command line arguments to gtest. I will take a look

@ahcorde
Copy link
Contributor Author

ahcorde commented Jun 17, 2022

@scpeters I added this draft PR #359 with the changes required to use cmd line arguments

Copy link
Member

@scpeters scpeters left a comment

Choose a reason for hiding this comment

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

this is great, and I also like the changes in #357


class EntityManagementFeaturesTest:
public testing::Test,
public testing::WithParamInterface<const char *>
Copy link
Member

Choose a reason for hiding this comment

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

nit: we aren't currently using parameterized tests (TEST_P) so this WithParamInterface line can be removed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#include <gtest/gtest.h>

#include <gz/common/Filesystem.hh>
#include <gz/common/Console.hh>
Copy link
Member

Choose a reason for hiding this comment

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

nit: alphabetize

Copy link
Contributor Author

Choose a reason for hiding this comment

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


auto plugins = loader.LoadLib(libToTest);

pluginNames = gz::physics::FindFeatures3d<Features>::From(loader);
Copy link
Member

Choose a reason for hiding this comment

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

future todo: we should also run the 3f, 2d, and 2f variants of FindFeatures

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ahcorde ahcorde requested a review from scpeters June 20, 2022 13:44
@ahcorde
Copy link
Contributor Author

ahcorde commented Jun 20, 2022

@scpeters Do you mind to review this PR #359 which built on top of this one?

@scpeters
Copy link
Member

@scpeters Do you mind to review this PR #359 which built on top of this one?

I just approved it 😄

…nts (#359)

* Added basic architecture for common tests with cmd arguments

Signed-off-by: ahcorde <[email protected]>
@ahcorde ahcorde merged commit a950315 into main Jun 20, 2022
@ahcorde ahcorde deleted the ahcorde/common_test_initial_commit branch June 20, 2022 19:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bullet Bullet engine DART DART engine 🌱 garden Ignition Garden TPE Trivial Physics Engine
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

3 participants