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 2014/03/05 18:50:57 UTC

svn commit: r1574590 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/ solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java

Author: markrmiller
Date: Wed Mar  5 17:50:57 2014
New Revision: 1574590

URL: http://svn.apache.org/r1574590
Log:
SOLR-5813: tests for "" or null collection name - should default to core name.

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1574590&r1=1574589&r2=1574590&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java (original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java Wed Mar  5 17:50:57 2014
@@ -202,14 +202,14 @@ public class CollectionsAPIDistributedZk
     testCollectionsAPI();
     testCollectionsAPIAddRemoveStress();
     testErrorHandling();
+    testNoCollectionSpecified();
     deletePartiallyCreatedCollection();
     deleteCollectionRemovesStaleZkCollectionsNode();
     clusterPropTest();
-
     addReplicaTest();
-
     // last
     deleteCollectionWithDownNodes();
+    
     if (DEBUG) {
       super.printLayout();
     }
@@ -577,6 +577,40 @@ public class CollectionsAPIDistributedZk
     String val2 = failure.getVal(0).toString();
     assertTrue(val1.contains("SolrException") || val2.contains("SolrException"));
   }
+  
+  private void testNoCollectionSpecified() throws Exception {
+    
+    cloudClient.getZkStateReader().updateClusterState(true);
+    assertFalse(cloudClient.getZkStateReader().getAllCollections().contains("corewithnocollection"));
+    assertFalse(cloudClient.getZkStateReader().getAllCollections().contains("corewithnocollection2"));
+    
+    // try and create a SolrCore with no collection name
+    Create createCmd = new Create();
+    createCmd.setCoreName("corewithnocollection");
+    createCmd.setCollection("");
+    String dataDir = SolrTestCaseJ4.dataDir.getAbsolutePath() + File.separator
+        + System.currentTimeMillis() + "corewithnocollection" + "_1v";
+    createCmd.setDataDir(dataDir);
+    createCmd.setNumShards(1);
+    if (secondConfigSet) {
+      createCmd.setCollectionConfigName("conf1");
+    }
+    
+    createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(1)))
+        .request(createCmd);
+    
+    // try and create a SolrCore with no collection name
+    createCmd.setCollection(null);
+    createCmd.setCoreName("corewithnocollection2");
+    
+    createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(1)))
+        .request(createCmd);
+    
+    // in both cases, the collection should have default to the core name
+    cloudClient.getZkStateReader().updateClusterState(true);
+    assertTrue(cloudClient.getZkStateReader().getAllCollections().contains("corewithnocollection"));
+    assertTrue(cloudClient.getZkStateReader().getAllCollections().contains("corewithnocollection2"));
+  }
 
   private void testNodesUsedByCreate() throws Exception {
     // we can use this client because we just want base url