You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2012/01/21 19:18:23 UTC

svn commit: r1234381 - /lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java

Author: markrmiller
Date: Sat Jan 21 18:18:22 2012
New Revision: 1234381

URL: http://svn.apache.org/viewvc?rev=1234381&view=rev
Log:
Add a couple asserts to make sure our client/jetty model matches the cluster state and build model more efficiently.

Modified:
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java?rev=1234381&r1=1234380&r2=1234381&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java (original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/cloud/FullSolrCloudTest.java Sat Jan 21 18:18:22 2012
@@ -281,17 +281,17 @@ public class FullSolrCloudTest extends A
     shardToJetty.clear();
     jettyToInfo.clear();
     
+    CloudState cloudState = zkStateReader.getCloudState();
+    Map<String,Slice> slices = cloudState.getSlices(DEFAULT_COLLECTION);
+    
+    if (slices == null) {
+      throw new RuntimeException("No slices found for collection "
+          + DEFAULT_COLLECTION + " in " + cloudState.getCollections());
+    }
+    
     for (SolrServer client : clients) {
-      // find info for this client in zk
-      
-      CloudState cloudState = zkStateReader.getCloudState();
-      Map<String,Slice> slices = cloudState.getSlices(DEFAULT_COLLECTION);
-      
-      if (slices == null) {
-        throw new RuntimeException("No slices found for collection "
-            + DEFAULT_COLLECTION + " in " + cloudState.getCollections());
-      }
-      
+      // find info for this client in zk 
+      nextClient:
       // we find ou state by simply matching ports...
       for (Map.Entry<String,Slice> slice : slices.entrySet()) {
         Map<String,ZkNodeProps> theShards = slice.getValue().getShards();
@@ -316,21 +316,27 @@ public class FullSolrCloudTest extends A
             if (isLeader) {
               shardToLeaderClient.put(slice.getKey(), client);
             }
+            break nextClient;
           }
         }
       }
-      
     }
     
-    Map<String,Slice> slices = zkStateReader.getCloudState().getSlices(
-        DEFAULT_COLLECTION);
-    
+    for (Map.Entry<String,Slice> slice : slices.entrySet()) {
+      // check that things look right
+      assertEquals(slice.getValue().getShards().size(), shardToClient.get(slice.getKey()).size());
+    }
+ 
     for (JettySolrRunner jetty : jettys) {
+      nextJetty:
       for (Map.Entry<String,Slice> slice : slices.entrySet()) {
         Map<String,ZkNodeProps> theShards = slice.getValue().getShards();
         for (Map.Entry<String,ZkNodeProps> shard : theShards.entrySet()) {
           int port = jetty.getLocalPort();
-         
+          if (port == -1) {
+            fail("If we cannot get the port, we cannot map properly");
+          }
+          
           if (shard.getKey().contains(":" + port + "_")) {
             jettyToInfo.put(jetty, shard.getValue());
             List<CloudJettyRunner> list = shardToJetty.get(slice.getKey());
@@ -348,10 +354,16 @@ public class FullSolrCloudTest extends A
             if (isLeader) {
               shardToLeaderJetty.put(slice.getKey(), cjr);
             }
+            break nextJetty;
           }
         }
       }
     }
+    
+    for (Map.Entry<String,Slice> slice : slices.entrySet()) {
+      // check that things look right
+      assertEquals(slice.getValue().getShards().size(), shardToJetty.get(slice.getKey()).size());
+    }
   }
   
   @Override