From f98ca5310cc1e8f0b2f1fd478f90f6599abe15c4 Mon Sep 17 00:00:00 2001 From: Yannick Welsch Date: Thu, 26 May 2016 19:00:26 +0200 Subject: [PATCH] Fix ReplicaShardAllocatorTests when unassigned reason is ALLOCATION_FAILED When mocking unassigned shards which have failed with reason ALLOCATION_FAILED we have to ensure that the failed allocation counter is strictly positive. --- .../org/elasticsearch/gateway/ReplicaShardAllocatorTests.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java b/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java index 82004448658..38dc2f9e632 100644 --- a/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java +++ b/core/src/test/java/org/elasticsearch/gateway/ReplicaShardAllocatorTests.java @@ -291,12 +291,14 @@ public class ReplicaShardAllocatorTests extends ESAllocationTestCase { // mark shard as delayed if reason is NODE_LEFT boolean delayed = reason == UnassignedInfo.Reason.NODE_LEFT && UnassignedInfo.INDEX_DELAYED_NODE_LEFT_TIMEOUT_SETTING.get(settings).nanos() > 0; + int failedAllocations = reason == UnassignedInfo.Reason.ALLOCATION_FAILED ? 1 : 0; RoutingTable routingTable = RoutingTable.builder() .add(IndexRoutingTable.builder(shardId.getIndex()) .addIndexShard(new IndexShardRoutingTable.Builder(shardId) .addShard(primaryShard) .addShard(ShardRouting.newUnassigned(shardId, null, false, - new UnassignedInfo(reason, null, null, 0, System.nanoTime(), System.currentTimeMillis(), delayed))) + new UnassignedInfo(reason, null, null, failedAllocations, System.nanoTime(), + System.currentTimeMillis(), delayed))) .build()) ) .build();