lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ans...@apache.org
Subject svn commit: r1647472 - in /lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud: CollectionsAPIDistributedZkTest.java CollectionsAPISolrJTests.java
Date Tue, 23 Dec 2014 02:52:08 GMT
Author: anshum
Date: Tue Dec 23 02:52:07 2014
New Revision: 1647472

URL: http://svn.apache.org/r1647472
Log:
SOLR-6868: Try to fix the failing test and also a part of the SolrJ collection API test refactoring

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

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java?rev=1647472&r1=1647471&r2=1647472&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
(original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
Tue Dec 23 02:52:07 2014
@@ -34,7 +34,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Objects;
-import java.util.Properties;
 import java.util.Set;
 import java.util.concurrent.CompletionService;
 import java.util.concurrent.ExecutorCompletionService;
@@ -47,7 +46,6 @@ import org.apache.lucene.util.LuceneTest
 import org.apache.lucene.util.TestUtil;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrRequest;
-import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.embedded.JettySolrRunner;
 import org.apache.solr.client.solrj.impl.CloudSolrServer;
@@ -72,7 +70,6 @@ import org.apache.solr.common.cloud.ZkCo
 import org.apache.solr.common.cloud.ZkNodeProps;
 import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.params.CollectionParams.CollectionAction;
-import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.common.params.MapSolrParams;
 import org.apache.solr.common.params.ModifiableSolrParams;
 import org.apache.solr.common.util.NamedList;
@@ -85,7 +82,6 @@ import org.apache.solr.core.SolrResource
 import org.apache.solr.servlet.SolrDispatchFilter;
 import org.apache.solr.update.DirectUpdateHandler2;
 import org.apache.solr.util.DefaultSolrThreadFactory;
-import org.apache.zookeeper.data.Stat;
 import org.junit.Before;
 import org.junit.BeforeClass;
 
@@ -199,7 +195,6 @@ public class CollectionsAPIDistributedZk
   
   @Override
   public void doTest() throws Exception {
-    testPropertyParamsForCreate();
     testNodesUsedByCreate();
     testCollectionsAPI();
     testCollectionsAPIAddRemoveStress();
@@ -217,53 +212,7 @@ public class CollectionsAPIDistributedZk
     }
   }
 
