0

I have an app that connects to an elastic search node on another server via the Transport client using the JAVA API. The node has shield security enabled, so I use maven to fetch the shield jar. My app runs fine. However, now I'm trying to set up integration tests for the build process of my app. Thus instead of trying the Transport client, I try to run a local node to run my tests against. However, the local node complaints about the following issues.

  1. The license is only valid for 30 days. The documentation describes perfectly well on how to do this using all kinds of tooling, but it doesn't tell how to update the license via the JAVA API.
  2. I get an org.elasticsearch.shield.authz.AuthorizationException: action [indices:data/write/index] is unauthorized for user [__es_system_user]. This happens because my node doesn't configure any users. Again the documentation describes perfectly well how add users to a node, but doesn't explain on how to accomplish this using the JAVA API.

This I'm wondering whether it's possible to just disable shield for integration tests. I tried the following, but it didn't work. Any help is appreciated.

nodeBuilder().local(true).settings(ImmutableSettings.builder()
    .put("shield.enabled", false)).build()

1 Answer 1

0

What version of Elasticsearch and Shield are you using? shield.enabled works for me; I just did the following in a simple maven project with ES 1.5.2 and Shield 1.2.0

final Node node = NodeBuilder.nodeBuilder()
            .settings(ImmutableSettings.builder().put("shield.enabled", false))
            .local(true).node();
Client client = node.client();
ClusterHealthResponse response = client.admin().cluster().prepareHealth().get();
System.out.println(response.toString());

No errors about licensing when doing this. If you still have some errors can you add them to your original post?

4
  • So strange, working now. Seems like I answered my own question. By the way, I created a node using the code above. Is there any way to connect to this node from the same jvm using a TransportClient?
    – dingdong
    Apr 30, 2015 at 9:31
  • 1
    Yes it is possible: InternalNode internalNode = (InternalNode) node; TransportClient transportClient = new TransportClient(ImmutableSettings.settingsBuilder() .put("shield.enabled", false) .put("node.local", true)); TransportAddress address = internalNode.injector().getInstance(TransportService.class).boundAddress().publishAddress(); transportClient.addTransportAddress(address); Based on elasticsearch's test code: github.com/elastic/elasticsearch/blob/1.x/src/test/java/org/…
    – jaymode
    Apr 30, 2015 at 10:19
  • I don't have access to my internal node from within the code that runs the TransportClient. Is there some static function to retrieve the last created active node?
    – dingdong
    May 5, 2015 at 15:59
  • Maybe we you create the node, you can add the transport address to a list and make that available somehow to your client? I don't think there is a way to get the last created node.
    – jaymode
    May 6, 2015 at 17:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.