Browse Source

[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.
Britta Weber 11 years ago
parent
commit
57b77c6907

+ 1 - 0
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");

+ 3 - 2
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();