lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thelabd...@apache.org
Subject svn commit: r1596636 - /lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
Date Wed, 21 May 2014 18:05:53 GMT
Author: thelabdude
Date: Wed May 21 18:05:53 2014
New Revision: 1596636

URL: http://svn.apache.org/r1596636
Log:
SOLR-5495: Print cluster state in assertion failure messages if a leader cannot be found to
determine root cause of HttpPartitionTest failures in Jenkins.

Modified:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java?rev=1596636&r1=1596635&r2=1596636&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java Wed May
21 18:05:53 2014
@@ -58,7 +58,7 @@ public class HttpPartitionTest extends A
   
   // To prevent the test assertions firing too fast before cluster state
   // recognizes (and propagates) partitions
-  private static final long sleepMsBeforeHealPartition = 1000L;
+  private static final long sleepMsBeforeHealPartition = 2000L;
   
   private static final int maxWaitSecsToSeeAllActive = 30;
   
@@ -229,7 +229,7 @@ public class HttpPartitionTest extends A
         ensureAllReplicasAreActive(testCollectionName, 3, maxWaitSecsToSeeAllActive);
     assertTrue("Expected 2 replicas for collection " + testCollectionName
         + " but found " + notLeaders.size() + "; clusterState: "
-        + cloudClient.getZkStateReader().getClusterState(),
+        + printClusterStateInfo(),
         notLeaders.size() == 2);
     
     sendDoc(1);
@@ -277,7 +277,7 @@ public class HttpPartitionTest extends A
         ensureAllReplicasAreActive(testCollectionName, 3, maxWaitSecsToSeeAllActive);
     assertTrue("Expected 2 replicas for collection " + testCollectionName
         + " but found " + notLeaders.size() + "; clusterState: "
-        + cloudClient.getZkStateReader().getClusterState(),
+        + printClusterStateInfo(),
         notLeaders.size() == 2);
         
     sendDoc(1);
@@ -314,7 +314,8 @@ public class HttpPartitionTest extends A
     Replica leader = 
         cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1");
     String leaderNode = leader.getNodeName();
-    assertNotNull("Could not find leader for shard1 of "+testCollectionName, leader);
+    assertNotNull("Could not find leader for shard1 of "+
+      testCollectionName+"; clusterState: "+printClusterStateInfo(), leader);
     JettySolrRunner leaderJetty = getJettyOnPort(getReplicaPort(leader));
     
     // since maxShardsPerNode is 1, we're safe to kill the leader
@@ -343,16 +344,17 @@ public class HttpPartitionTest extends A
       log.warn("No SocketProxy found for old leader node "+leaderNode);      
     }
 
-    Thread.sleep(sleepMsBeforeHealPartition);
+    Thread.sleep(10000); // give chance for new leader to be elected.
     
     Replica newLeader = 
         cloudClient.getZkStateReader().getLeaderRetry(testCollectionName, "shard1", 60000);
         
-    assertNotNull("No new leader was elected after 60 seconds", newLeader);
+    assertNotNull("No new leader was elected after 60 seconds; clusterState: "+
+      printClusterStateInfo(),newLeader);
         
     assertTrue("Expected node "+shouldNotBeNewLeaderNode+
         " to NOT be the new leader b/c it was out-of-sync with the old leader! ClusterState:
"+
-        cloudClient.getZkStateReader().getClusterState(), 
+        printClusterStateInfo(), 
         !shouldNotBeNewLeaderNode.equals(newLeader.getNodeName()));
     
     proxy0.reopen();
@@ -362,12 +364,19 @@ public class HttpPartitionTest extends A
     cloudClient.getZkStateReader().updateClusterState(true);
     
     List<Replica> activeReps = getActiveOrRecoveringReplicas(testCollectionName, "shard1");
-    assertTrue("Expected 2 of 3 replicas to be active but only found "+activeReps.size()+";
"+activeReps, activeReps.size() == 2);
+    assertTrue("Expected 2 of 3 replicas to be active but only found "+
+      activeReps.size()+"; "+activeReps+"; clusterState: "+printClusterStateInfo(), 
+      activeReps.size() == 2);
         
     sendDoc(6);
     
     assertDocsExistInAllReplicas(activeReps, testCollectionName, 1, 6);
-  }  
+  }
+  
+  protected String printClusterStateInfo() throws Exception {
+    cloudClient.getZkStateReader().updateClusterState(true);
+    return String.valueOf(cloudClient.getZkStateReader().getClusterState());
+  }
   
   protected List<Replica> getActiveOrRecoveringReplicas(String testCollectionName,
String shardId) throws Exception {    
     Map<String,Replica> activeReplicas = new HashMap<String,Replica>();    
@@ -492,10 +501,12 @@ public class HttpPartitionTest extends A
     } // end while
     
     if (!allReplicasUp) 
-      fail("Didn't see all replicas come up within " + maxWaitMs + " ms! ClusterState: "
+ cs);
+      fail("Didn't see all replicas come up within " + maxWaitMs + 
+          " ms! ClusterState: " + printClusterStateInfo());
     
     if (notLeaders.isEmpty()) 
-      fail("Didn't isolate any replicas that are not the leader! ClusterState: " + cs);
+      fail("Didn't isolate any replicas that are not the leader! ClusterState: " + 
+         printClusterStateInfo());
     
     long diffMs = (System.currentTimeMillis() - startMs);
     log.info("Took " + diffMs + " ms to see all replicas become active.");



Mime
View raw message