You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by no...@apache.org on 2013/08/08 11:10:38 UTC

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

Author: noble
Date: Thu Aug  8 09:10:38 2013
New Revision: 1511635

URL: http://svn.apache.org/r1511635
Log:
SOLR-5113

Added:
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java
      - copied unchanged from r1511633, lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/CustomCollectionTest.java
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=1511635&r1=1511634&r2=1511635&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 Thu Aug  8 09:10:38 2013
@@ -22,14 +22,12 @@ import org.apache.lucene.util.LuceneTest
 import org.apache.lucene.util._TestUtil;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.client.solrj.SolrQuery;
-import org.apache.solr.client.solrj.SolrRequest;
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.impl.CloudSolrServer;
 import org.apache.solr.client.solrj.impl.HttpSolrServer;
 import org.apache.solr.client.solrj.request.CoreAdminRequest;
 import org.apache.solr.client.solrj.request.CoreAdminRequest.Create;
 import org.apache.solr.client.solrj.request.QueryRequest;
-import org.apache.solr.client.solrj.request.UpdateRequest;
 import org.apache.solr.client.solrj.response.CoreAdminResponse;
 import org.apache.solr.client.solrj.response.QueryResponse;
 import org.apache.solr.common.SolrException;
@@ -37,8 +35,6 @@ import org.apache.solr.common.SolrExcept
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.cloud.ClusterState;
 import org.apache.solr.common.cloud.DocCollection;
-import org.apache.solr.common.cloud.DocRouter;
-import org.apache.solr.common.cloud.ImplicitDocRouter;
 import org.apache.solr.common.cloud.Replica;
 import org.apache.solr.common.cloud.Slice;
 import org.apache.solr.common.cloud.ZkCoreNodeProps;
@@ -57,7 +53,6 @@ import org.apache.solr.update.SolrCmdDis
 import org.apache.solr.util.DefaultSolrThreadFactory;
 import org.junit.Before;
 import org.junit.BeforeClass;
-import org.junit.Ignore;
 
 import javax.management.MBeanServer;
 import javax.management.MBeanServerFactory;
@@ -82,17 +77,12 @@ import java.util.concurrent.SynchronousQ
 import java.util.concurrent.ThreadPoolExecutor;
 import java.util.concurrent.TimeUnit;
 
-import static org.apache.solr.cloud.OverseerCollectionProcessor.MAX_SHARDS_PER_NODE;
 import static org.apache.solr.cloud.OverseerCollectionProcessor.REPLICATION_FACTOR;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.ROUTER;
-import static org.apache.solr.cloud.OverseerCollectionProcessor.SHARDS_PROP;
-import static org.apache.solr.common.params.ShardParams._ROUTE_;
 
 /**
  * Tests the Cloud Collections API.
  */
 @Slow
-@Ignore("SOLR-5113")
 public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBase {
   
   private static final String DEFAULT_COLLECTION = "collection1";
@@ -158,7 +148,6 @@ public class CollectionsAPIDistributedZk
     testErrorHandling();
     deletePartiallyCreatedCollection();
     deleteCollectionWithDownNodes();
-    testCustomCollectionsAPI();
     if (DEBUG) {
       super.printLayout();
     }
@@ -629,208 +618,6 @@ public class CollectionsAPIDistributedZk
     
     checkNoTwoShardsUseTheSameIndexDir();
   }
