# Elasticsearch 5 ESIntegTestCase simple testcase problem

**URL:** <https://discuss.elastic.co/t/elasticsearch-5-esintegtestcase-simple-testcase-problem/72499>\
**Category:** Elasticsearch\
**Created:** [January 23, 2017, 3:10pm UTC](https://discuss.elastic.co/t/elasticsearch-5-esintegtestcase-simple-testcase-problem/72499 "2017-01-23T15:10:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![whelanp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whelanp/32/14820_2.png) [@whelanp](https://discuss.elastic.co/u/whelanp)\
**Post date:** [January 23, 2017, 3:10pm UTC](https://discuss.elastic.co/t/elasticsearch-5-esintegtestcase-simple-testcase-problem/72499/1 "2017-01-23T15:10:19Z")

</div>

Hello

I have the following simple test case and I am trying to figure out why the document count does not work?

I can see in the logs the following.

[2017-01-23T22:59:03,039][DEBUG][p.ServiceIntTest] [-1] docs indexed. waiting for [1]  
[2017-01-23T22:59:04,039][DEBUG][p.ServiceIntTest] [-1] docs indexed. waiting for [1]

Am I missing the point of what waitForDocs(1); is used for?

Thanks  
Paul

## sample code

```
package pdw;

import static org.elasticsearch.common.xcontent.XContentFactory.jsonBuilder;

import java.text.ParseException;
import java.util.Date;

import org.elasticsearch.action.index.IndexResponse;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.test.ESIntegTestCase;
import org.elasticsearch.test.ESIntegTestCase.ClusterScope;
import org.elasticsearch.test.ESIntegTestCase.Scope;
import org.elasticsearch.test.junit.annotations.TestLogging;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;

@TestLogging("_root:DEBUG")
@ClusterScope(scope = Scope.SUITE)
@RunWith(com.carrotsearch.randomizedtesting.RandomizedRunner.class)
public class ServiceIntTest extends ESIntegTestCase {

	private Client client;
	
	@Override
	protected Settings nodeSettings(int nodeOrdinal) {
		return Settings.builder().put(super.nodeSettings(nodeOrdinal)).build();
	}

	@Before
	public void setUp() throws Exception {
		super.setUp();
		client = ESIntegTestCase.client();
		setUpTestData(client);
	}
	
	private void setUpTestData(Client client) throws Exception {

		createIndex("twitter");
		refresh("twitter");
		IndexResponse response = client.prepareIndex("twitter", "tweet", "1")
		        .setSource(jsonBuilder()
		                    .startObject()
		                        .field("user", "kimchy")
		                        .field("postDate", new Date())
		                        .field("message", "trying out Elasticsearch")
		                    .endObject()
		                  )
		        .get();	
				
		refresh("twitter");
		waitForDocs(1);
		ensureGreen();
	}

	@Test
	public void testDocsCount() throws ParseException {
		Assert.assertTrue(true);
	}
}
```

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [January 23, 2017, 3:59pm UTC](https://discuss.elastic.co/t/elasticsearch-5-esintegtestcase-simple-testcase-problem/72499/2 "2017-01-23T15:59:43Z")

</div>

I've not used `waitForDocs`. `refresh` is synchronous though.

---

<div class="post-metadata">

**Author:** ![whelanp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whelanp/32/14820_2.png) [@whelanp](https://discuss.elastic.co/u/whelanp)\
**Post date:** [January 25, 2017, 10:58am UTC](https://discuss.elastic.co/t/elasticsearch-5-esintegtestcase-simple-testcase-problem/72499/3 "2017-01-25T10:58:28Z")

</div>

Thanks @nik9000 I settled on using the [elasticsearch-maven-plugin](https://github.com/alexcojocaru/elasticsearch-maven-plugin).

Based on some of your comments on other Threads it seems testing against a "real" node is the preferred way to go.

Everything works like I expect it to now. I'd recommend the plugin, it works great.

Thanks for the feedback.

Paul

---

<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 22, 2017, 10:58am UTC](https://discuss.elastic.co/t/elasticsearch-5-esintegtestcase-simple-testcase-problem/72499/4 "2017-02-22T10:58:46Z")

</div>

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