# gitIgnore for storing test elasticsearch instance in git

**URL:** <https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888>\
**Category:** Elasticsearch\
**Created:** [January 17, 2017, 5:23pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888 "2017-01-17T17:23:22Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 17, 2017, 5:23pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/1 "2017-01-17T17:23:22Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [January 17, 2017, 7:21pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/2 "2017-01-17T19:21:23Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 17, 2017, 7:51pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/3 "2017-01-17T19:51:45Z")

</div>

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!

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [January 17, 2017, 8:14pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/4 "2017-01-17T20:14:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 17, 2017, 8:40pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/5 "2017-01-17T20:40:08Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [January 17, 2017, 9:19pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/6 "2017-01-17T21:19:51Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 17, 2017, 9:22pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/7 "2017-01-17T21:22:02Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [January 17, 2017, 9:41pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/8 "2017-01-17T21:41:06Z")

</div>

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](https://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.elasticsearch.distribution.zip%22)).

---

<div class="post-metadata">

**Author:** ![mainec](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mainec/32/5557_2.png) [@mainec](https://discuss.elastic.co/u/mainec)\
**Post date:** [January 18, 2017, 11:34am UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/9 "2017-01-18T11:34:53Z")

</div>

> [@JonathanAaron](#):
>
> spin it up run tests and shut it down

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

> **[Java testing framework | Elasticsearch Guide \[8.11\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/testing-framework.html)**

---

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 18, 2017, 5:06pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/10 "2017-01-18T17:06:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [January 18, 2017, 5:54pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/11 "2017-01-18T17:54:16Z")

</div>

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](https://github.com/elastic/elasticsearch/issues/21544).

---

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 18, 2017, 5:56pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/12 "2017-01-18T17:56:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 18, 2017, 7:38pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/13 "2017-01-18T19:38:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [January 18, 2017, 10:27pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/14 "2017-01-18T22:27:22Z")

</div>

> [@JonathanAaron](#):
>
> @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?

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

---

<div class="post-metadata">

**Author:** ![JonathanAaron](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jonathanaaron/32/24405_2.png) [@JonathanAaron](https://discuss.elastic.co/u/JonathanAaron)\
**Post date:** [January 18, 2017, 10:58pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/15 "2017-01-18T22:58:01Z")

</div>

Just the API response. Like a mock SearchResponse

---

<div class="post-metadata">

**Author:** ![jasontedor](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasontedor/32/66992_2.png) [@jasontedor](https://discuss.elastic.co/u/jasontedor)\
**Post date:** [January 18, 2017, 11:14pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/16 "2017-01-18T23:14:29Z")

</div>

> [@JonathanAaron](#):
>
> 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).

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 15, 2017, 11:14pm UTC](https://discuss.elastic.co/t/gitignore-for-storing-test-elasticsearch-instance-in-git/71888/17 "2017-02-15T23:14:53Z")

</div>

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