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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to