You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by PaulElschot <gi...@git.apache.org> on 2014/02/19 21:47:47 UTC

[GitHub] lucene-solr pull request: Squashed commit for LUCENE-5092

GitHub user PaulElschot opened a pull request:

    https://github.com/apache/lucene-solr/pull/37

    Squashed commit for LUCENE-5092

    LUCENE-5092
    
    3rd pull request, resolved recent conflict with trunk.
    
    In core introduce DocBlocksIterator.
    Use this in FixedBitSet, in EliasFanoDocIdSet and in join module ToChild... and ToParent...
    Also change BaseDocIdSetTestCase to test DocBlocksIterator.advanceToJustBefore.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/PaulElschot/lucene-solr LUCENE-5092-pull-3

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/lucene-solr/pull/37.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #37
    
----
commit 77f73ac206e8ad85bc7706424a7cc181eb73e8a9
Author: Paul Elschot <pa...@gmail.com>
Date:   2014-02-19T20:31:03Z

    Squashed commit for LUCENE-5092

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. To do so, please top-post your response.
If your project does not have this feature enabled and wishes so, or if the
feature is enabled but not working, please contact infrastructure at
infrastructure@apache.org or file a JIRA ticket with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by tomjon <gi...@git.apache.org>.
Github user tomjon commented on the pull request:

    https://github.com/apache/lucene-solr/pull/37#issuecomment-220031698
  
    Pushed changes


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by tomjon <gi...@git.apache.org>.
GitHub user tomjon reopened a pull request:

    https://github.com/apache/lucene-solr/pull/37

    Move to SolrCloudTestCase

    

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tomjon/lucene-solr solr-cloudtest

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/lucene-solr/pull/37.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #37
    
----
commit 674e0346625cb3341e4183b0c19cd2d03f8ad58d
Author: Tom Winch <to...@flax.co.uk>
Date:   2016-05-10T11:12:31Z

    Use SolrCloudTestCase and tidy up deprecated API

commit f0ea19c38db1c272e602b9ac1d2b2394c62732f2
Author: Tom Winch <to...@flax.co.uk>
Date:   2016-05-10T11:12:53Z

    Store values of role and node in CollectionAdminRoleRequest constructor

commit 7e98bdf1fc6314aeca3b1e50ff32996e3e1b1ec1
Author: Tom Winch <to...@flax.co.uk>
Date:   2016-05-17T16:52:13Z

    Move CollectionsAPIDistributedZkTest over to SolrCloudTestCase

commit 548e98fe2ec6593ca0f395804670715509a00e48
Author: Tom Winch <to...@flax.co.uk>
Date:   2016-05-17T16:52:31Z

    Test files including jmx

commit 601a19cc8e4be978f79925ed3ac00864b3478224
Author: Tom Winch <to...@flax.co.uk>
Date:   2016-05-18T13:50:27Z

    Make suggested changes, leaving deleteCollectionWithUnloadedCore as @Ignore

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr issue #37: Move to SolrCloudTestCase