-  private void testPropertyParamsForCreate() throws Exception {
-    String collectionName = "solrj_test_core_props";
-    SolrServer server = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0)));
-
-    File tmpDir = createTempDir("testPropertyParamsForCreate").toFile();
-    File instanceDir = new File(tmpDir, "instanceDir-" + TestUtil.randomSimpleString(random(),
1, 5));
-    File dataDir = new File(tmpDir, "dataDir-" + TestUtil.randomSimpleString(random(), 1,
5));
-    File ulogDir = new File(tmpDir, "ulogDir-" + TestUtil.randomSimpleString(random(), 1,
5));
-
-    Properties properties = new Properties();
-    properties.put(CoreAdminParams.INSTANCE_DIR, instanceDir.getAbsolutePath());
-    properties.put(CoreAdminParams.DATA_DIR, dataDir.getAbsolutePath());
-    properties.put(CoreAdminParams.ULOG_DIR, ulogDir.getAbsolutePath());
-
-    CollectionAdminRequest.Create createReq = new CollectionAdminRequest.Create();
-    createReq.setCollectionName(collectionName);
-    createReq.setNumShards(1);
-    createReq.setConfigName("conf1");
-    createReq.setProperties(properties);
-
-    CollectionAdminResponse response = createReq.process( server );
-    assertEquals(0, response.getStatus());
-    assertTrue(response.isSuccess());
-    Map<String, NamedList<Integer>> coresStatus = response.getCollectionCoresStatus();
-    assertEquals(1, coresStatus.size());
-
-    DocCollection testcoll = getCommonCloudSolrServer().getZkStateReader()
-        .getClusterState().getCollection(collectionName);
-
-    Replica replica1 = testcoll.getReplica("core_node1");
-
-    HttpSolrServer replica1Server = new HttpSolrServer(replica1.getStr("base_url"));
-    try {
-      CoreAdminResponse status = CoreAdminRequest.getStatus(replica1.getStr("core"), replica1Server);
-      NamedList<Object> coreStatus = status.getCoreStatus(replica1.getStr("core"));
-      String dataDirStr = (String) coreStatus.get("dataDir");
-      String instanceDirStr = (String) coreStatus.get("instanceDir");
-      assertEquals("Instance dir does not match param passed in property.instanceDir syntax",
-          new File(instanceDirStr).getAbsolutePath(), instanceDir.getAbsolutePath());
-      assertEquals("Data dir does not match param given in property.dataDir syntax",
-          new File(dataDirStr).getAbsolutePath(), dataDir.getAbsolutePath());
 
-    } finally {
-      replica1Server.shutdown();
-    }
-
-  }
 
   private void deleteCollectionRemovesStaleZkCollectionsNode() throws Exception {
     

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTests.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTests.java?rev=1647472&r1=1647471&r2=1647472&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTests.java
(original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CollectionsAPISolrJTests.java
Tue Dec 23 02:52:07 2014
@@ -18,17 +18,26 @@ package org.apache.solr.cloud;
  */
 
 import org.apache.lucene.util.LuceneTestCase;
+import org.apache.lucene.util.TestUtil;
 import org.apache.solr.client.solrj.SolrServerException;
+import org.apache.solr.client.solrj.impl.HttpSolrServer;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
+import org.apache.solr.client.solrj.request.CoreAdminRequest;
 import org.apache.solr.client.solrj.response.CollectionAdminResponse;
+import org.apache.solr.client.solrj.response.CoreAdminResponse;
 import org.apache.solr.common.cloud.ClusterState;
+import org.apache.solr.common.cloud.DocCollection;
+import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.ZkStateReader;
+import org.apache.solr.common.params.CoreAdminParams;
 import org.apache.solr.common.util.NamedList;
 
+import java.io.File;
 import java.io.IOException;
 import java.util.Collection;
 import java.util.Map;
+import java.util.Properties;
 
 @LuceneTestCase.Slow
 public class CollectionsAPISolrJTests extends AbstractFullDistribZkTestBase {
@@ -39,7 +48,8 @@ public class CollectionsAPISolrJTests ex
     testCreateAndDeleteShard();
     testReloadCollection();
     testCreateAndDeleteAlias();
-    testSplitShard();    
+    testSplitShard();
+    testCreateCollectionWithPropertyParam();
   }
 
   public void tearDown() throws Exception {
@@ -214,5 +224,54 @@ public class CollectionsAPISolrJTests ex
     assertEquals("ClusterState: "+ clusterState.getActiveSlices(collectionName), 5, slices.size());
 
     
   }
-  
+
+  private void testCreateCollectionWithPropertyParam() throws Exception {
+    String collectionName = "solrj_test_core_props";
+    
+    File tmpDir = createTempDir("testPropertyParamsForCreate").toFile();
+    File instanceDir = new File(tmpDir, "instanceDir-" + TestUtil.randomSimpleString(random(),
1, 5));
+    File dataDir = new File(tmpDir, "dataDir-" + TestUtil.randomSimpleString(random(), 1,
5));
+    File ulogDir = new File(tmpDir, "ulogDir-" + TestUtil.randomSimpleString(random(), 1,
5));
+
+    Properties properties = new Properties();
+    properties.put(CoreAdminParams.INSTANCE_DIR, instanceDir.getAbsolutePath());
+    properties.put(CoreAdminParams.DATA_DIR, dataDir.getAbsolutePath());
+    properties.put(CoreAdminParams.ULOG_DIR, ulogDir.getAbsolutePath());
+
+    CollectionAdminRequest.Create createReq = new CollectionAdminRequest.Create();
+    createReq.setCollectionName(collectionName);
+    createReq.setNumShards(1);
+    createReq.setConfigName("conf1");
+    createReq.setProperties(properties);
+
+    CollectionAdminResponse response = createReq.process(cloudClient);
+    assertEquals(0, response.getStatus());
+    assertTrue(response.isSuccess());
+    Map<String, NamedList<Integer>> coresStatus = response.getCollectionCoresStatus();
+    assertEquals(1, coresStatus.size());
+
+    DocCollection testCollection = cloudClient.getZkStateReader()
+        .getClusterState().getCollection(collectionName);
+
+    Replica replica1 = testCollection.getReplica("core_node1");
+
+    HttpSolrServer solrServer = new HttpSolrServer(replica1.getStr("base_url"));
+    try {
+      CoreAdminResponse status = CoreAdminRequest.getStatus(replica1.getStr("core"), solrServer);
+      NamedList<Object> coreStatus = status.getCoreStatus(replica1.getStr("core"));
+      String dataDirStr = (String) coreStatus.get("dataDir");
+      String instanceDirStr = (String) coreStatus.get("instanceDir");
+      assertEquals("Instance dir does not match param passed in property.instanceDir syntax",
+          new File(instanceDirStr).getAbsolutePath(), instanceDir.getAbsolutePath());
+      assertEquals("Data dir does not match param given in property.dataDir syntax",
+          new File(dataDirStr).getAbsolutePath(), dataDir.getAbsolutePath());
+
+    } finally {
+      solrServer.shutdown();
+    }
+
+    CollectionAdminRequest.Delete deleteCollectionRequest = new CollectionAdminRequest.Delete();
+    deleteCollectionRequest.setCollectionName(collectionName);
+    deleteCollectionRequest.process(cloudClient);
+  }
 }



Mime
View raw message