From b28c82a1e6e025cc8e9e55e078b555198c8577a3 Mon Sep 17 00:00:00 2001 From: Luca Cavanna Date: Sat, 21 Sep 2013 20:08:55 +0200 Subject: [PATCH] Added @TestLogging to all methods to see which shards we refresh and which ones we search on Increased wait timeout and added multiple iterations there as well, one is not enough. We want to verify whether the problem gets fixed later on. --- .../recovery/RecoveryWhileUnderLoadTests.java | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadTests.java b/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadTests.java index d87c4d518b4..dae679e43c6 100644 --- a/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadTests.java +++ b/src/test/java/org/elasticsearch/recovery/RecoveryWhileUnderLoadTests.java @@ -131,7 +131,7 @@ public class RecoveryWhileUnderLoadTests extends AbstractIntegrationTest { iterateAssertCount(5, indexCounter.get(), 10); } - @Test + @Test @TestLogging("action.search.type:TRACE,action.admin.indices.refresh:TRACE") @Slow public void recoverWhileUnderLoadAllocateBackupsRelocatePrimariesTest() throws Exception { logger.info("--> creating test index ..."); @@ -205,7 +205,7 @@ public class RecoveryWhileUnderLoadTests extends AbstractIntegrationTest { iterateAssertCount(5, indexCounter.get(), 10); } - @Test + @Test @TestLogging("action.search.type:TRACE,action.admin.indices.refresh:TRACE") @Slow public void recoverWhileUnderLoadWithNodeShutdown() throws Exception { logger.info("--> creating test index ..."); @@ -297,7 +297,7 @@ public class RecoveryWhileUnderLoadTests extends AbstractIntegrationTest { } - private void iterateAssertCount(final int numberOfShards, final long numberOfDocs, int iterations) throws Exception { + private void iterateAssertCount(final int numberOfShards, final long numberOfDocs, final int iterations) throws Exception { SearchResponse[] iterationResults = new SearchResponse[iterations]; boolean error = false; for (int i = 0; i < iterations; i++) { @@ -314,19 +314,24 @@ public class RecoveryWhileUnderLoadTests extends AbstractIntegrationTest { IndicesStatsResponse indicesStatsResponse = client().admin().indices().prepareStats().get(); for (ShardStats shardStats : indicesStatsResponse.getShards()) { DocsStats docsStats = shardStats.getStats().docs; - logger.info("Shard [{}] - count {}, primary {}", shardStats.getShardId(), docsStats.getCount(), shardStats.getShardRouting().primary()); + logger.info("shard [{}] - count {}, primary {}", shardStats.getShardId(), docsStats.getCount(), shardStats.getShardRouting().primary()); } //if there was an error we try to wait and see if at some point it'll get fixed - //otherwise it means we are losing documents logger.info("--> trying to wait"); assertThat(awaitBusy(new Predicate() { @Override public boolean apply(Object o) { - SearchResponse searchResponse = client().prepareSearch().setSearchType(SearchType.COUNT).setQuery(matchAllQuery()).get(); - return searchResponse.getHits().totalHits() == numberOfDocs; + boolean error = false; + for (int i = 0; i < iterations; i++) { + SearchResponse searchResponse = client().prepareSearch().setSearchType(SearchType.COUNT).setQuery(matchAllQuery()).get(); + if (searchResponse.getHits().totalHits() != numberOfDocs) { + error = true; + } + } + return !error; } - }, 30, TimeUnit.SECONDS), equalTo(true)); + }, 5, TimeUnit.MINUTES), equalTo(true)); } //lets now make the test fail if it was supposed to fail