[TEST] Use client node such that we always have to do a round-trip to do a fetch.

This commit is contained in:
Simon Willnauer 2014-03-17 13:55:13 +01:00
parent 5f1d9af9fe
commit ff039019c5
2 changed files with 16 additions and 1 deletions

View File

@ -27,6 +27,7 @@ import org.elasticsearch.common.unit.TimeValue;
import org.elasticsearch.common.xcontent.ToXContent;
import org.elasticsearch.common.xcontent.XContentBuilder;
import org.elasticsearch.common.xcontent.XContentBuilderString;
import org.elasticsearch.common.xcontent.XContentFactory;
import java.io.IOException;
import java.util.HashMap;
@ -264,4 +265,17 @@ public class SearchStats implements Streamable, ToXContent {
}
}
}
@Override
public String toString() {
try {
XContentBuilder builder = XContentFactory.jsonBuilder().prettyPrint();
builder.startObject();
toXContent(builder, EMPTY_PARAMS);
builder.endObject();
return builder.string();
} catch (IOException e) {
return "{ \"error\" : \"" + e.getMessage() + "\"}";
}
}
}

View File

@ -91,12 +91,13 @@ public class SearchStatsTests extends ElasticsearchIntegrationTest {
refresh();
int iters = scaledRandomIntBetween(20, 50);
for (int i = 0; i < iters; i++) {
SearchResponse searchResponse = client().prepareSearch().setQuery(QueryBuilders.termQuery("field", "value")).setStats("group1", "group2").execute().actionGet();
SearchResponse searchResponse = cluster().clientNodeClient().prepareSearch().setQuery(QueryBuilders.termQuery("field", "value")).setStats("group1", "group2").execute().actionGet();
assertHitCount(searchResponse, docsTest1 + docsTest2);
assertAllSuccessful(searchResponse);
}
IndicesStatsResponse indicesStats = client().admin().indices().prepareStats().execute().actionGet();
logger.debug("###### indices search stats: " + indicesStats.getTotal().getSearch());
assertThat(indicesStats.getTotal().getSearch().getTotal().getQueryCount(), greaterThan(0l));
assertThat(indicesStats.getTotal().getSearch().getTotal().getQueryTimeInMillis(), greaterThan(0l));
assertThat(indicesStats.getTotal().getSearch().getTotal().getFetchCount(), greaterThan(0l));