From 57c5efacf604f83496f8c48c585de108972d73e5 Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Mon, 14 Sep 2015 07:54:05 -0400 Subject: [PATCH] Fix test bug in o.e.a.s.b.n.TransportBroadcastByNodeActionTests This commit fixes a test bug in o.e.a.s.b.n.TransportBroadcastByNodeActionTests. Namely, the randomized test allowed for the creation of cluster states that allocated indices having zero shards. This ultimately surfaced in a NoSuchElementException when attempting to iterate over the nonexistent shards. The fix is merely to draw the random number of shards from 1 to 10 instead of 0 to 10. --- .../broadcast/node/TransportBroadcastByNodeActionTests.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java b/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java index 14ee78a7cfb..18a86b1dea0 100644 --- a/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java +++ b/core/src/test/java/org/elasticsearch/action/support/broadcast/node/TransportBroadcastByNodeActionTests.java @@ -206,7 +206,7 @@ public class TransportBroadcastByNodeActionTests extends ESTestCase { for (int i = 0; i < numberOfNodes; i++) { final DiscoveryNode node = newNode(i); discoBuilder = discoBuilder.put(node); - int numberOfShards = randomIntBetween(0, 10); + int numberOfShards = randomIntBetween(1, 10); for (int j = 0; j < numberOfShards; j++) { final ShardId shardId = new ShardId(index, ++shardIndex); ShardRouting shard = TestShardRouting.newShardRouting(index, shardId.getId(), node.id(), true, ShardRoutingState.STARTED, 1);