private void launchTest(XContentBuilder river, final Integer numDocs, boolean removeRiver)
throws IOException, InterruptedException {
logger.info(" -> Checking internet working");
new HttpClient("www.elasticsearch.org", 80).request("/");
HttpClientResponse response = new HttpClient("www.elasticsearch.org", 80).request("/");
Assert.assertThat(response.errorCode(), is(200));
logger.info(" -> Create river");
try {
createIndex(getDbName());
} catch (IndexAlreadyExistsException e) {
// No worries. We already created the index before
}
index("_river", getDbName(), "_meta", river);
logger.info(" -> Wait for some docs");
assertThat(awaitBusy(new Predicate<Object>() {
public boolean apply(Object obj) {
try {
refresh();
CountResponse response = client().prepareCount(getDbName()).get();
logger.info(" -> got {} docs in {} index", response.getCount(), getDbName());
return response.getCount() >= numDocs;
} catch (IndexMissingException e) {
return false;
}
}
}, 5, TimeUnit.MINUTES), equalTo(true));