How am I supposed to deal with test resources in an ESIntegTestCase?


(Doug Turnbull) #1

I'm working on an Elasticsearch plugin. I'm implementing an integration test that needs to pull something off the file system. It's a rather large blob of text and I'd rather not place it inline in the code. I'm using the esPlugin gradle plugin. Which comes with many handy checks, including ensuring I'm not using any forbidden APIs.

The Java file i/o APIs appear to be forbidden. Instead, you're asked to use Elasticsearch's PathUtils utility class. This works fine in Intellij, however when I run the integration test from the command line (gradle integTest) I get a file-not-found error. It seems the root file system for Elasticsearch is not the same place where my test resource was staged. Specifically, /build/testrun/integTest/J0/build/resources/test/model.txt. You can see what I'm trying to do here.

I'm wondering what I, as an Elasticsearch plugin developer, am supposed to do to handle my own test resources. Should I

  1. Use some integTest#processTestResources that will stage this for me in the temp folder? (I can't seem to find such a task)
  2. Disable forbidden APIs for integTests?
  3. Use some other process I'm unfamiliar with?

Any help appreciated!


(Doug Turnbull) #2

I've also tried using the classloader to access my resources, but run into similar problems with java.io.File being disallowed.


(David Pilato) #3

Have a look at


(system) #4

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.