From 0ad390fee072bc4d01dbd21ba5baa0ae49701421 Mon Sep 17 00:00:00 2001 From: Shalin Shekhar Mangar Date: Sat, 14 Feb 2015 19:44:51 +0000 Subject: [PATCH] SOLR-7112: Fix DeleteInactiveReplicaTest.deleteLiveReplicaTest test failures git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1659850 13f79535-47bb-0310-9956-ffa450edef68 --- solr/CHANGES.txt | 3 +++ .../solr/cloud/DeleteInactiveReplicaTest.java | 17 +++++++++++++---- .../apache/solr/cloud/DeleteReplicaTest.java | 9 ++------- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt index 226689760f9..8375608ae6c 100644 --- a/solr/CHANGES.txt +++ b/solr/CHANGES.txt @@ -164,6 +164,9 @@ Other Changes when no qt or shard.qt parameter is specified; fix also resolves SOLR-4479. (Steve Molloy, Timothy Potter) +* SOLR-7112: Fix DeleteInactiveReplicaTest.deleteLiveReplicaTest test failures. + (shalin) + ================== 5.0.0 ================== Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release. diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java index 3ad3d996a70..88a97adafb8 100644 --- a/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/DeleteInactiveReplicaTest.java @@ -32,13 +32,16 @@ import org.apache.solr.common.util.NamedList; import org.junit.Test; import java.net.URL; +import java.util.HashMap; +import java.util.List; import java.util.Map; import static org.apache.solr.cloud.CollectionsAPIDistributedZkTest.setClusterProp; +import static org.apache.solr.cloud.OverseerCollectionProcessor.NUM_SLICES; import static org.apache.solr.common.cloud.ZkNodeProps.makeMap; +import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE; -//@Ignore("Not currently valid see SOLR-5580") -public class DeleteInactiveReplicaTest extends DeleteReplicaTest{ +public class DeleteInactiveReplicaTest extends AbstractFullDistribZkTestBase{ @Test public void deleteInactiveReplicaTest() throws Exception { @@ -48,7 +51,13 @@ public class DeleteInactiveReplicaTest extends DeleteReplicaTest{ setClusterProp(client, ZkStateReader.LEGACY_CLOUD, "false"); - createCollection(collectionName, client); + int replicationFactor = 2; + int numShards = 2; + int maxShardsPerNode = ((((numShards+1) * replicationFactor) / getCommonCloudSolrClient() + .getZkStateReader().getClusterState().getLiveNodes().size())) + 1; + + Map> collectionInfos = new HashMap<>(); + createCollection(collectionInfos, collectionName, numShards, replicationFactor, maxShardsPerNode, client, null); waitForRecoveriesToFinish(collectionName, false); @@ -109,7 +118,7 @@ public class DeleteInactiveReplicaTest extends DeleteReplicaTest{ } log.info("removed_replicas {}/{} ", shard1.getName(), replica1.getName()); - removeAndWaitForReplicaGone(collectionName, client, replica1, + DeleteReplicaTest.removeAndWaitForReplicaGone(collectionName, client, replica1, shard1.getName()); ChaosMonkey.start(stoppedJetty); log.info("restarted jetty"); diff --git a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java index 9fb53c31cc8..18ac8e8549b 100644 --- a/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java +++ b/solr/core/src/test/org/apache/solr/cloud/DeleteReplicaTest.java @@ -50,11 +50,6 @@ import static org.apache.solr.common.params.CollectionParams.CollectionAction.DE public class DeleteReplicaTest extends AbstractFullDistribZkTestBase { private CloudSolrClient client; - @BeforeClass - public static void beforeThisClass2() throws Exception { - - } - @Override public void distribSetUp() throws Exception { super.distribSetUp(); @@ -146,7 +141,7 @@ public class DeleteReplicaTest extends AbstractFullDistribZkTestBase { client.request(request); } - protected void removeAndWaitForReplicaGone(String COLL_NAME, + static void removeAndWaitForReplicaGone(String COLL_NAME, CloudSolrClient client, Replica replica, String shard) throws SolrServerException, IOException, InterruptedException { Map m = makeMap("collection", COLL_NAME, "action", DELETEREPLICA.toLower(), "shard", @@ -159,7 +154,7 @@ public class DeleteReplicaTest extends AbstractFullDistribZkTestBase { boolean success = false; DocCollection testcoll = null; while (System.currentTimeMillis() < endAt) { - testcoll = getCommonCloudSolrClient().getZkStateReader() + testcoll = client.getZkStateReader() .getClusterState().getCollection(COLL_NAME); success = testcoll.getSlice(shard).getReplica(replica.getName()) == null; if (success) {