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
This commit is contained in:
Shalin Shekhar Mangar 2015-02-14 19:44:51 +00:00
parent 74387f8d68
commit 0ad390fee0
3 changed files with 18 additions and 11 deletions

View File

@ -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.

View File

@ -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<String,List<Integer>> 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");

View File

@ -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) {