Search in sources :

Example 1 with CollectionAdminRequest

use of org.apache.solr.client.solrj.request.CollectionAdminRequest in project lucene-solr by apache.

the class SimpleCollectionCreateDeleteTest method test.

@Test
@ShardsFixed(num = 1)
public void test() throws Exception {
    String overseerNode = OverseerCollectionConfigSetProcessor.getLeaderNode(cloudClient.getZkStateReader().getZkClient());
    String notOverseerNode = null;
    for (CloudJettyRunner cloudJetty : cloudJettys) {
        if (!overseerNode.equals(cloudJetty.nodeName)) {
            notOverseerNode = cloudJetty.nodeName;
            break;
        }
    }
    String collectionName = "SimpleCollectionCreateDeleteTest";
    CollectionAdminRequest.Create create = CollectionAdminRequest.createCollection(collectionName, 1, 1).setCreateNodeSet(overseerNode).setStateFormat(2);
    NamedList<Object> request = create.process(cloudClient).getResponse();
    if (request.get("success") != null) {
        assertTrue(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, false));
        CollectionAdminRequest delete = CollectionAdminRequest.deleteCollection(collectionName);
        cloudClient.request(delete);
        assertFalse(cloudClient.getZkStateReader().getZkClient().exists(ZkStateReader.COLLECTIONS_ZKNODE + "/" + collectionName, false));
        // create collection again on a node other than the overseer leader
        create = CollectionAdminRequest.createCollection(collectionName, 1, 1).setCreateNodeSet(notOverseerNode).setStateFormat(2);
        request = create.process(cloudClient).getResponse();
        assertTrue("Collection creation should not have failed", request.get("success") != null);
    }
}
Also used : CollectionAdminRequest(org.apache.solr.client.solrj.request.CollectionAdminRequest) Test(org.junit.Test)

Example 2 with CollectionAdminRequest

use of org.apache.solr.client.solrj.request.CollectionAdminRequest in project lucene-solr by apache.

the class CollectionsAPIDistributedZkTest method testTooManyReplicas.

@Test
public void testTooManyReplicas() {
    CollectionAdminRequest req = CollectionAdminRequest.createCollection("collection", "conf", 2, 10);
    expectThrows(Exception.class, () -> {
        cluster.getSolrClient().request(req);
    });
}
Also used : CollectionAdminRequest(org.apache.solr.client.solrj.request.CollectionAdminRequest) Test(org.junit.Test)

Aggregations

CollectionAdminRequest (org.apache.solr.client.solrj.request.CollectionAdminRequest)2 Test (org.junit.Test)2