You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by sh...@apache.org on 2014/07/14 10:59:19 UTC
svn commit: r1610365 - in /lucene/dev/branches/branch_4x: ./ solr/
solr/CHANGES.txt solr/core/
solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
Author: shalin
Date: Mon Jul 14 08:59:18 2014
New Revision: 1610365
URL: http://svn.apache.org/r1610365
Log:
SOLR-6241: Harden the HttpPartitionTest
Modified:
lucene/dev/branches/branch_4x/ (props changed)
lucene/dev/branches/branch_4x/solr/ (props changed)
lucene/dev/branches/branch_4x/solr/CHANGES.txt (contents, props changed)
lucene/dev/branches/branch_4x/solr/core/ (props changed)
lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
Modified: lucene/dev/branches/branch_4x/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/CHANGES.txt?rev=1610365&r1=1610364&r2=1610365&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/CHANGES.txt (original)
+++ lucene/dev/branches/branch_4x/solr/CHANGES.txt Mon Jul 14 08:59:18 2014
@@ -132,6 +132,8 @@ Other Changes
* SOLR-6240: Removed unused coreName parameter in ZkStateReader.getReplicaProps. (shalin)
+* SOLR-6241: Harden the HttpPartitionTest. (shalin)
+
================== 4.9.0 ==================
Versions of Major Components
Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java?rev=1610365&r1=1610364&r2=1610365&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java Mon Jul 14 08:59:18 2014
@@ -26,12 +26,14 @@ import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.concurrent.TimeUnit;
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.JSONTestUtil;
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.impl.HttpSolrServer;
+import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.ClusterState;
@@ -216,6 +218,16 @@ public class HttpPartitionTest extends A
// verify all docs received
assertDocsExistInAllReplicas(notLeaders, testCollectionName, 1, numDocs + 3);
+
+ // try to clean up
+ try {
+ CollectionAdminRequest req = new CollectionAdminRequest.Delete();
+ req.setCollectionName(testCollectionName);
+ req.process(cloudClient);
+ } catch (Exception e) {
+ // don't fail the test
+ log.warn("Could not delete collection {} after test completed", testCollectionName);
+ }
}
protected void testRf3() throws Exception {
@@ -261,7 +273,16 @@ public class HttpPartitionTest extends A
sendDoc(4);
- assertDocsExistInAllReplicas(notLeaders, testCollectionName, 1, 4);
+ assertDocsExistInAllReplicas(notLeaders, testCollectionName, 1, 4);
+ // try to clean up
+ try {
+ CollectionAdminRequest req = new CollectionAdminRequest.Delete();
+ req.setCollectionName(testCollectionName);
+ req.process(cloudClient);
+ } catch (Exception e) {
+ // don't fail the test
+ log.warn("Could not delete collection {} after test completed", testCollectionName);
+ }
}
protected void testRf3WithLeaderFailover() throws Exception {
@@ -360,17 +381,22 @@ public class HttpPartitionTest extends A
proxy0.reopen();
- Thread.sleep(10000L);
-
- cloudClient.getZkStateReader().updateClusterState(true);
-
+ long timeout = System.nanoTime() + TimeUnit.NANOSECONDS.convert(60, TimeUnit.SECONDS);
+ while (System.nanoTime() < timeout) {
+ cloudClient.getZkStateReader().updateClusterState(true);
+
+ List<Replica> activeReps = getActiveOrRecoveringReplicas(testCollectionName, "shard1");
+ if (activeReps.size() == 2) break;
+ Thread.sleep(1000);
+ }
+
List<Replica> activeReps = getActiveOrRecoveringReplicas(testCollectionName, "shard1");
assertTrue("Expected 2 of 3 replicas to be active but only found "+
- activeReps.size()+"; "+activeReps+"; clusterState: "+printClusterStateInfo(),
- activeReps.size() == 2);
-
+ activeReps.size()+"; "+activeReps+"; clusterState: "+printClusterStateInfo(),
+ activeReps.size() == 2);
+
sendDoc(6);
-
+
assertDocsExistInAllReplicas(activeReps, testCollectionName, 1, 6);
}
@@ -383,7 +409,6 @@ public class HttpPartitionTest extends A
Map<String,Replica> activeReplicas = new HashMap<String,Replica>();
ZkStateReader zkr = cloudClient.getZkStateReader();
ClusterState cs = zkr.getClusterState();
- cs = zkr.getClusterState();
assertNotNull(cs);
for (Slice shard : cs.getActiveSlices(testCollectionName)) {
if (shard.getName().equals(shardId)) {