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

QA: Create a test plugin with configuration #12787

Merged
merged 2 commits into from
Aug 12, 2015

Conversation

nik9000
Copy link
Member

@nik9000 nik9000 commented Aug 10, 2015

In order to test the way plugins with configuration are installed and removed
we need a plugin with configuration in the repository. The simplest way to
get one is to make an "example" plugin.

In the process of making this example it became aparent that cat actions were
difficult to create outside of the org.elasticsearch.rest.action.cat package
because key methods in AbstractCatAction were package private. This makes them
protected and uses them to create the example configured plugin.

Relates to #12717 but is only one step of many to close it.

In order to test the way plugins with configuration are installed and removed
we need a plugin with configuration in the repository. The simplest way to
get one is to make an "example" plugin.

In the process of making this example it became aparent that cat actions were
difficult to create outside of the org.elasticsearch.rest.action.cat package
because key methods in AbstractCatAction were package private. This makes them
protected and uses them to create the example configured plugin.

Relates to elastic#12717 but is only one step of many to close it.
@nik9000 nik9000 added >test Issues or PRs that are addressing/adding tests :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts labels Aug 10, 2015
@nik9000
Copy link
Member Author

nik9000 commented Aug 10, 2015

This is step 0 in removing shield from the integration tests - it creates a shield lookalike that we can use to test the configuration installation and removal.

@rjernst
Copy link
Member

rjernst commented Aug 10, 2015

@nik9000 Can you merge this "configured-plugin" into the "jvm-example" plugin I added in #12744? That is essentially a blank slate right now, and has a similar intended purpose to what is here.

@nik9000
Copy link
Member Author

nik9000 commented Aug 10, 2015

@nik9000 Can you merge this "configured-plugin" into the "jvm-example" plugin I added in #12744? That is essentially a blank slate right now, and has a similar intended purpose to what is here.

Sure - I guess I should have been reviewing that pull request....

@nik9000 nik9000 added the review label Aug 11, 2015
@nik9000
Copy link
Member Author

nik9000 commented Aug 11, 2015

@rjernst so merged.

@Override
protected void configure() {
bind(ExamplePluginConfiguration.class).asEagerSingleton();
Multibinder<AbstractCatAction> catActionMultibinder = Multibinder.newSetBinder(binder(), AbstractCatAction.class);
Copy link
Member

Choose a reason for hiding this comment

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

It's interesting that this is the way we add cat actions...I wonder if this should be explicit registration like we have for other extension points, rather than having to know to setup a multibinder and what class to bind to. Not relevant for this PR, but I think it would be a good issue to spinoff?

Copy link
Member Author

Choose a reason for hiding this comment

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

I don't like the whole registration thing because it means there are two ways to do everything. I'd prefer to just do it the Multibinder way - maybe make some sugar to make that less ceremonial.

Copy link
Member

Choose a reason for hiding this comment

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

No, there are only two ways for sets/maps, because of how multibinder works. I think it is more confusing to have some things bound using a binder, and others with registration/settings. Classes that ES controls should be registered, and set. If there was a way to just not allow multiple multibinders to work I would say we should do that, but I don't think such a thing exists.

Copy link
Member Author

Choose a reason for hiding this comment

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

think it is more confusing to have some things bound using a binder, and others with registration/settings.

Yeah - but we're based on Guice. I think that hiding Guice under the covers is just asking for trouble.

Preventing multiple Multibinders from working would just handcuff plugin authors.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1 on registration directly via the RestActionModule

I don't think multiple multibindings is supported, but tbh I wouldn't do that if it is/was. By exposing the extension points as registration methods on the Module you communicate what can be extended and what not, what accepts multiple implementation of X and what just replaces a singleton of X, etc...

Copy link
Member

Choose a reason for hiding this comment

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

But we don't have well defined extension points.

This is not a valid argument for not making the system better with well defined extension points. How can we get to a point where we do have well defined extension points, if we don't start somewhere?

I went and started doing this with onModule - and it requires so much more ceremony!

How so? A Set, a method, and a couple lines in configure?

Copy link
Member

Choose a reason for hiding this comment

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

Also, we should really move this discussion to another issue. I think this PR is fine as is, this was just a suggestion for a follow up/thought.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is not a valid argument for not making the system better with well defined extension points. How can we get to a point where we do have well defined extension points, if we don't start somewhere?

I guess my argument is that Multibinder works regardless of how much work we put into supporting it but onModule only works if we make it work and we aren't doing much with it.

How so? A Set, a method, and a couple lines in configure?

I'll push the commit that gets it working in a minute - its just a few lists and methods to add to them. Compared to the 2 lines in the plugin. I guess the hard part for the plugin author is to onModule the right module. I had to do more debugging Elasticsearch to get the onModule thing working then I did the Multibinder - Guice just worked.

I just don't get why we wrap Guice here - its built for this kind of thing.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, we should really move this discussion to another issue. I think this PR is fine as is, this was just a suggestion for a follow up/thought.

Fair enough. I can merge this and then send another pull request to get onModule working for it and we can go there?

Copy link
Member

Choose a reason for hiding this comment

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

+1 Thanks!

@rjernst
Copy link
Member

rjernst commented Aug 11, 2015

LGTM

nik9000 added a commit that referenced this pull request Aug 12, 2015
QA: Add configuration to the jvm-example plugin
@nik9000 nik9000 merged commit e4e6077 into elastic:master Aug 12, 2015
@mark-vieira mark-vieira added the Team:Delivery Meta label for Delivery team label Nov 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts Team:Delivery Meta label for Delivery team >test Issues or PRs that are addressing/adding tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants