use of org.apache.solr.client.solrj.request.CoreStatus in project lucene-solr by apache.
the class DeleteShardTest method testDirectoryCleanupAfterDeleteShard.
@Test
public void testDirectoryCleanupAfterDeleteShard() throws InterruptedException, IOException, SolrServerException {
final String collection = "deleteshard_test";
CollectionAdminRequest.createCollectionWithImplicitRouter(collection, "conf", "a,b,c", 1).setMaxShardsPerNode(2).process(cluster.getSolrClient());
// Get replica details
Replica leader = getCollectionState(collection).getLeader("a");
CoreStatus coreStatus = getCoreStatus(leader);
assertTrue("Instance directory doesn't exist", FileUtils.fileExists(coreStatus.getInstanceDirectory()));
assertTrue("Data directory doesn't exist", FileUtils.fileExists(coreStatus.getDataDirectory()));
assertEquals(3, getCollectionState(collection).getActiveSlices().size());
// Delete shard 'a'
CollectionAdminRequest.deleteShard(collection, "a").process(cluster.getSolrClient());
assertEquals(2, getCollectionState(collection).getActiveSlices().size());
assertFalse("Instance directory still exists", FileUtils.fileExists(coreStatus.getInstanceDirectory()));
assertFalse("Data directory still exists", FileUtils.fileExists(coreStatus.getDataDirectory()));
leader = getCollectionState(collection).getLeader("b");
coreStatus = getCoreStatus(leader);
// Delete shard 'b'
CollectionAdminRequest.deleteShard(collection, "b").setDeleteDataDir(false).setDeleteInstanceDir(false).process(cluster.getSolrClient());
assertEquals(1, getCollectionState(collection).getActiveSlices().size());
assertTrue("Instance directory still exists", FileUtils.fileExists(coreStatus.getInstanceDirectory()));
assertTrue("Data directory still exists", FileUtils.fileExists(coreStatus.getDataDirectory()));
}
Aggregations