[TEST] Force flush even if not needed to ensure successful shards is greater than 0

This commit is contained in:
Simon Willnauer 2014-06-16 11:00:34 +02:00
parent 76fab9d42a
commit 93b56eb004
2 changed files with 6 additions and 1 deletions

View File

@ -38,6 +38,11 @@ public class FlushRequestBuilder extends BroadcastOperationRequestBuilder<FlushR
return this; return this;
} }
public FlushRequestBuilder setForce(boolean force) {
request.force(force);
return this;
}
@Override @Override
protected void doExecute(ActionListener<FlushResponse> listener) { protected void doExecute(ActionListener<FlushResponse> listener) {
((IndicesAdminClient) client).flush(request, listener); ((IndicesAdminClient) client).flush(request, listener);

View File

@ -851,7 +851,7 @@ public class GetActionTests extends ElasticsearchIntegrationTest {
assertThat(getResponse.getField(field).getValues().get(0).toString(), equalTo("value1")); assertThat(getResponse.getField(field).getValues().get(0).toString(), equalTo("value1"));
assertThat(getResponse.getField(field).getValues().get(1).toString(), equalTo("value2")); assertThat(getResponse.getField(field).getValues().get(1).toString(), equalTo("value2"));
FlushResponse flushResponse = client().admin().indices().prepareFlush("my-index").get(); FlushResponse flushResponse = client().admin().indices().prepareFlush("my-index").setForce(true).get();
// the flush must at least succeed on one shard and not all shards, because we don't wait for yellow/green // the flush must at least succeed on one shard and not all shards, because we don't wait for yellow/green
assertThat(flushResponse.getSuccessfulShards(), greaterThanOrEqualTo(1)); assertThat(flushResponse.getSuccessfulShards(), greaterThanOrEqualTo(1));