Testing plugin actions via transport client results in an NPE, 2.0.0.rc1

I'm a bit stuck when porting the clustering plugin to 2.0.0.rc1. Here
is the problem:

  • For integration tests ESIntegTestCase's client() returns a transport
    client (even if @ClusterScope's transportClientRatio is set to zero,
    which kind of makes sense since it's communicating with an external
    node). But when one develops custom plugins (with actions) it can be
    quite surprising to receive an NPE as follows:

Throwable #1: java.lang.NullPointerException

at org.elasticsearch.client.transport.support.TransportProxyClient$1.doWithNode(TransportProxyClient.java:58)
at org.elasticsearch.client.transport.TransportClientNodesService.execute(TransportClientNodesService.java:202)
at org.elasticsearch.client.transport.support.TransportProxyClient.execute(TransportProxyClient.java:55)
at org.elasticsearch.client.transport.TransportClient.doExecute(TransportClient.java:272)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)
at org.elasticsearch.client.FilterClient.doExecute(FilterClient.java:52)
at org.elasticsearch.client.support.AbstractClient.execute(AbstractClient.java:347)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:85)
at org.elasticsearch.action.ActionRequestBuilder.execute(ActionRequestBuilder.java:59)
at org.elasticsearch.action.ActionRequestBuilder.get(ActionRequestBuilder.java:67)

this essentially means the action (plugin) wasn't registered in
TransportClient. There are mentions of this requirement on the mailing
list, but they're buried under tons of other stuff. I think an
exception could be improved here (essentially "action unknown").

  • I can't figure out how to set up the transport client properly for
    ESIntegTestCase. I passed an appropriate "plugin.types" property to
    node settings in

protected Settings nodeSettings(int nodeOrdinal)

and it took me a longer while to realize that ESIntegTestCase has
two methods to initialize the settings, the other one being:

protected Settings transportClientSettings()

the thing is... even if I set plugin.types in transportClientSettings
I still get the NPE above. And this method doesn't seem to be invoked
at all.

What am I missing here?

[spent a few minutes looking at the code]

Oh, there is a third method to set up settings:

protected Settings externalClusterClientSettings()

And this one finally worked!

Could somebody who knows the code clarify what these methods actually
do and when to use which one? :slight_smile: