IndicesQueryCacheTests: Fix test bug.

The query cache is disabled on dfs_query_then_fetch so we need to enforce
query_then_fetch instead of relying on the randomized search type set by the
test framework.
This commit is contained in:
Adrien Grand 2015-03-31 12:28:02 +02:00
parent 0a6be2c111
commit 7a595d7911
1 changed files with 4 additions and 3 deletions

View File

@ -20,6 +20,7 @@
package org.elasticsearch.indices.cache.query; package org.elasticsearch.indices.cache.query;
import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.action.search.SearchType;
import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval; import org.elasticsearch.search.aggregations.bucket.histogram.DateHistogramInterval;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram; import org.elasticsearch.search.aggregations.bucket.histogram.Histogram;
import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket; import org.elasticsearch.search.aggregations.bucket.histogram.Histogram.Bucket;
@ -47,15 +48,15 @@ public class IndicesQueryCacheTests extends ElasticsearchIntegrationTest {
// This is not a random example: serialization with time zones writes shared strings // This is not a random example: serialization with time zones writes shared strings
// which used to not work well with the query cache because of the handles stream output // which used to not work well with the query cache because of the handles stream output
// see #9500 // see #9500
final SearchResponse r1 = client().prepareSearch("index").setSize(0) final SearchResponse r1 = client().prepareSearch("index").setSize(0).setSearchType(SearchType.QUERY_THEN_FETCH)
.addAggregation(dateHistogram("histo").field("f").timeZone("+01:00").minDocCount(0).interval(DateHistogramInterval.MONTH)).get(); .addAggregation(dateHistogram("histo").field("f").timeZone("+01:00").minDocCount(0).interval(DateHistogramInterval.MONTH)).get();
assertSearchResponse(r1); assertSearchResponse(r1);System.out.println(r1);
// The cached is actually used // The cached is actually used
assertThat(client().admin().indices().prepareStats("index").setQueryCache(true).get().getTotal().getQueryCache().getMemorySizeInBytes(), greaterThan(0l)); assertThat(client().admin().indices().prepareStats("index").setQueryCache(true).get().getTotal().getQueryCache().getMemorySizeInBytes(), greaterThan(0l));
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
final SearchResponse r2 = client().prepareSearch("index").setSize(0) final SearchResponse r2 = client().prepareSearch("index").setSize(0).setSearchType(SearchType.QUERY_THEN_FETCH)
.addAggregation(dateHistogram("histo").field("f").timeZone("+01:00").minDocCount(0).interval(DateHistogramInterval.MONTH)).get(); .addAggregation(dateHistogram("histo").field("f").timeZone("+01:00").minDocCount(0).interval(DateHistogramInterval.MONTH)).get();
assertSearchResponse(r2); assertSearchResponse(r2);
Histogram h1 = r1.getAggregations().get("histo"); Histogram h1 = r1.getAggregations().get("histo");