summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoaz Leskes <b.leskes@gmail.com>2017-07-02 21:19:51 +0200
committerBoaz Leskes <b.leskes@gmail.com>2017-07-02 21:19:51 +0200
commita4fae1540ea14331467199309d4eb7551a91f700 (patch)
treea03ebd03d9fe77177f0b4425cbf93d50f7ef03be
parent5a7c8bb04ed135be1823a4db6b08f7481d7d22c0 (diff)
testPrimaryFailureIncreasesTerm should use assertBusy to wait for yellow
ensureYellow ensures at least yellow. Also, since we only have 1 replica, we don't need to index for it to know about the primary term promotion Closes #25287
-rw-r--r--core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java23
1 files changed, 3 insertions, 20 deletions
diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java
index 01c335e6ec..de82e72f9d 100644
--- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java
+++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/ShardStateIT.java
@@ -18,12 +18,9 @@
*/
package org.elasticsearch.cluster.routing.allocation;
-import org.elasticsearch.action.index.IndexRequest;
import org.elasticsearch.cluster.ClusterState;
import org.elasticsearch.cluster.health.ClusterHealthStatus;
import org.elasticsearch.cluster.metadata.IndexMetaData;
-import org.elasticsearch.cluster.routing.Murmur3HashFunction;
-import org.elasticsearch.common.xcontent.XContentType;
import org.elasticsearch.index.IndexService;
import org.elasticsearch.index.shard.IndexShard;
import org.elasticsearch.indices.IndicesService;
@@ -51,23 +48,9 @@ public class ShardStateIT extends ESIntegTestCase {
indicesService.indexService(resolveIndex("test")).getShard(shard).failShard("simulated test failure", null);
logger.info("--> waiting for a yellow index");
- ensureYellow();
-
- // this forces the primary term to propagate to the replicas
- int id = 0;
- while (true) {
- // find an ID that routes to the right shard, we will only index to the shard that saw a primary failure
- final String idAsString = Integer.toString(id);
- final int hash = Math.floorMod(Murmur3HashFunction.hash(idAsString), 2);
- if (hash == shard) {
- client()
- .index(new IndexRequest("test", "type", idAsString).source("{ \"f\": \"" + idAsString + "\"}", XContentType.JSON))
- .get();
- break;
- } else {
- id++;
- }
- }
+ // we can't use ensureYellow since that one is just as happy with a GREEN status.
+ assertBusy(() ->
+ assertThat(client().admin().cluster().prepareHealth("test").get().getStatus(), equalTo(ClusterHealthStatus.YELLOW)));
final long term0 = shard == 0 ? 2 : 1;
final long term1 = shard == 1 ? 2 : 1;