-  private void testCustomCollectionsAPI() throws Exception {
-    String COLL_PREFIX = "new_implicit_coll_";
-
-    // TODO: fragile - because we dont pass collection.confName, it will only
-    // find a default if a conf set with a name matching the collection name is found, or
-    // if there is only one conf set. That and the fact that other tests run first in this
-    // env make this pretty fragile
-
-    // create new collections rapid fire
-    Map<String,List<Integer>> collectionInfos = new HashMap<String,List<Integer>>();
-    int cnt = random().nextInt(6) + 1;
-
-    for (int i = 0; i < cnt; i++) {
-      int numShards = 4;
-      int replicationFactor = _TestUtil.nextInt(random(), 0, 3) + 2;
-      int maxShardsPerNode = ((((numShards+1) * replicationFactor) / getCommonCloudSolrServer()
-          .getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
-
-
-      CloudSolrServer client = null;
-      try {
-        if (i == 0) {
-          // Test if we can create a collection through CloudSolrServer where
-          // you havnt set default-collection
-          // This is nice because you want to be able to create you first
-          // collection using CloudSolrServer, and in such case there is
-          // nothing reasonable to set as default-collection
-          client = createCloudClient(null);
-        } else if (i == 1) {
-          // Test if we can create a collection through CloudSolrServer where
-          // you have set default-collection to a non-existing collection
-          // This is nice because you want to be able to create you first
-          // collection using CloudSolrServer, and in such case there is
-          // nothing reasonable to set as default-collection, but you might want
-          // to use the same CloudSolrServer throughout the entire
-          // lifetime of your client-application, so it is nice to be able to
-          // set a default-collection on this CloudSolrServer once and for all
-          // and use this CloudSolrServer to create the collection
-          client = createCloudClient(COLL_PREFIX + i);
-        }
-
-        Map<String, Object> props = OverseerCollectionProcessor.asMap(
-            ROUTER, ImplicitDocRouter.NAME,
-            REPLICATION_FACTOR, replicationFactor,
-            MAX_SHARDS_PER_NODE, maxShardsPerNode,
-            SHARDS_PROP,"a,b,c,d");
-
-        createCollection(collectionInfos, COLL_PREFIX + i,props,client);
-      } finally {
-        if (client != null) client.shutdown();
-      }
-    }
-
-    Set<Entry<String,List<Integer>>> collectionInfosEntrySet = collectionInfos.entrySet();
-    for (Entry<String,List<Integer>> entry : collectionInfosEntrySet) {
-      String collection = entry.getKey();
-      List<Integer> list = entry.getValue();
-      checkForCollection(collection, list, null);
-
-      String url = getUrlFromZk(collection);
-
-      HttpSolrServer collectionClient = new HttpSolrServer(url);
-
-      // poll for a second - it can take a moment before we are ready to serve
-      waitForNon403or404or503(collectionClient);
-    }
-    ZkStateReader zkStateReader = getCommonCloudSolrServer().getZkStateReader();
-    for (int j = 0; j < cnt; j++) {
-      waitForRecoveriesToFinish(COLL_PREFIX + j, zkStateReader, false);
-    }
-
-    ClusterState clusterState = zkStateReader.getClusterState();
-
-    DocCollection coll = clusterState.getCollection(COLL_PREFIX + 0);
-    assertEquals("implicit", coll.getStr(ROUTER));
-    assertNotNull(coll.getStr(REPLICATION_FACTOR));
-    assertNotNull(coll.getStr(MAX_SHARDS_PER_NODE));
-
-    List<String> collectionNameList = new ArrayList<String>();
-    collectionNameList.addAll(collectionInfos.keySet());
-    log.info("Collections created : "+collectionNameList );
-
-    String collectionName = collectionNameList.get(random().nextInt(collectionNameList.size()));
-
-    String url = getUrlFromZk(collectionName);
-
-    HttpSolrServer collectionClient = new HttpSolrServer(url);
-
-
-    // lets try and use the solrj client to index a couple documents
-
-    collectionClient.add(getDoc(id, 6, i1, -600, tlong, 600, t1,
-        "humpty dumpy sat on a wall", _ROUTE_,"a"));
-
-    collectionClient.add(getDoc(id, 7, i1, -600, tlong, 600, t1,
-        "humpty dumpy3 sat on a walls", _ROUTE_,"a"));
-
-    collectionClient.add(getDoc(id, 8, i1, -600, tlong, 600, t1,
-        "humpty dumpy2 sat on a walled", _ROUTE_,"a"));
-
-    collectionClient.commit();
-
-    assertEquals(3, collectionClient.query(new SolrQuery("*:*")).getResults().getNumFound());
-    assertEquals(0, collectionClient.query(new SolrQuery("*:*").setParam("shard.keys","b")).getResults().getNumFound());
-    assertEquals(3, collectionClient.query(new SolrQuery("*:*").setParam("shard.keys","a")).getResults().getNumFound());
-
-    collectionClient.deleteByQuery("*:*");
-    collectionClient.commit(true,true);
-    assertEquals(0, collectionClient.query(new SolrQuery("*:*")).getResults().getNumFound());
-
-    UpdateRequest up = new UpdateRequest();
-    up.setParam(_ROUTE_, "c");
-    up.setParam("commit","true");
-
-    up.add(getDoc(id, 9, i1, -600, tlong, 600, t1,
-        "humpty dumpy sat on a wall"));
-    up.add(getDoc(id, 10, i1, -600, tlong, 600, t1,
-        "humpty dumpy3 sat on a walls"));
-    up.add(getDoc(id, 11, i1, -600, tlong, 600, t1,
-        "humpty dumpy2 sat on a walled"));
-
-    collectionClient.request(up);
-
-    assertEquals(3, collectionClient.query(new SolrQuery("*:*")).getResults().getNumFound());
-    assertEquals(0, collectionClient.query(new SolrQuery("*:*").setParam("shard.keys","a")).getResults().getNumFound());
-    assertEquals(3, collectionClient.query(new SolrQuery("*:*").setParam("shard.keys","c")).getResults().getNumFound());
-
-    //Testing CREATESHARD
-    ModifiableSolrParams params = new ModifiableSolrParams();
-    params.set("action", CollectionAction.CREATESHARD.toString());
-    params.set("collection", coll.getName());
-    params.set("shard", "z");
-    SolrRequest request = new QueryRequest(params);
-    request.setPath("/admin/collections");
-    createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))).request(request);
-    waitForCollection(zkStateReader,coll.getName(),5);
-    collectionClient.add(getDoc(id, 66, i1, -600, tlong, 600, t1,
-        "humpty dumpy sat on a wall", _ROUTE_,"x"));
-    collectionClient.commit();
-    assertEquals(1, collectionClient.query(new SolrQuery("*:*").setParam(_ROUTE_,"x")).getResults().getNumFound());
-
-
-    int numShards = 4;
-    int replicationFactor = _TestUtil.nextInt(random(), 0, 3) + 2;
-    int maxShardsPerNode = (((numShards * replicationFactor) / getCommonCloudSolrServer()
-        .getZkStateReader().getClusterState().getLiveNodes().size())) + 1;
-
-
-    CloudSolrServer client = null;
-    String shard_fld = "shard_s";
-    try {
-      client = createCloudClient(null);
-      Map<String, Object> props = OverseerCollectionProcessor.asMap(
-          ROUTER, ImplicitDocRouter.NAME,
-          REPLICATION_FACTOR, replicationFactor,
-          MAX_SHARDS_PER_NODE, maxShardsPerNode,
-          SHARDS_PROP,"a,b,c,d",
-          DocRouter.ROUTE_FIELD, shard_fld);
-
-      collectionName = COLL_PREFIX + "withShardField";
-      createCollection(collectionInfos, collectionName,props,client);
-    } finally {
-      if (client != null) client.shutdown();
-    }
-
-    List<Integer> list = collectionInfos.get(collectionName);
-    checkForCollection(collectionName, list, null);
-
-
-    url = getUrlFromZk(collectionName);
-
-    collectionClient = new HttpSolrServer(url);
-
-    // poll for a second - it can take a moment before we are ready to serve
-    waitForNon403or404or503(collectionClient);
-
-
-
-
-    collectionClient = new HttpSolrServer(url);
-
-
-    // lets try and use the solrj client to index a couple documents
-
-    collectionClient.add(getDoc(id, 6, i1, -600, tlong, 600, t1,
-        "humpty dumpy sat on a wall", shard_fld,"a"));
-
-    collectionClient.add(getDoc(id, 7, i1, -600, tlong, 600, t1,
-        "humpty dumpy3 sat on a walls", shard_fld,"a"));
-
-    collectionClient.add(getDoc(id, 8, i1, -600, tlong, 600, t1,
-        "humpty dumpy2 sat on a walled", shard_fld,"a"));
-
-    collectionClient.commit();
-
-    assertEquals(3, collectionClient.query(new SolrQuery("*:*")).getResults().getNumFound());
-    assertEquals(0, collectionClient.query(new SolrQuery("*:*").setParam("shard.keys","b")).getResults().getNumFound());
-    //TODO debug the following case
-    assertEquals(3, collectionClient.query(new SolrQuery("*:*").setParam("shard.keys", "a")).getResults().getNumFound());
-
-
-  }
 
   private boolean waitForReloads(String collectionName, Map<String,Long> urlToTimeBefore) throws SolrServerException, IOException {