From 57b77c6907482d0158228cc4b02a2d9644cc0de0 Mon Sep 17 00:00:00 2001 From: Britta Weber Date: Wed, 10 Dec 2014 17:28:32 +0100 Subject: [PATCH] [TEST] wait for yellow to avoid searching while relocating After upgrading shard might start relocating again. If there are no replicas the cluster state of a node might not be up to data for a few miliseconds and direct a search request to a node that does not have the shard anymore. This result in the following test failures: 1> java.lang.AssertionError: Count is 99 but 101 was expected. Total shards: 13 Successful shards: 12 & 0 shard failures: 1> __randomizedtesting.SeedInfo.seed([1932F73B458703CA:6F4FAD3DAC55591C]:0) 1> [...org.junit.*] 1> org.elasticsearch.test.hamcrest.ElasticsearchAssertions.assertHitCount(ElasticsearchAssertions.java:184) 1> org.elasticsearch.bwcompat.BasicBackwardsCompatibilityTest.testIndexRollingUpgrade(BasicBackwardsCompatibilityTest.java:358) Waiting for relocation finished should fix this. --- .../bwcompat/BasicBackwardsCompatibilityTest.java | 1 + .../search/basic/SearchWhileRelocatingTests.java | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityTest.java b/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityTest.java index b94b6330777..7eff7728bbc 100644 --- a/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityTest.java +++ b/src/test/java/org/elasticsearch/bwcompat/BasicBackwardsCompatibilityTest.java @@ -350,6 +350,7 @@ public class BasicBackwardsCompatibilityTest extends ElasticsearchBackwardsCompa indexRandom(true, docs); } while (upgraded); client().admin().indices().prepareUpdateSettings(indices).setSettings(ImmutableSettings.builder().put(EnableAllocationDecider.INDEX_ROUTING_ALLOCATION_ENABLE, "all")).get(); + ensureYellow(); CountResponse countResponse = client().prepareCount().get(); assertHitCount(countResponse, numDocs); assertSimpleSort("num_double", "num_int"); diff --git a/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java b/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java index dddd3efa5c3..8c0f6edcb14 100644 --- a/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java +++ b/src/test/java/org/elasticsearch/search/basic/SearchWhileRelocatingTests.java @@ -25,6 +25,7 @@ import org.elasticsearch.action.index.IndexRequestBuilder; import org.elasticsearch.action.search.SearchPhaseExecutionException; import org.elasticsearch.action.search.SearchResponse; import org.elasticsearch.client.Client; +import org.elasticsearch.common.Priority; import org.elasticsearch.search.SearchHits; import org.elasticsearch.test.ElasticsearchIntegrationTest; import org.hamcrest.Matchers; @@ -130,12 +131,12 @@ public class SearchWhileRelocatingTests extends ElasticsearchIntegrationTest { } allowNodes("test", between(1, 3)); client().admin().cluster().prepareReroute().get(); - // this might time out on some machines if they are really busy and you hit lots of throttling - ClusterHealthResponse resp = client().admin().cluster().prepareHealth().setWaitForRelocatingShards(0).setTimeout("5m").get(); stop.set(true); for (int j = 0; j < threads.length; j++) { threads[j].join(); } + // this might time out on some machines if they are really busy and you hit lots of throttling + ClusterHealthResponse resp = client().admin().cluster().prepareHealth().setWaitForRelocatingShards(0).setWaitForEvents(Priority.LANGUID).setTimeout("5m").get(); assertNoTimeout(resp); if (!thrownExceptions.isEmpty() || !nonCriticalExceptions.isEmpty()) { Client client = client();