From 7a595d79119f4da5e009b984648d1b0aac361e0e Mon Sep 17 00:00:00 2001 From: Adrien Grand Date: Tue, 31 Mar 2015 12:28:02 +0200 Subject: [PATCH] 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. --- .../indices/cache/query/IndicesQueryCacheTests.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/test/java/org/elasticsearch/indices/cache/query/IndicesQueryCacheTests.java b/src/test/java/org/elasticsearch/indices/cache/query/IndicesQueryCacheTests.java index 138be27e251..77bd1d63add 100644 --- a/src/test/java/org/elasticsearch/indices/cache/query/IndicesQueryCacheTests.java +++ b/src/test/java/org/elasticsearch/indices/cache/query/IndicesQueryCacheTests.java @@ -20,6 +20,7 @@ package org.elasticsearch.indices.cache.query; 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.Histogram; 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 // which used to not work well with the query cache because of the handles stream output // 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(); - assertSearchResponse(r1); + assertSearchResponse(r1);System.out.println(r1); // The cached is actually used assertThat(client().admin().indices().prepareStats("index").setQueryCache(true).get().getTotal().getQueryCache().getMemorySizeInBytes(), greaterThan(0l)); 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(); assertSearchResponse(r2); Histogram h1 = r1.getAggregations().get("histo");