gitIgnore for storing test elasticsearch instance in git


(Jonathan Aaron) #1

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


(David Pilato) #2

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


(Jonathan Aaron) #3

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!


(Jason Tedor) #4

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


(Jonathan Aaron) #5

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?


(Jason Tedor) #6

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.


(Jonathan Aaron) #7

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


(Jason Tedor) #8

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).


(Isabel Drost-Fromm) #9

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


(Jonathan Aaron) #10

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


(Jason Tedor) #11

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.


(Jonathan Aaron) #12

@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?


(Jonathan Aaron) #13

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


(Jason Tedor) #14

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


(Jonathan Aaron) #15

Just the API response. Like a mock SearchResponse


(Jason Tedor) #16

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


(system) #17

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