From a1f66daea97b2e42572fd56cd545cfaa85254e8a Mon Sep 17 00:00:00 2001 From: Simon Willnauer Date: Thu, 27 Feb 2014 23:11:43 +0100 Subject: [PATCH] Move ensureEstimatedStats() after index wiping to ensure everything is cleaned up once the index is removed --- .../test/ElasticsearchIntegrationTest.java | 23 +++++++++---------- 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java index d453e20390a..0c896b02e0e 100644 --- a/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java +++ b/src/test/java/org/elasticsearch/test/ElasticsearchIntegrationTest.java @@ -251,16 +251,12 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase .transientSettings().getAsMap().size(), equalTo(0)); } - try { - ensureEstimatedStats(); - } finally { - wipeIndices("_all"); // wipe after to make sure we fail in the test that - // didn't ack the delete - wipeTemplates(); - wipeRepositories(); - } + wipeIndices("_all"); // wipe after to make sure we fail in the test that didn't ack the delete + wipeTemplates(); + wipeRepositories(); ensureAllSearchersClosed(); ensureAllFilesClosed(); + ensureEstimatedStats(); logger.info("[{}#{}]: cleaned up after test", getTestClass().getSimpleName(), getTestName()); } catch (OutOfMemoryError e) { if (e.getMessage().contains("unable to create new native thread")) { @@ -346,14 +342,17 @@ public abstract class ElasticsearchIntegrationTest extends ElasticsearchTestCase return ImmutableSettings.EMPTY; } - public static void ensureEstimatedStats() { + /** + * Ensures that the breaker statistics are reset to 0 since we wiped all indices and that + * means all stats should be set to 0 otherwise something is wrong with the field data + * calculation. + */ + private static void ensureEstimatedStats() { if (cluster().size() > 0) { - ClearIndicesCacheResponse all = client().admin().indices().prepareClearCache("_all").setFieldDataCache(true).execute().actionGet(); - assertNoFailures(all); NodesStatsResponse nodeStats = client().admin().cluster().prepareNodesStats() .clear().setBreaker(true).execute().actionGet(); for (NodeStats stats : nodeStats.getNodes()) { - assertThat("Breaker reset to 0 - cleared on [" + all.getSuccessfulShards() + "] shards total [" + all.getTotalShards() + "]", + assertThat("Breaker not reset to 0 on node: " + stats.getNode(), stats.getBreaker().getEstimated(), equalTo(0L)); } }