mirror of https://github.com/apache/lucene.git
SOLR-9632: Add deleteAllCollections method to MiniSolrCloudCluster
This commit is contained in:
parent
f870c2069c
commit
20ea5355c9
|
@ -283,6 +283,8 @@ Other Changes
|
|||
|
||||
* SOLR-9627: Add QParser.getSortSpec, deprecate misleadingly named QParser.getSort (Judith Silverman, Christine Poerschke)
|
||||
|
||||
* SOLR-9632: Add MiniSolrCloudCluster#deleteAllCollections() method (Alan Woodward)
|
||||
|
||||
================== 6.2.1 ==================
|
||||
|
||||
Bug Fixes
|
||||
|
|
|
@ -29,6 +29,7 @@ import org.apache.solr.client.solrj.request.GenericSolrRequest;
|
|||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.junit.After;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
import org.junit.rules.ExpectedException;
|
||||
|
@ -54,6 +55,11 @@ public class RulesTest extends SolrCloudTestCase {
|
|||
@org.junit.Rule
|
||||
public ExpectedException expectedException = ExpectedException.none();
|
||||
|
||||
@After
|
||||
public void removeCollections() throws Exception {
|
||||
cluster.deleteAllCollections();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void doIntegrationTest() throws Exception {
|
||||
final long minGB = (random().nextBoolean() ? 1 : 0);
|
||||
|
@ -80,8 +86,6 @@ public class RulesTest extends SolrCloudTestCase {
|
|||
CollectionAdminRequest.createShard(rulesColl, "shard2").process(cluster.getSolrClient());
|
||||
CollectionAdminRequest.addReplicaToShard(rulesColl, "shard2").process(cluster.getSolrClient());
|
||||
|
||||
CollectionAdminRequest.deleteCollection(rulesColl).process(cluster.getSolrClient());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -105,7 +109,6 @@ public class RulesTest extends SolrCloudTestCase {
|
|||
assertEquals(1, list.size());
|
||||
assertEquals ( "ImplicitSnitch", ((Map)list.get(0)).get("class"));
|
||||
|
||||
CollectionAdminRequest.deleteCollection(rulesColl).process(cluster.getSolrClient());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -134,7 +137,6 @@ public class RulesTest extends SolrCloudTestCase {
|
|||
assertEquals(1, list.size());
|
||||
assertEquals("ImplicitSnitch", list.get(0).get("class"));
|
||||
|
||||
CollectionAdminRequest.deleteCollection(rulesColl).process(cluster.getSolrClient());
|
||||
}
|
||||
|
||||
|
||||
|
@ -157,8 +159,6 @@ public class RulesTest extends SolrCloudTestCase {
|
|||
.setSnitch("class:ImplicitSnitch")
|
||||
.process(cluster.getSolrClient());
|
||||
|
||||
CollectionAdminRequest.deleteCollection(rulesColl).process(cluster.getSolrClient());
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -201,6 +201,5 @@ public class RulesTest extends SolrCloudTestCase {
|
|||
assertEquals(1, list.size());
|
||||
assertEquals("ImplicitSnitch", ((Map) list.get(0)).get("class"));
|
||||
|
||||
CollectionAdminRequest.deleteCollection(rulesColl).process(cluster.getSolrClient());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,6 +46,7 @@ import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
|||
import org.apache.solr.client.solrj.embedded.SSLConfig;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient.Builder;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.QueryRequest;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.SolrZkClient;
|
||||
|
@ -401,6 +402,15 @@ public class MiniSolrCloudCluster {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NamedList<Object> createCollection(String name, int numShards, int replicationFactor,
|
||||
String configName, Map<String, String> collectionProperties) throws SolrServerException, IOException {
|
||||
return createCollection(name, numShards, replicationFactor, configName, null, null, collectionProperties);
|
||||
|
|
Loading…
Reference in New Issue