Posted by romseygeek <gi...@git.apache.org>.
Github user romseygeek commented on the issue:

    https://github.com/apache/lucene-solr/pull/37
  
    Finally merged this in (with a few changes), thanks @tomjon !


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by romseygeek <gi...@git.apache.org>.
Github user romseygeek commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/37#discussion_r63663755
  
    --- Diff: solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java ---
    @@ -435,73 +278,55 @@ private void testErrorHandling() throws Exception {
         request.setPath("/admin/collections");
         gotExp = false;
         try {
    -      makeRequest(baseUrl, request);
    +      cloudClient.request(request);
         } catch (SolrException e) {
           gotExp = true;
         }
         assertTrue(gotExp);
         
    -    // Too many replicas
    +    // No numShards should fail
         params = new ModifiableSolrParams();
         params.set("action", CollectionAction.CREATE.toString());
    -    collectionName = "collection";
    +    collectionName = "acollection";
         params.set("name", collectionName);
    -    params.set("numShards", 2);
    +    params.set(REPLICATION_FACTOR, 10);
         if (secondConfigSet) {
           params.set("collection.configName", "conf1");
         }
    -    params.set(REPLICATION_FACTOR, 10);
         request = new QueryRequest(params);
         request.setPath("/admin/collections");
         gotExp = false;
         try {
    -      makeRequest(baseUrl, request);
    +      cloudClient.request(request);
         } catch (SolrException e) {
           gotExp = true;
         }
         assertTrue(gotExp);
    +  }
    +  
    +  @Test
    +  public void testBadParams() throws SolrServerException, IOException {
    +    int exceptionCount = 0;
         
    -    // No numShards should fail
    -    params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.CREATE.toString());
    -    collectionName = "acollection";
    -    params.set("name", collectionName);
    -    params.set(REPLICATION_FACTOR, 10);
    -    if (secondConfigSet) {
    -      params.set("collection.configName", "conf1");
    -    }
    -    request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    -    gotExp = false;
    +    // Too many replicas
         try {
    -      makeRequest(baseUrl, request);
    +      createCollection("collection", configSet, 2, 10).process(cloudClient);
         } catch (SolrException e) {
    -      gotExp = true;
    +      ++exceptionCount;
    --- End diff --
    
    Rather than doing this, can you use ```expectThrows()```?  That way we get better error messages if the test fails.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Squashed commit for LUCENE-5092

Posted by PaulElschot <gi...@git.apache.org>.
Github user PaulElschot commented on the pull request:

    https://github.com/apache/lucene-solr/pull/37#issuecomment-37589051
  
    Opened new PR for recent minor conflict


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Squashed commit for LUCENE-5092

Posted by PaulElschot <gi...@git.apache.org>.
Github user PaulElschot closed the pull request at:

    https://github.com/apache/lucene-solr/pull/37


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by tomjon <gi...@git.apache.org>.
Github user tomjon commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/37#discussion_r63668079
  
    --- Diff: solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java ---
    @@ -70,357 +77,193 @@
     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;
    -import org.apache.solr.common.util.SimpleOrderedMap;
     import org.apache.solr.common.util.StrUtils;
     import org.apache.solr.core.CoreContainer;
     import org.apache.solr.core.SolrCore;
     import org.apache.solr.core.SolrInfoMBean.Category;
     import org.apache.solr.util.TestInjection;
     import org.apache.solr.util.TimeOut;
    +import org.junit.After;
    +import org.junit.AfterClass;
     import org.junit.BeforeClass;
     import org.junit.Test;
     import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;
     
    -import static org.apache.solr.cloud.OverseerCollectionMessageHandler.NUM_SLICES;
    -import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
    -import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
    -import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
    -import static org.apache.solr.common.util.Utils.makeMap;
    -
     /**
      * Tests the Cloud Collections API.
      */
     @Slow
    -public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBase {
    +public class CollectionsAPIDistributedZkTest extends SolrCloudTestCase {
     
       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
    -
    -  private static final String DEFAULT_COLLECTION = "collection1";
    +  
    +  private static final int NODE_COUNT = 5;
     
       // we randomly use a second config set rather than just one
    -  private boolean secondConfigSet = random().nextBoolean();
    +  private final boolean secondConfigSet = false; //random().nextBoolean(); FIXME
    +  private final String configSet = secondConfigSet ? "conf1": "conf2";
    +
    +  private static CloudSolrClient cloudClient;
    +  private static ZkTestServer zkServer;
       
       @BeforeClass
    -  public static void beforeCollectionsAPIDistributedZkTest() {
    +  public static void setup() throws Exception {
    +    configureCluster(NODE_COUNT)
    +        .addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-jmx").resolve("conf"))
    +        .addConfig("conf2", TEST_PATH().resolve("configsets").resolve("cloud-jmx").resolve("conf"))
    +        .configure();
    +    
    +    cloudClient = cluster.buildSolrClient(random().nextBoolean());
    +    cloudClient.setParallelUpdates(random().nextBoolean());
    +    cloudClient.connect();
    +    
    +    zkServer = cluster.getZkServer();
    +    
         TestInjection.randomDelayInCoreCreation = "true:20";
         System.setProperty("validateAfterInactivity", "200");
       }
    -  
    -  @Override
    -  public void distribSetUp() throws Exception {
    -    super.distribSetUp();
    -    
    -    if (secondConfigSet ) {
    -      String zkHost = zkServer.getZkHost();
    -      String zkAddress = zkServer.getZkAddress();
    -      SolrZkClient zkClient = new SolrZkClient(zkHost, AbstractZkTestCase.TIMEOUT);
    -      zkClient.makePath("/solr", false, true);
    -      zkClient.close();
    -
    -      zkClient = new SolrZkClient(zkAddress, AbstractZkTestCase.TIMEOUT);
     
    -      File solrhome = new File(TEST_HOME());
    -      
    -      // for now, always upload the config and schema to the canonical names
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, getCloudSolrConfig(), "solrconfig.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "schema.xml", "schema.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "enumsConfig.xml", "enumsConfig.xml");
    -      
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "solrconfig.snippet.randomindexconfig.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "stopwords.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "protwords.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "currency.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "open-exchange-rates.json");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "mapping-ISOLatin1Accent.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "old_synonyms.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "synonyms.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "elevate.xml");
    -      zkClient.close();
    -    }
    +  @AfterClass
    +  public static void deleteDefaultCollection() throws Exception {
    +    cloudClient.close();
    +    zkServer.shutdown();
       }
       
    -  protected String getSolrXml() {
    -    return "solr-no-core.xml";
    -  }
    -
    -  
    -  public CollectionsAPIDistributedZkTest() {
    -    sliceCount = 2;
    -  }
    -  
    -  @Override
    -  protected void setDistributedParams(ModifiableSolrParams params) {
    -
    -    if (r.nextBoolean()) {
    -      // don't set shards, let that be figured out from the cloud state
    -    } else {
    -      // use shard ids rather than physical locations
    -      StringBuilder sb = new StringBuilder();
    -      for (int i = 0; i < getShardCount(); i++) {
    -        if (i > 0)
    -          sb.append(',');
    -        sb.append("shard" + (i + 3));
    -      }
    -      params.set("shards", sb.toString());
    -    }
    +  // make sure tests leave all our nodes live
    +  @After
    +  public void bar() {
    +    ClusterState state = cloudClient.getZkStateReader().getClusterState();
    +    assertEquals(NODE_COUNT, state.getLiveNodes().size());
       }
     
       @Test
    -  @ShardsFixed(num = 4)
    -  public void test() throws Exception {
    -    waitForRecoveriesToFinish(false); // we need to fix no core tests still
    -    testNodesUsedByCreate();
    -    testNoConfigSetExist();
    -    testCollectionsAPI();
    -    testCollectionsAPIAddRemoveStress();
    -    testErrorHandling();
    -    testNoCollectionSpecified();
    -    deletePartiallyCreatedCollection();
    -    deleteCollectionRemovesStaleZkCollectionsNode();
    -    clusterPropTest();
    -    // last
    -    deleteCollectionWithDownNodes();
    -    addReplicaTest();
    -  }
    -
    -  private void deleteCollectionRemovesStaleZkCollectionsNode() throws Exception {
    -    
    -    // we can use this client because we just want base url
    -    final String baseUrl = getBaseUrl((HttpSolrClient) clients.get(0));
    -    
    +  public void deleteCollectionRemovesStaleZkCollectionsNode() throws Exception {
         String collectionName = "out_of_sync_collection";
         
    -    List<Integer> numShardsNumReplicaList = new ArrayList<>();
    -    numShardsNumReplicaList.add(2);
    -    numShardsNumReplicaList.add(1);
    -    
    -    
         cloudClient.getZkStateReader().getZkClient().makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true);
         
    -    ModifiableSolrParams params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.DELETE.toString());
    -    params.set("name", collectionName);
    -    QueryRequest request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    -    
    -    // there are remnants of the collection in zk, should work
    -    makeRequest(baseUrl, request);
    -    
    -    assertCollectionNotExists(collectionName, 45);
    -    
    -    assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true));
    +    CollectionAdminResponse response = deleteCollection(collectionName)
    +        .process(cloudClient);
    +    assertEquals(0, response.getStatus());
     
    +    waitForCollectionToDisappear(collectionName, cloudClient.getZkStateReader(), false, true, 45);
    +    assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true));
       }
     
    -  private void deletePartiallyCreatedCollection() throws Exception {
    -    final String baseUrl = getBaseUrl((HttpSolrClient) clients.get(0));
    +  @Test
    +  public void deletePartiallyCreatedCollection() throws Exception {
         String collectionName = "halfdeletedcollection";
    -    Create createCmd = new Create();
    -    createCmd.setCoreName("halfdeletedcollection_shard1_replica1");
    -    createCmd.setCollection(collectionName);
    -    String dataDir = createTempDir().toFile().getAbsolutePath();
    -    createCmd.setDataDir(dataDir);
    -    createCmd.setNumShards(2);
    -    if (secondConfigSet) {
    -      createCmd.setCollectionConfigName("conf1");
    -    }
     
    -    makeRequest(baseUrl, createCmd);
    -
    -    ModifiableSolrParams params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.DELETE.toString());
    -    params.set("name", collectionName);
    -    QueryRequest request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    +    Properties properties = new Properties();
    +    properties.put(CoreAdminParams.DATA_DIR, createTempDir().toFile().getAbsolutePath());
    +    properties.put(CoreAdminParams.CORE, "halfdeletedcollection_shard1_replica1");
    +    CollectionAdminResponse response = createCollection(collectionName, configSet, 2, 1)
    --- End diff --
    
    Ah yes, I learned later that this use of properties won't actually do anything, and forgot to go back to fix this


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by tomjon <gi...@git.apache.org>.
Github user tomjon closed the pull request at:

    https://github.com/apache/lucene-solr/pull/37


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by tomjon <gi...@git.apache.org>.
Github user tomjon commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/37#discussion_r63668312
  
    --- Diff: solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java ---
    @@ -70,357 +77,193 @@
     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;
    -import org.apache.solr.common.util.SimpleOrderedMap;
     import org.apache.solr.common.util.StrUtils;
     import org.apache.solr.core.CoreContainer;
     import org.apache.solr.core.SolrCore;
     import org.apache.solr.core.SolrInfoMBean.Category;
     import org.apache.solr.util.TestInjection;
     import org.apache.solr.util.TimeOut;
    +import org.junit.After;
    +import org.junit.AfterClass;
     import org.junit.BeforeClass;
     import org.junit.Test;
     import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;
     
    -import static org.apache.solr.cloud.OverseerCollectionMessageHandler.NUM_SLICES;
    -import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
    -import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
    -import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
    -import static org.apache.solr.common.util.Utils.makeMap;
    -
     /**
      * Tests the Cloud Collections API.
      */
     @Slow
    -public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBase {
    +public class CollectionsAPIDistributedZkTest extends SolrCloudTestCase {
     
       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
    -
    -  private static final String DEFAULT_COLLECTION = "collection1";
    +  
    +  private static final int NODE_COUNT = 5;
     
       // we randomly use a second config set rather than just one
    -  private boolean secondConfigSet = random().nextBoolean();
    +  private final boolean secondConfigSet = false; //random().nextBoolean(); FIXME
    +  private final String configSet = secondConfigSet ? "conf1": "conf2";
    +
    +  private static CloudSolrClient cloudClient;
    +  private static ZkTestServer zkServer;
       
       @BeforeClass
    -  public static void beforeCollectionsAPIDistributedZkTest() {
    +  public static void setup() throws Exception {
    +    configureCluster(NODE_COUNT)
    +        .addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-jmx").resolve("conf"))
    +        .addConfig("conf2", TEST_PATH().resolve("configsets").resolve("cloud-jmx").resolve("conf"))
    +        .configure();
    +    
    +    cloudClient = cluster.buildSolrClient(random().nextBoolean());
    +    cloudClient.setParallelUpdates(random().nextBoolean());
    +    cloudClient.connect();
    +    
    +    zkServer = cluster.getZkServer();
    +    
         TestInjection.randomDelayInCoreCreation = "true:20";
         System.setProperty("validateAfterInactivity", "200");
       }
    -  
    -  @Override
    -  public void distribSetUp() throws Exception {
    -    super.distribSetUp();
    -    
    -    if (secondConfigSet ) {
    -      String zkHost = zkServer.getZkHost();
    -      String zkAddress = zkServer.getZkAddress();
    -      SolrZkClient zkClient = new SolrZkClient(zkHost, AbstractZkTestCase.TIMEOUT);
    -      zkClient.makePath("/solr", false, true);
    -      zkClient.close();
    -
    -      zkClient = new SolrZkClient(zkAddress, AbstractZkTestCase.TIMEOUT);
     
    -      File solrhome = new File(TEST_HOME());
    -      
    -      // for now, always upload the config and schema to the canonical names
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, getCloudSolrConfig(), "solrconfig.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "schema.xml", "schema.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "enumsConfig.xml", "enumsConfig.xml");
    -      
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "solrconfig.snippet.randomindexconfig.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "stopwords.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "protwords.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "currency.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "open-exchange-rates.json");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "mapping-ISOLatin1Accent.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "old_synonyms.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "synonyms.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "elevate.xml");
    -      zkClient.close();
    -    }
    +  @AfterClass
    --- End diff --
    
    Actually, I at least need to close() the zkServer, as this (50% of the time) gets replaced by a new one when restarting Zookeeper.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by tomjon <gi...@git.apache.org>.
Github user tomjon commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/37#discussion_r63668163
  
    --- Diff: solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java ---
    @@ -435,73 +278,55 @@ private void testErrorHandling() throws Exception {
         request.setPath("/admin/collections");
         gotExp = false;
         try {
    -      makeRequest(baseUrl, request);
    +      cloudClient.request(request);
         } catch (SolrException e) {
           gotExp = true;
         }
         assertTrue(gotExp);
         
    -    // Too many replicas
    +    // No numShards should fail
         params = new ModifiableSolrParams();
         params.set("action", CollectionAction.CREATE.toString());
    -    collectionName = "collection";
    +    collectionName = "acollection";
         params.set("name", collectionName);
    -    params.set("numShards", 2);
    +    params.set(REPLICATION_FACTOR, 10);
         if (secondConfigSet) {
           params.set("collection.configName", "conf1");
         }
    -    params.set(REPLICATION_FACTOR, 10);
         request = new QueryRequest(params);
         request.setPath("/admin/collections");
         gotExp = false;
         try {
    -      makeRequest(baseUrl, request);
    +      cloudClient.request(request);
         } catch (SolrException e) {
           gotExp = true;
         }
         assertTrue(gotExp);
    +  }
    +  
    +  @Test
    +  public void testBadParams() throws SolrServerException, IOException {
    +    int exceptionCount = 0;
         
    -    // No numShards should fail
    -    params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.CREATE.toString());
    -    collectionName = "acollection";
    -    params.set("name", collectionName);
    -    params.set(REPLICATION_FACTOR, 10);
    -    if (secondConfigSet) {
    -      params.set("collection.configName", "conf1");
    -    }
    -    request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    -    gotExp = false;
    +    // Too many replicas
         try {
    -      makeRequest(baseUrl, request);
    +      createCollection("collection", configSet, 2, 10).process(cloudClient);
         } catch (SolrException e) {
    -      gotExp = true;
    +      ++exceptionCount;
    --- End diff --
    
    Yes, good idea - I was following how it'd already been done, here


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by romseygeek <gi...@git.apache.org>.
Github user romseygeek commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/37#discussion_r63663320
  
    --- Diff: solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java ---
    @@ -70,357 +77,193 @@
     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;
    -import org.apache.solr.common.util.SimpleOrderedMap;
     import org.apache.solr.common.util.StrUtils;
     import org.apache.solr.core.CoreContainer;
     import org.apache.solr.core.SolrCore;
     import org.apache.solr.core.SolrInfoMBean.Category;
     import org.apache.solr.util.TestInjection;
     import org.apache.solr.util.TimeOut;
    +import org.junit.After;
    +import org.junit.AfterClass;
     import org.junit.BeforeClass;
     import org.junit.Test;
     import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;
     
    -import static org.apache.solr.cloud.OverseerCollectionMessageHandler.NUM_SLICES;
    -import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
    -import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
    -import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
    -import static org.apache.solr.common.util.Utils.makeMap;
    -
     /**
      * Tests the Cloud Collections API.
      */
     @Slow
    -public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBase {
    +public class CollectionsAPIDistributedZkTest extends SolrCloudTestCase {
     
       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
    -
    -  private static final String DEFAULT_COLLECTION = "collection1";
    +  
    +  private static final int NODE_COUNT = 5;
     
       // we randomly use a second config set rather than just one
    -  private boolean secondConfigSet = random().nextBoolean();
    +  private final boolean secondConfigSet = false; //random().nextBoolean(); FIXME
    +  private final String configSet = secondConfigSet ? "conf1": "conf2";
    +
    +  private static CloudSolrClient cloudClient;
    +  private static ZkTestServer zkServer;
       
       @BeforeClass
    -  public static void beforeCollectionsAPIDistributedZkTest() {
    +  public static void setup() throws Exception {
    +    configureCluster(NODE_COUNT)
    +        .addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-jmx").resolve("conf"))
    +        .addConfig("conf2", TEST_PATH().resolve("configsets").resolve("cloud-jmx").resolve("conf"))
    +        .configure();
    +    
    +    cloudClient = cluster.buildSolrClient(random().nextBoolean());
    +    cloudClient.setParallelUpdates(random().nextBoolean());
    +    cloudClient.connect();
    +    
    +    zkServer = cluster.getZkServer();
    +    
         TestInjection.randomDelayInCoreCreation = "true:20";
         System.setProperty("validateAfterInactivity", "200");
       }
    -  
    -  @Override
    -  public void distribSetUp() throws Exception {
    -    super.distribSetUp();
    -    
    -    if (secondConfigSet ) {
    -      String zkHost = zkServer.getZkHost();
    -      String zkAddress = zkServer.getZkAddress();
    -      SolrZkClient zkClient = new SolrZkClient(zkHost, AbstractZkTestCase.TIMEOUT);
    -      zkClient.makePath("/solr", false, true);
    -      zkClient.close();
    -
    -      zkClient = new SolrZkClient(zkAddress, AbstractZkTestCase.TIMEOUT);
     
    -      File solrhome = new File(TEST_HOME());
    -      
    -      // for now, always upload the config and schema to the canonical names
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, getCloudSolrConfig(), "solrconfig.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "schema.xml", "schema.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "enumsConfig.xml", "enumsConfig.xml");
    -      
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "solrconfig.snippet.randomindexconfig.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "stopwords.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "protwords.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "currency.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "open-exchange-rates.json");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "mapping-ISOLatin1Accent.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "old_synonyms.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "synonyms.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "elevate.xml");
    -      zkClient.close();
    -    }
    +  @AfterClass
    +  public static void deleteDefaultCollection() throws Exception {
    +    cloudClient.close();
    +    zkServer.shutdown();
       }
       
    -  protected String getSolrXml() {
    -    return "solr-no-core.xml";
    -  }
    -
    -  
    -  public CollectionsAPIDistributedZkTest() {
    -    sliceCount = 2;
    -  }
    -  
    -  @Override
    -  protected void setDistributedParams(ModifiableSolrParams params) {
    -
    -    if (r.nextBoolean()) {
    -      // don't set shards, let that be figured out from the cloud state
    -    } else {
    -      // use shard ids rather than physical locations
    -      StringBuilder sb = new StringBuilder();
    -      for (int i = 0; i < getShardCount(); i++) {
    -        if (i > 0)
    -          sb.append(',');
    -        sb.append("shard" + (i + 3));
    -      }
    -      params.set("shards", sb.toString());
    -    }
    +  // make sure tests leave all our nodes live
    +  @After
    +  public void bar() {
    +    ClusterState state = cloudClient.getZkStateReader().getClusterState();
    +    assertEquals(NODE_COUNT, state.getLiveNodes().size());
       }
     
       @Test
    -  @ShardsFixed(num = 4)
    -  public void test() throws Exception {
    -    waitForRecoveriesToFinish(false); // we need to fix no core tests still
    -    testNodesUsedByCreate();
    -    testNoConfigSetExist();
    -    testCollectionsAPI();
    -    testCollectionsAPIAddRemoveStress();
    -    testErrorHandling();
    -    testNoCollectionSpecified();
    -    deletePartiallyCreatedCollection();
    -    deleteCollectionRemovesStaleZkCollectionsNode();
    -    clusterPropTest();
    -    // last
    -    deleteCollectionWithDownNodes();
    -    addReplicaTest();
    -  }
    -
    -  private void deleteCollectionRemovesStaleZkCollectionsNode() throws Exception {
    -    
    -    // we can use this client because we just want base url
    -    final String baseUrl = getBaseUrl((HttpSolrClient) clients.get(0));
    -    
    +  public void deleteCollectionRemovesStaleZkCollectionsNode() throws Exception {
         String collectionName = "out_of_sync_collection";
         
    -    List<Integer> numShardsNumReplicaList = new ArrayList<>();
    -    numShardsNumReplicaList.add(2);
    -    numShardsNumReplicaList.add(1);
    -    
    -    
         cloudClient.getZkStateReader().getZkClient().makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true);
         
    -    ModifiableSolrParams params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.DELETE.toString());
    -    params.set("name", collectionName);
    -    QueryRequest request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    -    
    -    // there are remnants of the collection in zk, should work
    -    makeRequest(baseUrl, request);
    -    
    -    assertCollectionNotExists(collectionName, 45);
    -    
    -    assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true));
    +    CollectionAdminResponse response = deleteCollection(collectionName)
    +        .process(cloudClient);
    +    assertEquals(0, response.getStatus());
     
    +    waitForCollectionToDisappear(collectionName, cloudClient.getZkStateReader(), false, true, 45);
    +    assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true));
       }
     
    -  private void deletePartiallyCreatedCollection() throws Exception {
    -    final String baseUrl = getBaseUrl((HttpSolrClient) clients.get(0));
    +  @Test
    +  public void deletePartiallyCreatedCollection() throws Exception {
         String collectionName = "halfdeletedcollection";
    -    Create createCmd = new Create();
    -    createCmd.setCoreName("halfdeletedcollection_shard1_replica1");
    -    createCmd.setCollection(collectionName);
    -    String dataDir = createTempDir().toFile().getAbsolutePath();
    -    createCmd.setDataDir(dataDir);
    -    createCmd.setNumShards(2);
    -    if (secondConfigSet) {
    -      createCmd.setCollectionConfigName("conf1");
    -    }
     
    -    makeRequest(baseUrl, createCmd);
    -
    -    ModifiableSolrParams params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.DELETE.toString());
    -    params.set("name", collectionName);
    -    QueryRequest request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    +    Properties properties = new Properties();
    +    properties.put(CoreAdminParams.DATA_DIR, createTempDir().toFile().getAbsolutePath());
    +    properties.put(CoreAdminParams.CORE, "halfdeletedcollection_shard1_replica1");
    +    CollectionAdminResponse response = createCollection(collectionName, configSet, 2, 1)
    --- End diff --
    
    I don't think this is quite right?  The test is simulating a core being left behind after a collection has been deleted (because it's parent node was down when the DELETE command was issued), so this needs to use the CoreAdmin API rather than the Collections API to create the stray core.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by romseygeek <gi...@git.apache.org>.
Github user romseygeek commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/37#discussion_r63663986
  
    --- Diff: solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java ---
    @@ -599,17 +409,17 @@ private void testNoConfigSetExist() throws Exception {
         createCmd.setCollectionConfigName("conf123");
         boolean gotExp = false;
         try {
    -      makeRequest(getBaseUrl((HttpSolrClient) clients.get(1)), createCmd);
    +      cloudClient.request(createCmd);
         } catch (SolrException e) {
           gotExp = true;
    --- End diff --
    
    Again, replacing this with ```expectThrows()``` would be good.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by romseygeek <gi...@git.apache.org>.
Github user romseygeek commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/37#discussion_r63663466
  
    --- Diff: solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java ---
    @@ -70,357 +77,193 @@
     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;
    -import org.apache.solr.common.util.SimpleOrderedMap;
     import org.apache.solr.common.util.StrUtils;
     import org.apache.solr.core.CoreContainer;
     import org.apache.solr.core.SolrCore;
     import org.apache.solr.core.SolrInfoMBean.Category;
     import org.apache.solr.util.TestInjection;
     import org.apache.solr.util.TimeOut;
    +import org.junit.After;
    +import org.junit.AfterClass;
     import org.junit.BeforeClass;
     import org.junit.Test;
     import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;
     
    -import static org.apache.solr.cloud.OverseerCollectionMessageHandler.NUM_SLICES;
    -import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
    -import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
    -import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
    -import static org.apache.solr.common.util.Utils.makeMap;
    -
     /**
      * Tests the Cloud Collections API.
      */
     @Slow
    -public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBase {
    +public class CollectionsAPIDistributedZkTest extends SolrCloudTestCase {
     
       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
    -
    -  private static final String DEFAULT_COLLECTION = "collection1";
    +  
    +  private static final int NODE_COUNT = 5;
     
       // we randomly use a second config set rather than just one
    -  private boolean secondConfigSet = random().nextBoolean();
    +  private final boolean secondConfigSet = false; //random().nextBoolean(); FIXME
    +  private final String configSet = secondConfigSet ? "conf1": "conf2";
    +
    +  private static CloudSolrClient cloudClient;
    +  private static ZkTestServer zkServer;
       
       @BeforeClass
    -  public static void beforeCollectionsAPIDistributedZkTest() {
    +  public static void setup() throws Exception {
    +    configureCluster(NODE_COUNT)
    +        .addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-jmx").resolve("conf"))
    +        .addConfig("conf2", TEST_PATH().resolve("configsets").resolve("cloud-jmx").resolve("conf"))
    +        .configure();
    +    
    +    cloudClient = cluster.buildSolrClient(random().nextBoolean());
    +    cloudClient.setParallelUpdates(random().nextBoolean());
    +    cloudClient.connect();
    +    
    +    zkServer = cluster.getZkServer();
    +    
         TestInjection.randomDelayInCoreCreation = "true:20";
         System.setProperty("validateAfterInactivity", "200");
       }
    -  
    -  @Override
    -  public void distribSetUp() throws Exception {
    -    super.distribSetUp();
    -    
    -    if (secondConfigSet ) {
    -      String zkHost = zkServer.getZkHost();
    -      String zkAddress = zkServer.getZkAddress();
    -      SolrZkClient zkClient = new SolrZkClient(zkHost, AbstractZkTestCase.TIMEOUT);
    -      zkClient.makePath("/solr", false, true);
    -      zkClient.close();
    -
    -      zkClient = new SolrZkClient(zkAddress, AbstractZkTestCase.TIMEOUT);
     
    -      File solrhome = new File(TEST_HOME());
    -      
    -      // for now, always upload the config and schema to the canonical names
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, getCloudSolrConfig(), "solrconfig.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "schema.xml", "schema.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "enumsConfig.xml", "enumsConfig.xml");
    -      
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "solrconfig.snippet.randomindexconfig.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "stopwords.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "protwords.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "currency.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "open-exchange-rates.json");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "mapping-ISOLatin1Accent.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "old_synonyms.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "synonyms.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "elevate.xml");
    -      zkClient.close();
    -    }
    +  @AfterClass
    +  public static void deleteDefaultCollection() throws Exception {
    +    cloudClient.close();
    +    zkServer.shutdown();
       }
       
    -  protected String getSolrXml() {
    -    return "solr-no-core.xml";
    -  }
    -
    -  
    -  public CollectionsAPIDistributedZkTest() {
    -    sliceCount = 2;
    -  }
    -  
    -  @Override
    -  protected void setDistributedParams(ModifiableSolrParams params) {
    -
    -    if (r.nextBoolean()) {
    -      // don't set shards, let that be figured out from the cloud state
    -    } else {
    -      // use shard ids rather than physical locations
    -      StringBuilder sb = new StringBuilder();
    -      for (int i = 0; i < getShardCount(); i++) {
    -        if (i > 0)
    -          sb.append(',');
    -        sb.append("shard" + (i + 3));
    -      }
    -      params.set("shards", sb.toString());
    -    }
    +  // make sure tests leave all our nodes live
    +  @After
    +  public void bar() {
    +    ClusterState state = cloudClient.getZkStateReader().getClusterState();
    +    assertEquals(NODE_COUNT, state.getLiveNodes().size());
       }
     
       @Test
    -  @ShardsFixed(num = 4)
    -  public void test() throws Exception {
    -    waitForRecoveriesToFinish(false); // we need to fix no core tests still
    -    testNodesUsedByCreate();
    -    testNoConfigSetExist();
    -    testCollectionsAPI();
    -    testCollectionsAPIAddRemoveStress();
    -    testErrorHandling();
    -    testNoCollectionSpecified();
    -    deletePartiallyCreatedCollection();
    -    deleteCollectionRemovesStaleZkCollectionsNode();
    -    clusterPropTest();
    -    // last
    -    deleteCollectionWithDownNodes();
    -    addReplicaTest();
    -  }
    -
    -  private void deleteCollectionRemovesStaleZkCollectionsNode() throws Exception {
    -    
    -    // we can use this client because we just want base url
    -    final String baseUrl = getBaseUrl((HttpSolrClient) clients.get(0));
    -    
    +  public void deleteCollectionRemovesStaleZkCollectionsNode() throws Exception {
         String collectionName = "out_of_sync_collection";
         
    -    List<Integer> numShardsNumReplicaList = new ArrayList<>();
    -    numShardsNumReplicaList.add(2);
    -    numShardsNumReplicaList.add(1);
    -    
    -    
         cloudClient.getZkStateReader().getZkClient().makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true);
         
    -    ModifiableSolrParams params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.DELETE.toString());
    -    params.set("name", collectionName);
    -    QueryRequest request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    -    
    -    // there are remnants of the collection in zk, should work
    -    makeRequest(baseUrl, request);
    -    
    -    assertCollectionNotExists(collectionName, 45);
    -    
    -    assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true));
    +    CollectionAdminResponse response = deleteCollection(collectionName)
    +        .process(cloudClient);
    +    assertEquals(0, response.getStatus());
     
    +    waitForCollectionToDisappear(collectionName, cloudClient.getZkStateReader(), false, true, 45);
    +    assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true));
       }
     
    -  private void deletePartiallyCreatedCollection() throws Exception {
    -    final String baseUrl = getBaseUrl((HttpSolrClient) clients.get(0));
    +  @Test
    +  public void deletePartiallyCreatedCollection() throws Exception {
         String collectionName = "halfdeletedcollection";
    -    Create createCmd = new Create();
    -    createCmd.setCoreName("halfdeletedcollection_shard1_replica1");
    -    createCmd.setCollection(collectionName);
    -    String dataDir = createTempDir().toFile().getAbsolutePath();
    -    createCmd.setDataDir(dataDir);
    -    createCmd.setNumShards(2);
    -    if (secondConfigSet) {
    -      createCmd.setCollectionConfigName("conf1");
    -    }
     
    -    makeRequest(baseUrl, createCmd);
    -
    -    ModifiableSolrParams params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.DELETE.toString());
    -    params.set("name", collectionName);
    -    QueryRequest request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    +    Properties properties = new Properties();
    +    properties.put(CoreAdminParams.DATA_DIR, createTempDir().toFile().getAbsolutePath());
    +    properties.put(CoreAdminParams.CORE, "halfdeletedcollection_shard1_replica1");
    +    CollectionAdminResponse response = createCollection(collectionName, configSet, 2, 1)
    +        .setProperties(properties)
    +        .process(cloudClient);
    +    assertEquals(0, response.getStatus());
    +    
    +    response = deleteCollection(collectionName)
    +        .process(cloudClient);
     
    -    makeRequest(baseUrl, request);
    +    waitForCollectionToDisappear(collectionName, cloudClient.getZkStateReader(), false, true, 45);
    +    assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true));
     
    -    assertCollectionNotExists(collectionName, 45);
    -    
         // now creating that collection should work
    -    params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.CREATE.toString());
    -    params.set("name", collectionName);
    -    params.set("numShards", 2);
    -    request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    -    if (secondConfigSet) {
    -      params.set("collection.configName", "conf1");
    -    }
    -    makeRequest(baseUrl, request);
    +    response = createCollection(collectionName, configSet, 2, 1)
    +        .process(cloudClient);
    +    assertEquals(0, response.getStatus());
       }
       
    -  private void deleteCollectionOnlyInZk() throws Exception {
    -    final String baseUrl = getBaseUrl((HttpSolrClient) clients.get(0));
    +  @Test
    +  public void deleteCollectionOnlyInZk() throws Exception {
         String collectionName = "onlyinzk";
     
         cloudClient.getZkStateReader().getZkClient().makePath(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true);
     
    -    ModifiableSolrParams params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.DELETE.toString());
    -    params.set("name", collectionName);
    -    QueryRequest request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    -
    -    makeRequest(baseUrl, request);
    +    CollectionAdminResponse response = deleteCollection(collectionName)
    +        .process(cloudClient);
    +    assertEquals(0, response.getStatus());
     
    -    assertCollectionNotExists(collectionName, 45);
    +    waitForCollectionToDisappear(collectionName, cloudClient.getZkStateReader(), false, true, 45);
    +    assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, true));
         
         // now creating that collection should work
    -    params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.CREATE.toString());
    -    params.set("name", collectionName);
    -    params.set("numShards", 2);
    -    request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    -    if (secondConfigSet) {
    -      params.set("collection.configName", "conf1");
    -    }
    -    makeRequest(baseUrl, request);
    +    response = createCollection(collectionName, configSet, 2, 1)
    +        .process(cloudClient);
    +    assertEquals(0, response.getStatus());
         
    -    waitForRecoveriesToFinish(collectionName, false);
    +    ZkStateReader zkStateReader = cloudClient.getZkStateReader();
    +    waitForRecoveriesToFinish(collectionName, zkStateReader, false, true, 330);
         
    -    params = new ModifiableSolrParams();
    -    params.set("action", CollectionAction.DELETE.toString());
    -    params.set("name", collectionName);
    -    request = new QueryRequest(params);
    -    request.setPath("/admin/collections");
    -
    -    makeRequest(baseUrl, request);
    +    response = deleteCollection(collectionName)
    +        .process(cloudClient);
    +    assertEquals(0, response.getStatus());
       }
       
    -  private void deleteCollectionWithUnloadedCore() throws Exception {
    --- End diff --
    
    Can you migrate this test as well, and ```@Ignore``` it?  At some point someone will want to fix this, I think...


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org


[GitHub] lucene-solr pull request: Move to SolrCloudTestCase

Posted by romseygeek <gi...@git.apache.org>.
Github user romseygeek commented on a diff in the pull request:

    https://github.com/apache/lucene-solr/pull/37#discussion_r63664257
  
    --- Diff: solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java ---
    @@ -70,357 +77,193 @@
     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;
    -import org.apache.solr.common.util.SimpleOrderedMap;
     import org.apache.solr.common.util.StrUtils;
     import org.apache.solr.core.CoreContainer;
     import org.apache.solr.core.SolrCore;
     import org.apache.solr.core.SolrInfoMBean.Category;
     import org.apache.solr.util.TestInjection;
     import org.apache.solr.util.TimeOut;
    +import org.junit.After;
    +import org.junit.AfterClass;
     import org.junit.BeforeClass;
     import org.junit.Test;
     import org.slf4j.Logger;
     import org.slf4j.LoggerFactory;
     
    -import static org.apache.solr.cloud.OverseerCollectionMessageHandler.NUM_SLICES;
    -import static org.apache.solr.common.cloud.ZkStateReader.CORE_NAME_PROP;
    -import static org.apache.solr.common.cloud.ZkStateReader.MAX_SHARDS_PER_NODE;
    -import static org.apache.solr.common.cloud.ZkStateReader.REPLICATION_FACTOR;
    -import static org.apache.solr.common.util.Utils.makeMap;
    -
     /**
      * Tests the Cloud Collections API.
      */
     @Slow
    -public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBase {
    +public class CollectionsAPIDistributedZkTest extends SolrCloudTestCase {
     
       private static final Logger log = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
    -
    -  private static final String DEFAULT_COLLECTION = "collection1";
    +  
    +  private static final int NODE_COUNT = 5;
     
       // we randomly use a second config set rather than just one
    -  private boolean secondConfigSet = random().nextBoolean();
    +  private final boolean secondConfigSet = false; //random().nextBoolean(); FIXME
    +  private final String configSet = secondConfigSet ? "conf1": "conf2";
    +
    +  private static CloudSolrClient cloudClient;
    +  private static ZkTestServer zkServer;
       
       @BeforeClass
    -  public static void beforeCollectionsAPIDistributedZkTest() {
    +  public static void setup() throws Exception {
    +    configureCluster(NODE_COUNT)
    +        .addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-jmx").resolve("conf"))
    +        .addConfig("conf2", TEST_PATH().resolve("configsets").resolve("cloud-jmx").resolve("conf"))
    +        .configure();
    +    
    +    cloudClient = cluster.buildSolrClient(random().nextBoolean());
    +    cloudClient.setParallelUpdates(random().nextBoolean());
    +    cloudClient.connect();
    +    
    +    zkServer = cluster.getZkServer();
    +    
         TestInjection.randomDelayInCoreCreation = "true:20";
         System.setProperty("validateAfterInactivity", "200");
       }
    -  
    -  @Override
    -  public void distribSetUp() throws Exception {
    -    super.distribSetUp();
    -    
    -    if (secondConfigSet ) {
    -      String zkHost = zkServer.getZkHost();
    -      String zkAddress = zkServer.getZkAddress();
    -      SolrZkClient zkClient = new SolrZkClient(zkHost, AbstractZkTestCase.TIMEOUT);
    -      zkClient.makePath("/solr", false, true);
    -      zkClient.close();
    -
    -      zkClient = new SolrZkClient(zkAddress, AbstractZkTestCase.TIMEOUT);
     
    -      File solrhome = new File(TEST_HOME());
    -      
    -      // for now, always upload the config and schema to the canonical names
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, getCloudSolrConfig(), "solrconfig.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "schema.xml", "schema.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "enumsConfig.xml", "enumsConfig.xml");
    -      
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "solrconfig.snippet.randomindexconfig.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "stopwords.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "protwords.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "currency.xml");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "open-exchange-rates.json");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "mapping-ISOLatin1Accent.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "old_synonyms.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "synonyms.txt");
    -      AbstractZkTestCase.putConfig("conf2", zkClient, solrhome, "elevate.xml");
    -      zkClient.close();
    -    }
    +  @AfterClass
    --- End diff --
    
    You don't need to do this, SolrCloudTestCase handles shutdown logic itself


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org