From 916466a9be68530b4ee9dc0ed941abe5325147d2 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Mon, 20 Jul 2015 12:04:37 +0200 Subject: [PATCH 1/2] add await fix firstAllocationFailureTwoNodes --- .../cluster/routing/allocation/FailedShardsRoutingTests.java | 1 + 1 file changed, 1 insertion(+) diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java index 569018c431d..a1c9529d7c9 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java @@ -333,6 +333,7 @@ public class FailedShardsRoutingTests extends ElasticsearchAllocationTestCase { } @Test + @AwaitsFix(bugUrl = "boaz is looking into failures: http://build-us-00.elastic.co/job/es_core_master_strong/4168/") public void firstAllocationFailureTwoNodes() { AllocationService strategy = createAllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) From 64750fa8bba3faa41ac8411e6e43b4b57ea6b181 Mon Sep 17 00:00:00 2001 From: Boaz Leskes Date: Mon, 20 Jul 2015 12:23:12 +0200 Subject: [PATCH 2/2] Test: firstAllocationFailureTwoNodes used hard coded node reference The test starts two nodes and two shards and expects the primary shard to be allocated on the first node. Very rarely this is not the case. --- .../routing/allocation/FailedShardsRoutingTests.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java index a1c9529d7c9..a53206494d6 100644 --- a/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java +++ b/core/src/test/java/org/elasticsearch/cluster/routing/allocation/FailedShardsRoutingTests.java @@ -19,6 +19,7 @@ package org.elasticsearch.cluster.routing.allocation; +import com.carrotsearch.randomizedtesting.annotations.Repeat; import com.google.common.collect.ImmutableList; import org.elasticsearch.Version; import org.elasticsearch.cluster.ClusterState; @@ -333,7 +334,6 @@ public class FailedShardsRoutingTests extends ElasticsearchAllocationTestCase { } @Test - @AwaitsFix(bugUrl = "boaz is looking into failures: http://build-us-00.elastic.co/job/es_core_master_strong/4168/") public void firstAllocationFailureTwoNodes() { AllocationService strategy = createAllocationService(settingsBuilder() .put("cluster.routing.allocation.concurrent_recoveries", 10) @@ -372,11 +372,14 @@ public class FailedShardsRoutingTests extends ElasticsearchAllocationTestCase { logger.info("fail the first shard, will start INITIALIZING on the second node"); prevRoutingTable = routingTable; - final ShardRouting firstShard = clusterState.routingNodes().node("node1").get(0); + final ShardRouting firstShard = clusterState.routingNodes().node(nodeHoldingPrimary).get(0); routingTable = strategy.applyFailedShard(clusterState, firstShard).routingTable(); clusterState = ClusterState.builder(clusterState).routingTable(routingTable).build(); - assertThat(prevRoutingTable != routingTable, equalTo(true)); + + final String nodeHoldingPrimary2 = routingTable.index("test").shard(0).primaryShard().currentNodeId(); + assertThat(nodeHoldingPrimary2, not(equalTo(nodeHoldingPrimary))); + assertThat(routingTable.index("test").shards().size(), equalTo(1)); for (int i = 0; i < routingTable.index("test").shards().size(); i++) { assertThat(routingTable.index("test").shard(i).size(), equalTo(2));