gitIgnore for storing test elasticsearch instance in git

I have a copy of elasticsearch in my project where I spin it up run tests and shut it down. I'm wonder what would be some good things to put into the gitignore so I don't store logs and other things.

Thanks,

Jonathan

I think that gradle run will run elasticsearch in the right place. Can you try if it "solves" your problem?

I don't think I explained my problem right. I have a Java project that uses a Transport Client. I also have a copy of elasticsearch in that project so I can spin up a local ES node to run queries against and do unit test based off of those queries. I accumulated alot of log files and other things I don't want to store in git. I was hoping someone had a gitignore list I could use to keep these pesky files from storing in git.

Thanks for the reply David!

I think you would be better off if you spun it up in a temporary directory outside of your git repository. Does that help?

So this will all be happening in Jenkins. Jenkins will pull down my repo, start elastic, run tests, then kill elastic. How would I spin up elastic outside of my directory? Are you saying that when I start elastic that I should specify that the data directory be in a tmp dir instead of the elastics' default?

No, I'm saying that you should not include an Elasticsearch distribution as part of your repository, you should pull down a zip distribution, explode it in a temporary directory (or the build workspace, it doesn't matter, just not in your repository), and point at the cluster started there.

1 Like

I see. Thanks for the clarification. That's a great idea.

Also, we provide an artifact in Maven Central that you could use for this (e.g., the latest would be the 5.1.2 zip distribution).

1 Like

Depending on the types of tests you want to run, you might also want to checkout the Elasticsearch testing framework:

https://www.elastic.co/guide/en/elasticsearch/reference/current/testing-framework.html

Do you think I could mock up things like InternalAggregation and SearchResponse?

We have been encouraging folks to not use the testing framework but rather spinning up and tearing down standalone nodes as these are more realistic tests. The testing framework is very useful for plugin developers, less so for application/client developers. See also #21544.

@jasontedor , do you know the best way to mock up an InternalAggregation? I have some service logic I'm trying to test that's not really Integration testing?

I'm seeing something from SearchResponse called toXConent? I might somehow be able to create some json builder to mock out a searchresponse?

It depends. Do you need to mock the Java API response, or the HTTP response?

Just the API response. Like a mock SearchResponse

If you need to mock the Java API response, I would recommend just using a mocking framework (e.g., mockito).

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