Attempt at fixing IndexStatsIT.testFilterCacheStats.
I suspect recent failures are due to the fact that the cache disables itself when there is contention. This runs assertions in an assertBusy block since they should eventually succeed.
This commit is contained in:
parent
c87ba0bfa8
commit
6c8744ecb5
|
@ -30,7 +30,6 @@ import org.elasticsearch.action.admin.indices.stats.IndicesStatsResponse;
|
|||
import org.elasticsearch.action.admin.indices.stats.ShardStats;
|
||||
import org.elasticsearch.action.get.GetResponse;
|
||||
import org.elasticsearch.action.index.IndexRequestBuilder;
|
||||
import org.elasticsearch.action.search.SearchResponse;
|
||||
import org.elasticsearch.action.search.SearchType;
|
||||
import org.elasticsearch.cluster.metadata.IndexMetaData;
|
||||
import org.elasticsearch.common.bytes.BytesReference;
|
||||
|
@ -1015,22 +1014,27 @@ public class IndexStatsIT extends ESIntegTestCase {
|
|||
assertCumulativeQueryCacheStats(response);
|
||||
assertEquals(0, response.getTotal().queryCache.getCacheSize());
|
||||
|
||||
SearchResponse r;
|
||||
assertSearchResponse(r = client().prepareSearch("index").setQuery(QueryBuilders.constantScoreQuery(QueryBuilders.matchQuery("foo", "baz"))).get());
|
||||
response = client().admin().indices().prepareStats("index").setQueryCache(true).get();
|
||||
assertCumulativeQueryCacheStats(response);
|
||||
assertThat(response.getTotal().queryCache.getHitCount(), equalTo(0L));
|
||||
assertThat(response.getTotal().queryCache.getEvictions(), equalTo(0L));
|
||||
assertThat(response.getTotal().queryCache.getMissCount(), greaterThan(0L));
|
||||
assertThat(response.getTotal().queryCache.getCacheSize(), greaterThan(0L));
|
||||
// the query cache has an optimization that disables it automatically if there is contention,
|
||||
// so we run it in an assertBusy block which should eventually succeed
|
||||
assertBusy(() -> {
|
||||
assertSearchResponse(client().prepareSearch("index").setQuery(QueryBuilders.constantScoreQuery(QueryBuilders.matchQuery("foo", "baz"))).get());
|
||||
IndicesStatsResponse stats = client().admin().indices().prepareStats("index").setQueryCache(true).get();
|
||||
assertCumulativeQueryCacheStats(stats);
|
||||
assertThat(stats.getTotal().queryCache.getHitCount(), equalTo(0L));
|
||||
assertThat(stats.getTotal().queryCache.getEvictions(), equalTo(0L));
|
||||
assertThat(stats.getTotal().queryCache.getMissCount(), greaterThan(0L));
|
||||
assertThat(stats.getTotal().queryCache.getCacheSize(), greaterThan(0L));
|
||||
});
|
||||
|
||||
assertSearchResponse(client().prepareSearch("index").setQuery(QueryBuilders.constantScoreQuery(QueryBuilders.matchQuery("foo", "baz"))).get());
|
||||
response = client().admin().indices().prepareStats("index").setQueryCache(true).get();
|
||||
assertCumulativeQueryCacheStats(response);
|
||||
assertThat(response.getTotal().queryCache.getHitCount(), greaterThan(0L));
|
||||
assertThat(response.getTotal().queryCache.getEvictions(), equalTo(0L));
|
||||
assertThat(response.getTotal().queryCache.getMissCount(), greaterThan(0L));
|
||||
assertThat(response.getTotal().queryCache.getCacheSize(), greaterThan(0L));
|
||||
assertBusy(() -> {
|
||||
assertSearchResponse(client().prepareSearch("index").setQuery(QueryBuilders.constantScoreQuery(QueryBuilders.matchQuery("foo", "baz"))).get());
|
||||
IndicesStatsResponse stats = client().admin().indices().prepareStats("index").setQueryCache(true).get();
|
||||
assertCumulativeQueryCacheStats(stats);
|
||||
assertThat(stats.getTotal().queryCache.getHitCount(), greaterThan(0L));
|
||||
assertThat(stats.getTotal().queryCache.getEvictions(), equalTo(0L));
|
||||
assertThat(stats.getTotal().queryCache.getMissCount(), greaterThan(0L));
|
||||
assertThat(stats.getTotal().queryCache.getCacheSize(), greaterThan(0L));
|
||||
});
|
||||
|
||||
assertTrue(client().prepareDelete("index", "type", "1").get().isFound());
|
||||
assertTrue(client().prepareDelete("index", "type", "2").get().isFound());
|
||||
|
@ -1045,15 +1049,17 @@ public class IndexStatsIT extends ESIntegTestCase {
|
|||
indexRandom(true,
|
||||
client().prepareIndex("index", "type", "1").setSource("foo", "bar"),
|
||||
client().prepareIndex("index", "type", "2").setSource("foo", "baz"));
|
||||
assertSearchResponse(client().prepareSearch("index").setQuery(QueryBuilders.constantScoreQuery(QueryBuilders.matchQuery("foo", "baz"))).get());
|
||||
|
||||
response = client().admin().indices().prepareStats("index").setQueryCache(true).get();
|
||||
assertCumulativeQueryCacheStats(response);
|
||||
assertThat(response.getTotal().queryCache.getHitCount(), greaterThan(0L));
|
||||
assertThat(response.getTotal().queryCache.getEvictions(), greaterThan(0L));
|
||||
assertThat(response.getTotal().queryCache.getMissCount(), greaterThan(0L));
|
||||
assertThat(response.getTotal().queryCache.getCacheSize(), greaterThan(0L));
|
||||
assertThat(response.getTotal().queryCache.getMemorySizeInBytes(), greaterThan(0L));
|
||||
assertBusy(() -> {
|
||||
assertSearchResponse(client().prepareSearch("index").setQuery(QueryBuilders.constantScoreQuery(QueryBuilders.matchQuery("foo", "baz"))).get());
|
||||
IndicesStatsResponse stats = client().admin().indices().prepareStats("index").setQueryCache(true).get();
|
||||
assertCumulativeQueryCacheStats(stats);
|
||||
assertThat(stats.getTotal().queryCache.getHitCount(), greaterThan(0L));
|
||||
assertThat(stats.getTotal().queryCache.getEvictions(), greaterThan(0L));
|
||||
assertThat(stats.getTotal().queryCache.getMissCount(), greaterThan(0L));
|
||||
assertThat(stats.getTotal().queryCache.getCacheSize(), greaterThan(0L));
|
||||
assertThat(stats.getTotal().queryCache.getMemorySizeInBytes(), greaterThan(0L));
|
||||
});
|
||||
|
||||
assertAllSuccessful(client().admin().indices().prepareClearCache("index").setQueryCache(true).get());
|
||||
response = client().admin().indices().prepareStats("index").setQueryCache(true).get();
|
||||
|
|
Loading…
Reference in New Issue