public void deleteAllCollections() throws Exception { try (ZkStateReader reader = new ZkStateReader(solrClient.getZkStateReader().getZkClient())) { reader.createClusterStateWatchersAndUpdate(); for (String collection : reader.getClusterState().getCollectionStates().keySet()) { CollectionAdminRequest.deleteCollection(collection).process(solrClient); } } }
@AfterClass public static void shutdown() { log.info( "DistribJoinFromCollectionTest logic complete ... deleting the " + toColl + " and " + fromColl + " collections"); // try to clean up for (String c : new String[] {toColl, fromColl}) { try { CollectionAdminRequest.Delete req = CollectionAdminRequest.deleteCollection(c); req.process(cluster.getSolrClient()); } catch (Exception e) { // don't fail the test log.warn("Could not delete collection {} after test completed due to: " + e, c); } } log.info("DistribJoinFromCollectionTest succeeded ... shutting down now!"); }
private void testSolrJAPICalls() throws Exception { SolrServer server = createNewSolrServer("", getBaseUrl((HttpSolrServer) clients.get(0))); CollectionAdminResponse response; Map<String, NamedList<Integer>> coresStatus; Map<String, NamedList<Integer>> nodesStatus; response = CollectionAdminRequest.createCollection( "solrj_collection", 2, 2, null, null, "conf1", "myOwnField", server); assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); coresStatus = response.getCollectionCoresStatus(); assertEquals(4, coresStatus.size()); for (int i = 0; i < 4; i++) { NamedList<Integer> status = coresStatus.get("solrj_collection_shard" + (i / 2 + 1) + "_replica" + (i % 2 + 1)); assertEquals(0, (int) status.get("status")); assertTrue(status.get("QTime") > 0); } response = CollectionAdminRequest.createCollection("solrj_implicit", "shardA,shardB", "conf1", server); assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); coresStatus = response.getCollectionCoresStatus(); assertEquals(2, coresStatus.size()); response = CollectionAdminRequest.createShard("solrj_implicit", "shardC", server); assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); coresStatus = response.getCollectionCoresStatus(); assertEquals(1, coresStatus.size()); assertEquals(0, (int) coresStatus.get("solrj_implicit_shardC_replica1").get("status")); response = CollectionAdminRequest.deleteShard("solrj_implicit", "shardC", server); assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); nodesStatus = response.getCollectionNodesStatus(); assertEquals(1, nodesStatus.size()); response = CollectionAdminRequest.deleteCollection("solrj_implicit", server); assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); nodesStatus = response.getCollectionNodesStatus(); assertEquals(2, nodesStatus.size()); response = CollectionAdminRequest.createCollection("conf1", 4, "conf1", server); assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); response = CollectionAdminRequest.reloadCollection("conf1", server); assertEquals(0, response.getStatus()); response = CollectionAdminRequest.createAlias("solrj_alias", "conf1,solrj_collection", server); assertEquals(0, response.getStatus()); response = CollectionAdminRequest.deleteAlias("solrj_alias", server); assertEquals(0, response.getStatus()); response = CollectionAdminRequest.splitShard("conf1", "shard1", server); assertEquals(0, response.getStatus()); assertTrue(response.isSuccess()); coresStatus = response.getCollectionCoresStatus(); assertEquals(0, (int) coresStatus.get("conf1_shard1_0_replica1").get("status")); assertEquals(0, (int) coresStatus.get("conf1_shard1_0_replica1").get("status")); response = CollectionAdminRequest.deleteCollection("conf1", server); assertEquals(0, response.getStatus()); nodesStatus = response.getCollectionNodesStatus(); assertTrue(response.isSuccess()); assertEquals(4, nodesStatus.size()); response = CollectionAdminRequest.deleteCollection("solrj_collection", server); assertEquals(0, response.getStatus()); nodesStatus = response.getCollectionNodesStatus(); assertTrue(response.isSuccess()); assertEquals(4, nodesStatus.size()); }