use of org.elasticsearch.indices.IndexAlreadyExistsException in project elasticsearch-river-couchdb by elastic.
the class CouchdbRiverIntegrationTest method launchTest.
private void launchTest(XContentBuilder river, final Integer numDocs, InjectorHook injectorHook) throws IOException, InterruptedException {
logger.info(" -> Checking couchdb running");
CouchDBClient.checkCouchDbRunning();
logger.info(" -> Creating test database [{}]", getDbName());
CouchDBClient.dropAndCreateTestDatabase(getDbName());
logger.info(" -> Put [{}] documents", numDocs);
for (int i = 0; i < numDocs; i++) {
CouchDBClient.putDocument(getDbName(), "" + i, "foo", "bar", "content", "" + i);
}
logger.info(" -> Put [{}] documents done", numDocs);
if (injectorHook != null) {
logger.info(" -> Injecting extra data");
injectorHook.inject();
}
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();
SearchResponse response = client().prepareSearch(getDbName()).get();
logger.info(" -> got {} docs in {} index", response.getHits().totalHits(), getDbName());
return response.getHits().totalHits() == numDocs;
} catch (IndexMissingException e) {
return false;
}
}
}, 1, TimeUnit.MINUTES), equalTo(true));
}
Aggregations