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

GEODE-5960: Add test to verify CommandMarker file for the JDBC connector #2751

Merged

Conversation

BenjaminPerryRoss
Copy link
Contributor

Added a new test to the JDBC connector project to verify that the list
of commands loaded via the scanner and the command marker match the list
of commands found via these two sources. This is to avoid
errors/warnings due to commands which appear in Command Marker files but
don't have available source code.

Co-authored-by: Ben Ross bross@pivotal.io
Co-authored-by: Darrel Schneider dschneider@pivotal.io

Thank you for submitting a contribution to Apache Geode.

In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:

For all changes:

  • Is there a JIRA ticket associated with this PR? Is it referenced in the commit message?

  • Has your PR been rebased against the latest commit within the target branch (typically develop)?

  • Is your initial contribution a single, squashed commit?

  • Does gradlew build run cleanly?

  • Have you written or updated unit tests to verify your changes?

  • If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under ASF 2.0?

Note:

Please ensure that once the PR is submitted, you check travis-ci for build issues and
submit an update to your PR as soon as possible. If you need help, please send an
email to dev@geode.apache.org.

Added a new test to the JDBC connector project to verify that the list
of commands loaded via the scanner and the command marker match the list
of commands found via these two sources. This is to avoid
errors/warnings due to commands which appear in Command Marker files but
don't have available source code.

Co-authored-by: Ben Ross <bross@pivotal.io>
Co-authored-by: Darrel Schneider <dschneider@pivotal.io>
Copy link
Member

@sboorlagadda sboorlagadda left a comment

Choose a reason for hiding this comment

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

CommandAvailabilityIndicatorTest is kind of providing some coverage to assert that commands are available online. But this test seems to be a more basic test to help developers to figure out if he misses the markers.

@jinmeiliao
Copy link
Member

I am not sure what this test is for. the commandManager actually uses the package scanner to scan the classpath to compose its list of commands, so the test is just reiterates what the commandManager is doing. So if a command did not implement CommandMarker, this test would still pass, I believe.

Copy link
Member

@jinmeiliao jinmeiliao left a comment

Choose a reason for hiding this comment

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

A better test is probably to write an acceptance test for each jdbc gfsh commands.

@dschneider-pivotal
Copy link
Contributor

Jinmei, this test is only to catch when we remove a command class that still has its name in the CommandMarker file. With what is currently checked in, all the open side tests pass even though a user of gfsh will get a warning about that command class not existing.
We have verified that this new test fails if the CommandMarker file contains a class name that does not exist. And that is all this test attempting to verify.

@dschneider-pivotal dschneider-pivotal changed the title GEODE-5960: Add test to verify JDBC gfsh commands load properly GEODE-5960: Add test to verify CommandMarker file for the JDBC connector Oct 31, 2018
@jinmeiliao
Copy link
Member

jinmeiliao commented Oct 31, 2018

@dschneider-pivotal now I see that this test is to make sure all commands defined in the commandMarker file is able to load, then you don't need to scan the packages to get a list of all the commands at all, you can just get the list of commands loaded by service loader and make sure they exists in the command manager, this can make your test a lot shorter. Something like this:

ServiceLoader loader =
ServiceLoader.load(CommandMarker.class, ClassPathLoader.getLatest().asClassLoader());
loader.reload();
Iterator iterator = loader.iterator();

List<Class>
    allCommandClass = commandManager.getCommandMarkers().stream().map(CommandMarker::getClass).collect(
    Collectors.toList());
while (iterator.hasNext()) {
  Class<? extends CommandMarker> commandClass = iterator.next().getClass();
  assertThat(allCommandClass).contains(commandClass);
}

@dschneider-pivotal dschneider-pivotal merged commit dd24a9c into apache:develop Nov 1, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants