mirror of https://github.com/apache/lucene.git
SOLR-9634: Deprecate create/deleteCollection methods on MiniSolrCloudCluster
This commit is contained in:
parent
d6dc1321a9
commit
df09867ccc
|
@ -45,6 +45,11 @@ prefix, then you will now get an error as these options are incompatible with nu
|
|||
you may need to update the log configs to use the DEBUG level to get the
|
||||
same logging messages as before.
|
||||
|
||||
* The create/deleteCollection methods on MiniSolrCloudCluster have been
|
||||
deprecated. Clients should instead use the CollectionAdminRequest API. In
|
||||
addition, MiniSolrCloudCluster#uploadConfigSet(File, String) has been
|
||||
deprecated in favour of #uploadConfigSet(Path, String)
|
||||
|
||||
New Features
|
||||
----------------------
|
||||
* SOLR-5725: facet.method=enum can bypass exact counts calculation with facet.exists=true, it just returns 1 for
|
||||
|
@ -252,6 +257,8 @@ Other Changes
|
|||
|
||||
* SOLR-9632: Add MiniSolrCloudCluster#deleteAllCollections() method (Alan Woodward)
|
||||
|
||||
* SOLR-9634: Deprecate collection methods on MiniSolrCloudCluster (Alan Woodward)
|
||||
|
||||
================== 6.2.1 ==================
|
||||
|
||||
Bug Fixes
|
||||
|
|
|
@ -17,13 +17,9 @@
|
|||
|
||||
package org.apache.solr.cloud;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
|
@ -32,6 +28,7 @@ import org.apache.solr.client.solrj.SolrServerException;
|
|||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.request.AbstractUpdateRequest;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
|
@ -71,17 +68,13 @@ public class CdcrBootstrapTest extends SolrTestCaseJ4 {
|
|||
MiniSolrCloudCluster source = new MiniSolrCloudCluster(1, createTempDir("cdcr-source"), buildJettyConfig("/solr"));
|
||||
try {
|
||||
source.waitForAllNodes(30);
|
||||
final File configDir = getFile("solr").toPath().resolve("configsets/cdcr-source-disabled").toFile();
|
||||
System.out.println("config dir absolute path = " + configDir.getAbsolutePath());
|
||||
source.uploadConfigDir(configDir, "cdcr-source");
|
||||
source.uploadConfigSet(configset("cdcr-source-disabled"), "cdcr-source");
|
||||
|
||||
// create a collection with the cdcr-source-disabled configset
|
||||
Map<String, String> collectionProperties = new HashMap<>();
|
||||
// todo investigate why this is necessary??? because by default it selects a ram directory which deletes the tlogs on reloads?
|
||||
collectionProperties.putIfAbsent("solr.directoryFactory", "solr.StandardDirectoryFactory");
|
||||
source.createCollection("cdcr-source", 1, 1, "cdcr-source", collectionProperties);
|
||||
source.getSolrClient().getZkStateReader().forceUpdateCollection("cdcr-source");
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish("cdcr-source", source.getSolrClient().getZkStateReader(), true, true, 330);
|
||||
CollectionAdminRequest.createCollection("cdcr-source", "cdcr-source", 1, 1)
|
||||
// todo investigate why this is necessary??? because by default it selects a ram directory which deletes the tlogs on reloads?
|
||||
.withProperty("solr.directoryFactory", "solr.StandardDirectoryFactory")
|
||||
.process(source.getSolrClient());
|
||||
|
||||
// index 10000 docs with a hard commit every 1000 documents
|
||||
CloudSolrClient sourceSolrClient = source.getSolrClient();
|
||||
|
@ -115,8 +108,7 @@ public class CdcrBootstrapTest extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
// upload the cdcr-enabled config and restart source cluster
|
||||
final File cdcrEnabledSourceConfigDir = getFile("solr").toPath().resolve("configsets/cdcr-source").toFile();
|
||||
source.uploadConfigDir(cdcrEnabledSourceConfigDir, "cdcr-source");
|
||||
source.uploadConfigSet(configset("cdcr-source"), "cdcr-source");
|
||||
JettySolrRunner runner = source.stopJettySolrRunner(0);
|
||||
source.startJettySolrRunner(runner);
|
||||
assertTrue(runner.isRunning());
|
||||
|
@ -126,11 +118,9 @@ public class CdcrBootstrapTest extends SolrTestCaseJ4 {
|
|||
assertEquals("Document mismatch on source after restart", numDocs, response.getResults().getNumFound());
|
||||
|
||||
// setup the target cluster
|
||||
final File targetConfigDir = getFile("solr").toPath().resolve("configsets/cdcr-target").toFile();
|
||||
target.uploadConfigDir(targetConfigDir, "cdcr-target");
|
||||
target.createCollection("cdcr-target", 1, 1, "cdcr-target", Collections.emptyMap());
|
||||
target.getSolrClient().getZkStateReader().forceUpdateCollection("cdcr-target");
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish("cdcr-target", target.getSolrClient().getZkStateReader(), true, true, 330);
|
||||
target.uploadConfigSet(configset("cdcr-target"), "cdcr-target");
|
||||
CollectionAdminRequest.createCollection("cdcr-target", "cdcr-target", 1, 1)
|
||||
.process(target.getSolrClient());
|
||||
CloudSolrClient targetSolrClient = target.getSolrClient();
|
||||
targetSolrClient.setDefaultCollection("cdcr-target");
|
||||
Thread.sleep(1000);
|
||||
|
@ -174,16 +164,11 @@ public class CdcrBootstrapTest extends SolrTestCaseJ4 {
|
|||
MiniSolrCloudCluster source = new MiniSolrCloudCluster(1, createTempDir("cdcr-source"), buildJettyConfig("/solr"));
|
||||
try {
|
||||
source.waitForAllNodes(30);
|
||||
final File configDir = getFile("solr").toPath().resolve("configsets/cdcr-source").toFile();
|
||||
System.out.println("config dir absolute path = " + configDir.getAbsolutePath());
|
||||
source.uploadConfigDir(configDir, "cdcr-source");
|
||||
source.uploadConfigSet(configset("cdcr-source"), "cdcr-source");
|
||||
|
||||
Map<String, String> collectionProperties = new HashMap<>();
|
||||
// todo investigate why this is necessary???
|
||||
collectionProperties.putIfAbsent("solr.directoryFactory", "solr.StandardDirectoryFactory");
|
||||
source.createCollection("cdcr-source", 1, 1, "cdcr-source", collectionProperties);
|
||||
source.getSolrClient().getZkStateReader().forceUpdateCollection("cdcr-source");
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish("cdcr-source", source.getSolrClient().getZkStateReader(), true, true, 330);
|
||||
CollectionAdminRequest.createCollection("cdcr-source", "cdcr-source", 1, 1)
|
||||
.withProperty("solr.directoryFactory", "solr.StandardDirectoryFactory")
|
||||
.process(source.getSolrClient());
|
||||
|
||||
// index 10000 docs with a hard commit every 1000 documents
|
||||
CloudSolrClient sourceSolrClient = source.getSolrClient();
|
||||
|
@ -206,11 +191,9 @@ public class CdcrBootstrapTest extends SolrTestCaseJ4 {
|
|||
assertEquals("", numDocs, response.getResults().getNumFound());
|
||||
|
||||
// setup the target cluster
|
||||
final File targetConfigDir = getFile("solr").toPath().resolve("configsets/cdcr-target").toFile();
|
||||
target.uploadConfigDir(targetConfigDir, "cdcr-target");
|
||||
target.createCollection("cdcr-target", 1, 1, "cdcr-target", Collections.emptyMap());
|
||||
target.getSolrClient().getZkStateReader().forceUpdateCollection("cdcr-target");
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish("cdcr-target", target.getSolrClient().getZkStateReader(), true, true, 330);
|
||||
target.uploadConfigSet(configset("cdcr-target"), "cdcr-target");
|
||||
CollectionAdminRequest.createCollection("cdcr-target", "cdcr-target", 1, 1)
|
||||
.process(target.getSolrClient());
|
||||
CloudSolrClient targetSolrClient = target.getSolrClient();
|
||||
targetSolrClient.setDefaultCollection("cdcr-target");
|
||||
|
||||
|
@ -267,16 +250,11 @@ public class CdcrBootstrapTest extends SolrTestCaseJ4 {
|
|||
MiniSolrCloudCluster source = new MiniSolrCloudCluster(1, createTempDir("cdcr-source"), buildJettyConfig("/solr"));
|
||||
try {
|
||||
source.waitForAllNodes(30);
|
||||
final File configDir = getFile("solr").toPath().resolve("configsets/cdcr-source").toFile();
|
||||
System.out.println("config dir absolute path = " + configDir.getAbsolutePath());
|
||||
source.uploadConfigDir(configDir, "cdcr-source");
|
||||
source.uploadConfigSet(configset("cdcr-source"), "cdcr-source");
|
||||
|
||||
Map<String, String> collectionProperties = new HashMap<>();
|
||||
// todo investigate why this is necessary???
|
||||
collectionProperties.putIfAbsent("solr.directoryFactory", "solr.StandardDirectoryFactory");
|
||||
source.createCollection("cdcr-source", 1, 1, "cdcr-source", collectionProperties);
|
||||
source.getSolrClient().getZkStateReader().forceUpdateCollection("cdcr-source");
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish("cdcr-source", source.getSolrClient().getZkStateReader(), true, true, 330);
|
||||
CollectionAdminRequest.createCollection("cdcr-source", "cdcr-source", 1, 1)
|
||||
.withProperty("solr.directoryFactory", "solr.StandardDirectoryFactory")
|
||||
.process(source.getSolrClient());
|
||||
|
||||
// index 10000 docs with a hard commit every 1000 documents
|
||||
CloudSolrClient sourceSolrClient = source.getSolrClient();
|
||||
|
@ -299,11 +277,9 @@ public class CdcrBootstrapTest extends SolrTestCaseJ4 {
|
|||
assertEquals("", numDocs, response.getResults().getNumFound());
|
||||
|
||||
// setup the target cluster
|
||||
final File targetConfigDir = getFile("solr").toPath().resolve("configsets/cdcr-target").toFile();
|
||||
target.uploadConfigDir(targetConfigDir, "cdcr-target");
|
||||
target.createCollection("cdcr-target", 1, 1, "cdcr-target", Collections.emptyMap());
|
||||
target.getSolrClient().getZkStateReader().forceUpdateCollection("cdcr-target");
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish("cdcr-target", target.getSolrClient().getZkStateReader(), true, true, 330);
|
||||
target.uploadConfigSet(configset("cdcr-target"), "cdcr-target");
|
||||
CollectionAdminRequest.createCollection("cdcr-target", "cdcr-target", 1, 1)
|
||||
.process(target.getSolrClient());
|
||||
CloudSolrClient targetSolrClient = target.getSolrClient();
|
||||
targetSolrClient.setDefaultCollection("cdcr-target");
|
||||
Thread.sleep(1000);
|
||||
|
|
|
@ -16,8 +16,8 @@
|
|||
*/
|
||||
package org.apache.solr.cloud;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
|
@ -52,13 +52,12 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
public void testConcurrentCreateAndDeleteDoesNotFail() {
|
||||
final File configDir = getFile("solr").toPath().resolve("configsets/configset-2/conf").toFile();
|
||||
final AtomicReference<Exception> failure = new AtomicReference<>();
|
||||
final int timeToRunSec = 30;
|
||||
final Thread[] threads = new Thread[10];
|
||||
for (int i = 0; i < threads.length; i++) {
|
||||
final String collectionName = "collection" + i;
|
||||
uploadConfig(configDir, collectionName);
|
||||
uploadConfig(configset("configset-2"), collectionName);
|
||||
final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString();
|
||||
final SolrClient solrClient = getHttpSolrClient(baseUrl);
|
||||
threads[i] = new CreateDeleteSearchCollectionThread("create-delete-search-" + i, collectionName, collectionName,
|
||||
|
@ -73,8 +72,7 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
|
|||
|
||||
public void testConcurrentCreateAndDeleteOverTheSameConfig() {
|
||||
final String configName = "testconfig";
|
||||
final File configDir = getFile("solr").toPath().resolve("configsets/configset-2/conf").toFile();
|
||||
uploadConfig(configDir, configName); // upload config once, to be used by all collections
|
||||
uploadConfig(configset("configset-2"), configName); // upload config once, to be used by all collections
|
||||
final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString();
|
||||
final SolrClient solrClient = getHttpSolrClient(baseUrl);
|
||||
final AtomicReference<Exception> failure = new AtomicReference<>();
|
||||
|
@ -98,9 +96,9 @@ public class ConcurrentDeleteAndCreateCollectionTest extends SolrTestCaseJ4 {
|
|||
}
|
||||
}
|
||||
|
||||
private void uploadConfig(File configDir, String configName) {
|
||||
private void uploadConfig(Path configDir, String configName) {
|
||||
try {
|
||||
solrCluster.uploadConfigDir(configDir, configName);
|
||||
solrCluster.uploadConfigSet(configDir, configName);
|
||||
} catch (IOException | KeeperException | InterruptedException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
|
@ -16,8 +16,6 @@
|
|||
*/
|
||||
package org.apache.solr.cloud;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.nio.file.Path;
|
||||
|
@ -49,6 +47,8 @@ import org.junit.Test;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.not;
|
||||
|
||||
/**
|
||||
* Tests using fromIndex that points to a collection in SolrCloud mode.
|
||||
*/
|
||||
|
@ -83,10 +83,10 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
|
|||
|
||||
int shards = 2;
|
||||
int replicas = 2 ;
|
||||
assertNotNull(cluster.createCollection(toColl, shards, replicas,
|
||||
configName,
|
||||
collectionProperties));
|
||||
|
||||
CollectionAdminRequest.createCollection(toColl, configName, shards, replicas)
|
||||
.setProperties(collectionProperties)
|
||||
.process(cluster.getSolrClient());
|
||||
|
||||
// get the set of nodes where replicas for the "to" collection exist
|
||||
Set<String> nodeSet = new HashSet<>();
|
||||
ZkStateReader zkStateReader = cluster.getSolrClient().getZkStateReader();
|
||||
|
@ -97,14 +97,11 @@ public class DistribJoinFromCollectionTest extends SolrCloudTestCase{
|
|||
assertTrue(nodeSet.size() > 0);
|
||||
|
||||
// deploy the "from" collection to all nodes where the "to" collection exists
|
||||
|
||||
assertNotNull(cluster.createCollection(fromColl, 1, 4,
|
||||
configName, StringUtils.join(nodeSet,","), null,
|
||||
collectionProperties));
|
||||
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish(toColl, zkStateReader, false, true, 30);
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish(fromColl, zkStateReader, false, true, 30);
|
||||
|
||||
CollectionAdminRequest.createCollection(fromColl, configName, 1, 4)
|
||||
.setCreateNodeSet(StringUtils.join(nodeSet, ","))
|
||||
.setProperties(collectionProperties)
|
||||
.process(cluster.getSolrClient());
|
||||
|
||||
toDocId = indexDoc(toColl, 1001, "a", null, "b");
|
||||
indexDoc(fromColl, 2001, "a", "c", null);
|
||||
|
||||
|
|
|
@ -16,19 +16,18 @@
|
|||
*/
|
||||
package org.apache.solr.cloud;
|
||||
|
||||
import java.io.File;
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.FilterChain;
|
||||
import javax.servlet.ServletRequest;
|
||||
import javax.servlet.ServletResponse;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
|
||||
import org.apache.http.HttpException;
|
||||
import org.apache.http.HttpRequest;
|
||||
import org.apache.http.HttpRequestInterceptor;
|
||||
|
@ -43,8 +42,8 @@ import org.apache.solr.client.solrj.embedded.JettyConfig;
|
|||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpClientConfigurer;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.client.solrj.response.RequestStatusState;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
|
@ -63,8 +62,6 @@ import org.junit.rules.TestRule;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
|
||||
|
||||
/**
|
||||
* Test of the MiniSolrCloudCluster functionality with authentication enabled.
|
||||
*/
|
||||
|
@ -144,8 +141,7 @@ public class TestAuthenticationFramework extends LuceneTestCase {
|
|||
private void createCollection(MiniSolrCloudCluster miniCluster, String collectionName, String asyncId)
|
||||
throws Exception {
|
||||
String configName = "solrCloudCollectionConfig";
|
||||
File configDir = new File(SolrTestCaseJ4.TEST_HOME() + File.separator + "collection1" + File.separator + "conf");
|
||||
miniCluster.uploadConfigDir(configDir, configName);
|
||||
miniCluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1/conf"), configName);
|
||||
|
||||
final boolean persistIndex = random().nextBoolean();
|
||||
Map<String, String> collectionProperties = new HashMap<>();
|
||||
|
@ -166,7 +162,17 @@ public class TestAuthenticationFramework extends LuceneTestCase {
|
|||
collectionProperties.putIfAbsent("solr.tests.mergeScheduler", "org.apache.lucene.index.ConcurrentMergeScheduler");
|
||||
collectionProperties.putIfAbsent("solr.directoryFactory", (persistIndex ? "solr.StandardDirectoryFactory" : "solr.RAMDirectoryFactory"));
|
||||
|
||||
miniCluster.createCollection(collectionName, NUM_SHARDS, REPLICATION_FACTOR, configName, null, asyncId, collectionProperties);
|
||||
if (asyncId == null) {
|
||||
CollectionAdminRequest.createCollection(collectionName, configName, NUM_SHARDS, REPLICATION_FACTOR)
|
||||
.setProperties(collectionProperties)
|
||||
.process(miniCluster.getSolrClient());
|
||||
}
|
||||
else {
|
||||
CollectionAdminRequest.createCollection(collectionName, configName, NUM_SHARDS, REPLICATION_FACTOR)
|
||||
.setProperties(collectionProperties)
|
||||
.processAndWait(miniCluster.getSolrClient(), 30);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void collectionCreateSearchDelete(MiniSolrCloudCluster miniCluster) throws Exception {
|
||||
|
@ -186,11 +192,6 @@ public class TestAuthenticationFramework extends LuceneTestCase {
|
|||
log.info("#### Creating a collection");
|
||||
final String asyncId = (random().nextBoolean() ? null : "asyncId("+collectionName+".create)="+random().nextInt());
|
||||
createCollection(miniCluster, collectionName, asyncId);
|
||||
if (asyncId != null) {
|
||||
final RequestStatusState state = AbstractFullDistribZkTestBase.getRequestStateAfterCompletion(asyncId, 330,
|
||||
cloudSolrClient);
|
||||
assertSame("did not see async createCollection completion", RequestStatusState.COMPLETED, state);
|
||||
}
|
||||
|
||||
ZkStateReader zkStateReader = miniCluster.getSolrClient().getZkStateReader();
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish(collectionName, zkStateReader, true, true, 330);
|
||||
|
@ -208,17 +209,11 @@ public class TestAuthenticationFramework extends LuceneTestCase {
|
|||
assertEquals(1, rsp.getResults().getNumFound());
|
||||
|
||||
// delete the collection we created earlier
|
||||
miniCluster.deleteCollection(collectionName);
|
||||
AbstractDistribZkTestBase.waitForCollectionToDisappear(collectionName, zkStateReader, true, true, 330);
|
||||
CollectionAdminRequest.deleteCollection(collectionName).process(miniCluster.getSolrClient());
|
||||
|
||||
// create it again
|
||||
String asyncId2 = (random().nextBoolean() ? null : "asyncId("+collectionName+".create)="+random().nextInt());
|
||||
createCollection(miniCluster, collectionName, asyncId2);
|
||||
if (asyncId2 != null) {
|
||||
final RequestStatusState state = AbstractFullDistribZkTestBase.getRequestStateAfterCompletion(asyncId2, 330,
|
||||
cloudSolrClient);
|
||||
assertSame("did not see async createCollection completion", RequestStatusState.COMPLETED, state);
|
||||
}
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish(collectionName, zkStateReader, true, true, 330);
|
||||
|
||||
// check that there's no left-over state
|
||||
|
|
|
@ -24,28 +24,26 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.client.solrj.response.UpdateResponse;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.SolrInputField;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.cloud.ClusterState;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
import org.apache.solr.common.cloud.Slice;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -97,9 +95,10 @@ public class TestCloudDeleteByQuery extends SolrCloudTestCase {
|
|||
collectionProperties.put("config", "solrconfig-tlog.xml");
|
||||
collectionProperties.put("schema", "schema15.xml"); // string id for doc routing prefix
|
||||
|
||||
assertNotNull(cluster.createCollection(COLLECTION_NAME, NUM_SHARDS, REPLICATION_FACTOR,
|
||||
configName, null, null, collectionProperties));
|
||||
|
||||
CollectionAdminRequest.createCollection(COLLECTION_NAME, configName, NUM_SHARDS, REPLICATION_FACTOR)
|
||||
.setProperties(collectionProperties)
|
||||
.process(cluster.getSolrClient());
|
||||
|
||||
CLOUD_CLIENT = cluster.getSolrClient();
|
||||
CLOUD_CLIENT.setDefaultCollection(COLLECTION_NAME);
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
package org.apache.solr.cloud;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
|
@ -28,28 +27,22 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.schema.SchemaRequest.Field;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse;
|
||||
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
|
||||
import org.apache.solr.search.TestPseudoReturnFields;
|
||||
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
@ -85,10 +78,10 @@ public class TestCloudPseudoReturnFields extends SolrCloudTestCase {
|
|||
Map<String, String> collectionProperties = new HashMap<>();
|
||||
collectionProperties.put("config", "solrconfig-tlog.xml");
|
||||
collectionProperties.put("schema", "schema-psuedo-fields.xml");
|
||||
CollectionAdminRequest.createCollection(COLLECTION_NAME, configName, numShards, repFactor)
|
||||
.setProperties(collectionProperties)
|
||||
.process(cluster.getSolrClient());
|
||||
|
||||
assertNotNull(cluster.createCollection(COLLECTION_NAME, numShards, repFactor,
|
||||
configName, null, null, collectionProperties));
|
||||
|
||||
CLOUD_CLIENT = cluster.getSolrClient();
|
||||
CLOUD_CLIENT.setDefaultCollection(COLLECTION_NAME);
|
||||
|
||||
|
|
|
@ -80,8 +80,7 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
|
|||
public void testCreateErrors() throws Exception {
|
||||
final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString();
|
||||
final SolrClient solrClient = getHttpSolrClient(baseUrl);
|
||||
final File configDir = getFile("solr").toPath().resolve("configsets/configset-2/conf").toFile();
|
||||
solrCluster.uploadConfigDir(configDir, "configSet");
|
||||
solrCluster.uploadConfigSet(configset("configset-2"), "configSet");
|
||||
|
||||
// no action
|
||||
CreateNoErrorChecking createNoAction = new CreateNoErrorChecking();
|
||||
|
@ -137,7 +136,7 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
|
|||
FileUtils.write(new File(tmpConfigDir, ConfigSetProperties.DEFAULT_FILENAME),
|
||||
getConfigSetProps(oldProps), StandardCharsets.UTF_8);
|
||||
}
|
||||
solrCluster.uploadConfigDir(tmpConfigDir, baseConfigSetName);
|
||||
solrCluster.uploadConfigSet(tmpConfigDir.toPath(), baseConfigSetName);
|
||||
}
|
||||
|
||||
private void verifyCreate(String baseConfigSetName, String configSetName,
|
||||
|
@ -243,7 +242,7 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
|
|||
FileUtils.copyDirectory(configDir, tmpConfigDir);
|
||||
FileUtils.write(new File(tmpConfigDir, "configsetprops.json"),
|
||||
getConfigSetProps(ImmutableMap.<String, String>of("immutable", "true")), StandardCharsets.UTF_8);
|
||||
solrCluster.uploadConfigDir(tmpConfigDir, "configSet");
|
||||
solrCluster.uploadConfigSet(tmpConfigDir.toPath(), "configSet");
|
||||
|
||||
// no ConfigSet name
|
||||
DeleteNoErrorChecking delete = new DeleteNoErrorChecking();
|
||||
|
@ -275,9 +274,8 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
|
|||
public void testDelete() throws Exception {
|
||||
final String baseUrl = solrCluster.getJettySolrRunners().get(0).getBaseUrl().toString();
|
||||
final SolrClient solrClient = getHttpSolrClient(baseUrl);
|
||||
final File configDir = getFile("solr").toPath().resolve("configsets/configset-2/conf").toFile();
|
||||
final String configSet = "configSet";
|
||||
solrCluster.uploadConfigDir(configDir, configSet);
|
||||
solrCluster.uploadConfigSet(configset("configset-2"), configSet);
|
||||
|
||||
SolrZkClient zkClient = new SolrZkClient(solrCluster.getZkServer().getZkAddress(),
|
||||
AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null);
|
||||
|
@ -312,11 +310,10 @@ public class TestConfigSetsAPI extends SolrTestCaseJ4 {
|
|||
assertEquals(0, actualConfigSets.size());
|
||||
|
||||
// test multiple
|
||||
final File configDir = getFile("solr").toPath().resolve("configsets/configset-2/conf").toFile();
|
||||
Set<String> configSets = new HashSet<String>();
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
String configSet = "configSet" + i;
|
||||
solrCluster.uploadConfigDir(configDir, configSet);
|
||||
solrCluster.uploadConfigSet(configset("configset-2"), configSet);
|
||||
configSets.add(configSet);
|
||||
}
|
||||
response = list.process(solrClient);
|
||||
|
|
|
@ -16,23 +16,19 @@
|
|||
*/
|
||||
package org.apache.solr.cloud;
|
||||
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Create;
|
||||
import org.apache.solr.client.solrj.request.ConfigSetAdminRequest.Delete;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -92,11 +88,7 @@ public class TestConfigSetsAPIExclusivity extends SolrTestCaseJ4 {
|
|||
}
|
||||
|
||||
private void setupBaseConfigSet(String baseConfigSetName) throws Exception {
|
||||
final File configDir = getFile("solr").toPath().resolve("configsets/configset-2/conf").toFile();
|
||||
final File tmpConfigDir = createTempDir().toFile();
|
||||
tmpConfigDir.deleteOnExit();
|
||||
FileUtils.copyDirectory(configDir, tmpConfigDir);
|
||||
solrCluster.uploadConfigDir(tmpConfigDir, baseConfigSetName);
|
||||
solrCluster.uploadConfigSet(configset("configset-2"), baseConfigSetName);
|
||||
}
|
||||
|
||||
private Exception getFirstExceptionOrNull(List<Exception> list) {
|
||||
|
|
|
@ -136,7 +136,7 @@ public class TestConfigSetsAPIZkFailure extends SolrTestCaseJ4 {
|
|||
FileUtils.write(new File(tmpConfigDir, ConfigSetProperties.DEFAULT_FILENAME),
|
||||
getConfigSetProps(oldProps), StandardCharsets.UTF_8);
|
||||
}
|
||||
solrCluster.uploadConfigDir(tmpConfigDir, baseConfigSetName);
|
||||
solrCluster.uploadConfigSet(tmpConfigDir.toPath(), baseConfigSetName);
|
||||
}
|
||||
|
||||
private StringBuilder getConfigSetProps(Map<String, String> map) {
|
||||
|
|
|
@ -37,8 +37,8 @@ import org.apache.solr.client.solrj.embedded.JettyConfig;
|
|||
import org.apache.solr.client.solrj.embedded.JettyConfig.Builder;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.client.solrj.response.RequestStatusState;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.cloud.ClusterState;
|
||||
import org.apache.solr.common.cloud.Replica;
|
||||
|
@ -93,8 +93,7 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
|
|||
private void createCollection(MiniSolrCloudCluster miniCluster, String collectionName, String createNodeSet, String asyncId,
|
||||
Boolean indexToPersist, Map<String,String> collectionProperties) throws Exception {
|
||||
String configName = "solrCloudCollectionConfig";
|
||||
File configDir = new File(SolrTestCaseJ4.TEST_HOME() + File.separator + "collection1" + File.separator + "conf");
|
||||
miniCluster.uploadConfigDir(configDir, configName);
|
||||
miniCluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1").resolve("conf"), configName);
|
||||
|
||||
final boolean persistIndex = (indexToPersist != null ? indexToPersist.booleanValue() : random().nextBoolean());
|
||||
if (collectionProperties == null) {
|
||||
|
@ -115,8 +114,19 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
|
|||
}
|
||||
collectionProperties.putIfAbsent("solr.tests.mergeScheduler", "org.apache.lucene.index.ConcurrentMergeScheduler");
|
||||
collectionProperties.putIfAbsent("solr.directoryFactory", (persistIndex ? "solr.StandardDirectoryFactory" : "solr.RAMDirectoryFactory"));
|
||||
|
||||
miniCluster.createCollection(collectionName, NUM_SHARDS, REPLICATION_FACTOR, configName, createNodeSet, asyncId, collectionProperties);
|
||||
|
||||
if (asyncId == null) {
|
||||
CollectionAdminRequest.createCollection(collectionName, configName, NUM_SHARDS, REPLICATION_FACTOR)
|
||||
.setCreateNodeSet(createNodeSet)
|
||||
.setProperties(collectionProperties)
|
||||
.process(miniCluster.getSolrClient());
|
||||
}
|
||||
else {
|
||||
CollectionAdminRequest.createCollection(collectionName, configName, NUM_SHARDS, REPLICATION_FACTOR)
|
||||
.setCreateNodeSet(createNodeSet)
|
||||
.setProperties(collectionProperties)
|
||||
.processAndWait(miniCluster.getSolrClient(), 30);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -151,11 +161,6 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
|
|||
log.info("#### Creating a collection");
|
||||
final String asyncId = (random().nextBoolean() ? null : "asyncId("+collectionName+".create)="+random().nextInt());
|
||||
createCollection(miniCluster, collectionName, null, asyncId, null, null);
|
||||
if (asyncId != null) {
|
||||
final RequestStatusState state = AbstractFullDistribZkTestBase.getRequestStateAfterCompletion(asyncId, 330,
|
||||
cloudSolrClient);
|
||||
assertSame("did not see async createCollection completion", RequestStatusState.COMPLETED, state);
|
||||
}
|
||||
|
||||
ZkStateReader zkStateReader = miniCluster.getSolrClient().getZkStateReader();
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish(collectionName, zkStateReader, true, true, 330);
|
||||
|
@ -205,19 +210,11 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
|
|||
assertTrue(startedServer.isRunning());
|
||||
assertEquals(NUM_SERVERS, miniCluster.getJettySolrRunners().size());
|
||||
|
||||
|
||||
// delete the collection we created earlier
|
||||
miniCluster.deleteCollection(collectionName);
|
||||
AbstractDistribZkTestBase.waitForCollectionToDisappear(collectionName, zkStateReader, true, true, 330);
|
||||
CollectionAdminRequest.deleteCollection(collectionName).process(miniCluster.getSolrClient());
|
||||
|
||||
// create it again
|
||||
String asyncId2 = (random().nextBoolean() ? null : "asyncId("+collectionName+".create)="+random().nextInt());
|
||||
createCollection(miniCluster, collectionName, null, asyncId2, null, null);
|
||||
if (asyncId2 != null) {
|
||||
final RequestStatusState state = AbstractFullDistribZkTestBase.getRequestStateAfterCompletion(asyncId2, 330,
|
||||
cloudSolrClient);
|
||||
assertSame("did not see async createCollection completion", RequestStatusState.COMPLETED, state);
|
||||
}
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish(collectionName, zkStateReader, true, true, 330);
|
||||
|
||||
// check that there's no left-over state
|
||||
|
@ -246,10 +243,6 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
|
|||
// create collection
|
||||
final String asyncId = (random().nextBoolean() ? null : "asyncId("+collectionName+".create)="+random().nextInt());
|
||||
createCollection(miniCluster, collectionName, OverseerCollectionMessageHandler.CREATE_NODE_SET_EMPTY, asyncId, null, null);
|
||||
if (asyncId != null) {
|
||||
final RequestStatusState state = AbstractFullDistribZkTestBase.getRequestStateAfterCompletion(asyncId, 330, cloudSolrClient);
|
||||
assertSame("did not see async createCollection completion", RequestStatusState.COMPLETED, state);
|
||||
}
|
||||
|
||||
try (SolrZkClient zkClient = new SolrZkClient
|
||||
(miniCluster.getZkServer().getZkAddress(), AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null);
|
||||
|
@ -267,10 +260,7 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
|
|||
}
|
||||
assertEquals(0, coreCount);
|
||||
}
|
||||
|
||||
// delete the collection we created earlier
|
||||
miniCluster.deleteCollection(collectionName);
|
||||
AbstractDistribZkTestBase.waitForCollectionToDisappear(collectionName, zkStateReader, true, true, 330);
|
||||
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
@ -387,9 +377,6 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
|
|||
assertEquals(numDocs, rsp.getResults().getNumFound());
|
||||
}
|
||||
|
||||
// delete the collection we created earlier
|
||||
miniCluster.deleteCollection(collectionName);
|
||||
AbstractDistribZkTestBase.waitForCollectionToDisappear(collectionName, zkStateReader, true, true, 330);
|
||||
}
|
||||
}
|
||||
finally {
|
||||
|
@ -418,10 +405,6 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
|
|||
final Map<String, String> collectionProperties = new HashMap<>();
|
||||
collectionProperties.put(CoreDescriptor.CORE_CONFIG, "solrconfig-sortingmergepolicyfactory.xml");
|
||||
createCollection(miniCluster, collectionName, null, asyncId, Boolean.TRUE, collectionProperties);
|
||||
if (asyncId != null) {
|
||||
final RequestStatusState state = AbstractFullDistribZkTestBase.getRequestStateAfterCompletion(asyncId, 330, cloudSolrClient);
|
||||
assertSame("did not see async createCollection completion", RequestStatusState.COMPLETED, state);
|
||||
}
|
||||
}
|
||||
|
||||
ZkStateReader zkStateReader = cloudSolrClient.getZkStateReader();
|
||||
|
@ -444,9 +427,6 @@ public class TestMiniSolrCloudCluster extends LuceneTestCase {
|
|||
tstes.queryTimestampDescendingSegmentTerminateEarlyYesGrouped(cloudSolrClient);
|
||||
tstes.queryTimestampAscendingSegmentTerminateEarlyYes(cloudSolrClient); // uses a sort order that is _not_ compatible with the merge sort order
|
||||
|
||||
// delete the collection we created earlier
|
||||
miniCluster.deleteCollection(collectionName);
|
||||
AbstractDistribZkTestBase.waitForCollectionToDisappear(collectionName, zkStateReader, true, true, 330);
|
||||
}
|
||||
finally {
|
||||
miniCluster.shutdown();
|
||||
|
|
|
@ -17,10 +17,8 @@
|
|||
package org.apache.solr.cloud;
|
||||
|
||||
import javax.net.ssl.SSLContext;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.http.client.HttpClient;
|
||||
|
@ -40,6 +38,7 @@ import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
|||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpClientUtil;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.CoreAdminRequest;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.params.CoreAdminParams.CoreAdminAction;
|
||||
|
@ -167,9 +166,7 @@ public class TestMiniSolrCloudClusterSSL extends SolrTestCaseJ4 {
|
|||
public static void checkClusterWithCollectionCreations(final MiniSolrCloudCluster cluster,
|
||||
final SSLTestConfig sslConfig) throws Exception {
|
||||
|
||||
cluster.uploadConfigDir(new File(SolrTestCaseJ4.TEST_HOME() + File.separator +
|
||||
"collection1" + File.separator + "conf"),
|
||||
CONF_NAME);
|
||||
cluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1").resolve("conf"), CONF_NAME);
|
||||
|
||||
checkCreateCollection(cluster, "first_collection");
|
||||
|
||||
|
@ -196,11 +193,10 @@ public class TestMiniSolrCloudClusterSSL extends SolrTestCaseJ4 {
|
|||
*/
|
||||
private static void checkCreateCollection(final MiniSolrCloudCluster cluster,
|
||||
final String collection) throws Exception {
|
||||
assertNotNull(cluster.createCollection(collection,
|
||||
/* 1 shard/replica per server */ NUM_SERVERS, 1,
|
||||
CONF_NAME, null, null,
|
||||
Collections.singletonMap("config","solrconfig-tlog.xml")));
|
||||
final CloudSolrClient cloudClient = cluster.getSolrClient();
|
||||
CollectionAdminRequest.createCollection(collection, CONF_NAME, NUM_SERVERS, 1)
|
||||
.withProperty("config", "solrconfig-tlog.xml")
|
||||
.process(cloudClient);
|
||||
ZkStateReader zkStateReader = cloudClient.getZkStateReader();
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish(collection, zkStateReader, true, true, 330);
|
||||
assertEquals("sanity query", 0, cloudClient.query(collection, params("q","*:*")).getStatus());
|
||||
|
|
|
@ -16,9 +16,8 @@
|
|||
*/
|
||||
package org.apache.solr.cloud;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
|
@ -33,36 +32,29 @@ import java.util.Random;
|
|||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.response.transform.DocTransformer; // jdoc
|
||||
import org.apache.solr.response.transform.RawValueTransformerFactory; // jdoc
|
||||
import org.apache.solr.response.transform.DocTransformer;
|
||||
import org.apache.solr.response.transform.RawValueTransformerFactory;
|
||||
import org.apache.solr.response.transform.TransformerFactory;
|
||||
|
||||
|
||||
import org.apache.solr.util.RandomizeSSL;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/** @see TestCloudPseudoReturnFields */
|
||||
@RandomizeSSL(clientAuth=0.0,reason="client auth uses too much RAM")
|
||||
|
@ -125,7 +117,7 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
|
|||
new NotIncludedValidator("score","score_alias:score")));
|
||||
|
||||
@BeforeClass
|
||||
private static void createMiniSolrCloudCluster() throws Exception {
|
||||
public static void createMiniSolrCloudCluster() throws Exception {
|
||||
|
||||
// 50% runs use single node/shard a FL_VALIDATORS with all validators known to work on single node
|
||||
// 50% runs use multi node/shard with FL_VALIDATORS only containing stuff that works in cloud
|
||||
|
@ -142,17 +134,15 @@ public class TestRandomFlRTGCloud extends SolrCloudTestCase {
|
|||
final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
|
||||
|
||||
configureCluster(numNodes).addConfig(configName, configDir).configure();
|
||||
|
||||
Map<String, String> collectionProperties = new HashMap<>();
|
||||
collectionProperties.put("config", "solrconfig-tlog.xml");
|
||||
collectionProperties.put("schema", "schema-psuedo-fields.xml");
|
||||
|
||||
assertNotNull(cluster.createCollection(COLLECTION_NAME, numShards, repFactor,
|
||||
configName, null, null, collectionProperties));
|
||||
|
||||
CLOUD_CLIENT = cluster.getSolrClient();
|
||||
CLOUD_CLIENT.setDefaultCollection(COLLECTION_NAME);
|
||||
|
||||
CollectionAdminRequest.createCollection(COLLECTION_NAME, configName, numShards, repFactor)
|
||||
.withProperty("config", "solrconfig-tlog.xml")
|
||||
.withProperty("schema", "schema-psuedo-fields.xml")
|
||||
.process(CLOUD_CLIENT);
|
||||
|
||||
waitForRecoveriesToFinish(CLOUD_CLIENT);
|
||||
|
||||
for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.solr.cloud;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URL;
|
||||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
|
@ -38,8 +37,7 @@ public class TestRequestForwarding extends SolrTestCaseJ4 {
|
|||
System.setProperty("solr.test.sys.prop1", "propone");
|
||||
System.setProperty("solr.test.sys.prop2", "proptwo");
|
||||
solrCluster = new MiniSolrCloudCluster(3, createTempDir(), buildJettyConfig("/solr"));
|
||||
File configDir = getFile("solr").toPath().resolve("collection1/conf").toFile();
|
||||
solrCluster.uploadConfigDir(configDir, "conf1");
|
||||
solrCluster.uploadConfigSet(TEST_PATH().resolve("collection1/conf"), "conf1");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -176,8 +176,7 @@ public class TestSolrCloudWithKerberosAlt extends LuceneTestCase {
|
|||
|
||||
// create collection
|
||||
String configName = "solrCloudCollectionConfig";
|
||||
File configDir = new File(SolrTestCaseJ4.TEST_HOME() + File.separator + "collection1" + File.separator + "conf");
|
||||
miniCluster.uploadConfigDir(configDir, configName);
|
||||
miniCluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1/conf"), configName);
|
||||
|
||||
CollectionAdminRequest.Create createRequest = new CollectionAdminRequest.Create();
|
||||
createRequest.setCollectionName(collectionName);
|
||||
|
|
|
@ -19,29 +19,30 @@ package org.apache.solr.cloud;
|
|||
import java.lang.invoke.MethodHandles;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.client.solrj.response.UpdateResponse;
|
||||
import org.apache.solr.client.solrj.request.schema.SchemaRequest.Field;
|
||||
import org.apache.solr.client.solrj.request.schema.SchemaRequest.FieldType;
|
||||
import org.apache.solr.client.solrj.response.UpdateResponse;
|
||||
import org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldResponse;
|
||||
import org.apache.solr.client.solrj.response.schema.SchemaResponse.FieldTypeResponse;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
|
@ -52,13 +53,9 @@ import org.apache.solr.common.params.SolrParams;
|
|||
import org.apache.solr.common.util.ExecutorUtil;
|
||||
import org.apache.solr.util.DefaultSolrThreadFactory;
|
||||
import org.apache.solr.util.TestInjection;
|
||||
import org.apache.lucene.util.LuceneTestCase.Slow;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -125,17 +122,15 @@ public class TestStressCloudBlindAtomicUpdates extends SolrCloudTestCase {
|
|||
final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
|
||||
|
||||
configureCluster(numNodes).addConfig(configName, configDir).configure();
|
||||
|
||||
Map<String, String> collectionProperties = new HashMap<>();
|
||||
collectionProperties.put("config", "solrconfig-tlog.xml");
|
||||
collectionProperties.put("schema", "schema-minimal-atomic-stress.xml");
|
||||
|
||||
assertNotNull(cluster.createCollection(COLLECTION_NAME, numShards, repFactor,
|
||||
configName, null, null, collectionProperties));
|
||||
|
||||
CLOUD_CLIENT = cluster.getSolrClient();
|
||||
CLOUD_CLIENT.setDefaultCollection(COLLECTION_NAME);
|
||||
|
||||
CollectionAdminRequest.createCollection(COLLECTION_NAME, configName, numShards, repFactor)
|
||||
.withProperty("config", "solrconfig-tlog.xml")
|
||||
.withProperty("schema", "schema-minimal-atomic-stress.xml")
|
||||
.process(CLOUD_CLIENT);
|
||||
|
||||
waitForRecoveriesToFinish(CLOUD_CLIENT);
|
||||
|
||||
for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
|
||||
|
|
|
@ -24,21 +24,20 @@ import java.util.Arrays;
|
|||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.client.solrj.response.UpdateResponse;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.SolrInputField;
|
||||
import org.apache.solr.common.SolrException;
|
||||
import org.apache.solr.common.ToleratedUpdateError;
|
||||
import org.apache.solr.common.ToleratedUpdateError.CmdType;
|
||||
import org.apache.solr.common.cloud.ClusterState;
|
||||
|
@ -49,10 +48,8 @@ import org.apache.solr.common.params.ModifiableSolrParams;
|
|||
import org.apache.solr.common.params.SolrParams;
|
||||
import org.apache.solr.common.util.NamedList;
|
||||
import org.apache.solr.common.util.SimpleOrderedMap;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -103,7 +100,7 @@ public class TestTolerantUpdateProcessorCloud extends SolrCloudTestCase {
|
|||
private static final String S_TWO_PRE = "XYZ!";
|
||||
|
||||
@BeforeClass
|
||||
private static void createMiniSolrCloudCluster() throws Exception {
|
||||
public static void createMiniSolrCloudCluster() throws Exception {
|
||||
|
||||
final String configName = "solrCloudCollectionConfig";
|
||||
final File configDir = new File(TEST_HOME() + File.separator + "collection1" + File.separator + "conf");
|
||||
|
@ -112,16 +109,14 @@ public class TestTolerantUpdateProcessorCloud extends SolrCloudTestCase {
|
|||
.addConfig(configName, configDir.toPath())
|
||||
.configure();
|
||||
assertSpinLoopAllJettyAreRunning(cluster);
|
||||
|
||||
Map<String, String> collectionProperties = new HashMap<>();
|
||||
collectionProperties.put("config", "solrconfig-distrib-update-processor-chains.xml");
|
||||
collectionProperties.put("schema", "schema15.xml"); // string id for doc routing prefix
|
||||
|
||||
assertNotNull(cluster.createCollection(COLLECTION_NAME, NUM_SHARDS, REPLICATION_FACTOR,
|
||||
configName, null, null, collectionProperties));
|
||||
|
||||
CLOUD_CLIENT = cluster.getSolrClient();
|
||||
CLOUD_CLIENT.setDefaultCollection(COLLECTION_NAME);
|
||||
|
||||
CollectionAdminRequest.createCollection(COLLECTION_NAME, configName, NUM_SHARDS, REPLICATION_FACTOR)
|
||||
.withProperty("config", "solrconfig-distrib-update-processor-chains.xml")
|
||||
.withProperty("schema", "schema15.xml") // string id for doc routing prefix
|
||||
.process(CLOUD_CLIENT);
|
||||
|
||||
ZkStateReader zkStateReader = CLOUD_CLIENT.getZkStateReader();
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish(COLLECTION_NAME, zkStateReader, true, true, 330);
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
*/
|
||||
package org.apache.solr.cloud;
|
||||
|
||||
import javax.ws.rs.HEAD;
|
||||
import java.io.File;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.net.URL;
|
||||
|
@ -28,34 +29,34 @@ import java.util.Random;
|
|||
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.assertUpdateTolerantErrors;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.addErr;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.delIErr;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.delQErr;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.f;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.update;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.ExpectedErr;
|
||||
import org.apache.solr.client.solrj.SolrClient;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.impl.HttpSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.UpdateRequest;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.client.solrj.response.UpdateResponse;
|
||||
import static org.apache.solr.common.params.CursorMarkParams.CURSOR_MARK_PARAM;
|
||||
import static org.apache.solr.common.params.CursorMarkParams.CURSOR_MARK_START;
|
||||
import org.apache.solr.common.SolrDocument;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.SolrInputField;
|
||||
import org.apache.solr.common.cloud.ZkStateReader;
|
||||
import org.apache.solr.common.params.SolrParams;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.ExpectedErr;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.addErr;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.assertUpdateTolerantErrors;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.delIErr;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.delQErr;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.f;
|
||||
import static org.apache.solr.cloud.TestTolerantUpdateProcessorCloud.update;
|
||||
import static org.apache.solr.common.params.CursorMarkParams.CURSOR_MARK_PARAM;
|
||||
import static org.apache.solr.common.params.CursorMarkParams.CURSOR_MARK_START;
|
||||
|
||||
/**
|
||||
* Test of TolerantUpdateProcessor using a randomized MiniSolrCloud.
|
||||
* Reuses some utility methods in {@link TestTolerantUpdateProcessorCloud}
|
||||
|
@ -77,10 +78,10 @@ public class TestTolerantUpdateProcessorRandomCloud extends SolrCloudTestCase {
|
|||
/** A basic client for operations at the cloud level, default collection will be set */
|
||||
private static CloudSolrClient CLOUD_CLIENT;
|
||||
/** one HttpSolrClient for each server */
|
||||
private static List<SolrClient> NODE_CLIENTS;
|
||||
private static List<HttpSolrClient> NODE_CLIENTS;
|
||||
|
||||
@BeforeClass
|
||||
private static void createMiniSolrCloudCluster() throws Exception {
|
||||
public static void createMiniSolrCloudCluster() throws Exception {
|
||||
|
||||
final String configName = "solrCloudCollectionConfig";
|
||||
final File configDir = new File(TEST_HOME() + File.separator + "collection1" + File.separator + "conf");
|
||||
|
@ -101,15 +102,20 @@ public class TestTolerantUpdateProcessorRandomCloud extends SolrCloudTestCase {
|
|||
collectionProperties.put("config", "solrconfig-distrib-update-processor-chains.xml");
|
||||
collectionProperties.put("schema", "schema15.xml"); // string id
|
||||
|
||||
|
||||
assertNotNull(cluster.createCollection(COLLECTION_NAME, numShards, repFactor,
|
||||
configName, null, null, collectionProperties));
|
||||
|
||||
CLOUD_CLIENT = cluster.getSolrClient();
|
||||
CLOUD_CLIENT.setDefaultCollection(COLLECTION_NAME);
|
||||
|
||||
NODE_CLIENTS = new ArrayList<SolrClient>(numServers);
|
||||
|
||||
CollectionAdminRequest.createCollection(COLLECTION_NAME, configName, numShards, repFactor)
|
||||
.setProperties(collectionProperties)
|
||||
.process(CLOUD_CLIENT);
|
||||
|
||||
if (NODE_CLIENTS != null) {
|
||||
for (HttpSolrClient client : NODE_CLIENTS) {
|
||||
client.close();
|
||||
}
|
||||
}
|
||||
NODE_CLIENTS = new ArrayList<HttpSolrClient>(numServers);
|
||||
|
||||
for (JettySolrRunner jetty : cluster.getJettySolrRunners()) {
|
||||
URL jettyURL = jetty.getBaseUrl();
|
||||
NODE_CLIENTS.add(getHttpSolrClient(jettyURL.toString() + "/" + COLLECTION_NAME + "/"));
|
||||
|
|
|
@ -25,6 +25,7 @@ import java.util.HashMap;
|
|||
import org.apache.solr.client.solrj.SolrQuery;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import org.apache.solr.common.SolrDocumentList;
|
||||
|
@ -45,14 +46,17 @@ public class BlobRepositoryCloudTest extends SolrCloudTestCase {
|
|||
.configure();
|
||||
// Thread.sleep(2000);
|
||||
HashMap<String, String> params = new HashMap<>();
|
||||
cluster.createCollection(".system", 1, 1, null, params);
|
||||
CollectionAdminRequest.createCollection(".system", null, 1, 1)
|
||||
.process(cluster.getSolrClient());
|
||||
// test component will fail if it cant' find a blob with this data by this name
|
||||
TestBlobHandler.postData(cluster.getSolrClient(), findLiveNodeURI(), "testResource", ByteBuffer.wrap("foo,bar\nbaz,bam".getBytes(StandardCharsets.UTF_8)));
|
||||
// Thread.sleep(2000);
|
||||
// if these don't load we probably failed to post the blob above
|
||||
cluster.createCollection("col1", 1, 1, "configname", params);
|
||||
cluster.createCollection("col2", 1, 1, "configname", params);
|
||||
// Thread.sleep(2000);
|
||||
CollectionAdminRequest.createCollection("col1", "configname", 1, 1)
|
||||
.process(cluster.getSolrClient());
|
||||
CollectionAdminRequest.createCollection("col2", "configname", 1, 1)
|
||||
.process(cluster.getSolrClient());
|
||||
|
||||
SolrInputDocument document = new SolrInputDocument();
|
||||
document.addField("id", "1");
|
||||
document.addField("text", "col1");
|
||||
|
|
|
@ -24,6 +24,7 @@ import org.apache.commons.io.FileUtils;
|
|||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.SolrPing;
|
||||
import org.apache.solr.client.solrj.response.SolrPingResponse;
|
||||
import org.apache.solr.cloud.MiniSolrCloudCluster;
|
||||
|
@ -189,10 +190,10 @@ public class PingRequestHandlerTest extends SolrTestCaseJ4 {
|
|||
// create collection
|
||||
String collectionName = "testSolrCloudCollection";
|
||||
String configName = "solrCloudCollectionConfig";
|
||||
File configDir = new File(SolrTestCaseJ4.TEST_HOME() + File.separator + "collection1" + File.separator + "conf");
|
||||
miniCluster.uploadConfigDir(configDir, configName);
|
||||
miniCluster.createCollection(collectionName, NUM_SHARDS, REPLICATION_FACTOR, configName, null);
|
||||
|
||||
miniCluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1").resolve("conf"), configName);
|
||||
CollectionAdminRequest.createCollection(collectionName, configName, NUM_SHARDS, REPLICATION_FACTOR)
|
||||
.process(miniCluster.getSolrClient());
|
||||
|
||||
// Send distributed and non-distributed ping query
|
||||
SolrPingWithDistrib reqDistrib = new SolrPingWithDistrib();
|
||||
reqDistrib.setDistrib(true);
|
||||
|
@ -206,9 +207,6 @@ public class PingRequestHandlerTest extends SolrTestCaseJ4 {
|
|||
assertEquals(0, rsp.getStatus());
|
||||
assertTrue(rsp.getResponseHeader().getBooleanArg(("zkConnected")));
|
||||
|
||||
// delete the collection we created earlier
|
||||
miniCluster.deleteCollection(collectionName);
|
||||
|
||||
}
|
||||
finally {
|
||||
miniCluster.shutdown();
|
||||
|
|
|
@ -24,6 +24,7 @@ import java.util.function.Predicate;
|
|||
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.cloud.AbstractFullDistribZkTestBase;
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import org.apache.solr.common.cloud.DocCollection;
|
||||
|
@ -57,7 +58,8 @@ public class TestReqParamsAPI extends SolrCloudTestCase {
|
|||
configureCluster(2)
|
||||
.addConfig("conf1", TEST_PATH().resolve("configsets").resolve("cloud-managed").resolve("conf"))
|
||||
.configure();
|
||||
cluster.createCollection(COLL_NAME, 1, 2, "conf1", null);
|
||||
CollectionAdminRequest.createCollection(COLL_NAME, "conf1", 1, 2)
|
||||
.process(cluster.getSolrClient());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -16,13 +16,13 @@
|
|||
*/
|
||||
package org.apache.solr.handler.component;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.solr.SolrTestCaseJ4;
|
||||
import org.apache.solr.client.solrj.embedded.JettySolrRunner;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.QueryRequest;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.cloud.MiniSolrCloudCluster;
|
||||
|
@ -122,19 +122,14 @@ public class SearchHandlerTest extends SolrTestCaseJ4
|
|||
// create collection
|
||||
String collectionName = "testSolrCloudCollection";
|
||||
String configName = "solrCloudCollectionConfig";
|
||||
File configDir = new File(SolrTestCaseJ4.TEST_HOME() + File.separator + "collection1" + File.separator + "conf");
|
||||
miniCluster.uploadConfigDir(configDir, configName);
|
||||
miniCluster.createCollection(collectionName, 2, 2, configName, null);
|
||||
|
||||
|
||||
miniCluster.uploadConfigSet(SolrTestCaseJ4.TEST_PATH().resolve("collection1/conf"), configName);
|
||||
|
||||
CollectionAdminRequest.createCollection(collectionName, configName, 2, 2)
|
||||
.process(miniCluster.getSolrClient());
|
||||
|
||||
QueryRequest req = new QueryRequest();
|
||||
QueryResponse rsp = req.process(cloudSolrClient, collectionName);
|
||||
assertTrue(rsp.getResponseHeader().getBooleanArg("zkConnected"));
|
||||
|
||||
|
||||
// delete the collection we created earlier
|
||||
miniCluster.deleteCollection(collectionName);
|
||||
|
||||
}
|
||||
finally {
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.Random;
|
|||
import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.impl.CloudSolrClient;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.request.ContentStreamUpdateRequest;
|
||||
import org.apache.solr.client.solrj.request.QueryRequest;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
|
@ -64,13 +65,16 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
|
|||
|
||||
int shards = 2;
|
||||
int replicas = 2 ;
|
||||
assertNotNull(cluster.createCollection(people, shards, replicas,
|
||||
configName,
|
||||
collectionProperties));
|
||||
|
||||
assertNotNull(cluster.createCollection(depts, shards, replicas,
|
||||
configName, collectionProperties));
|
||||
|
||||
CollectionAdminRequest.createCollection(people, configName, shards, replicas)
|
||||
.withProperty("config", "solrconfig-doctransformers.xml")
|
||||
.withProperty("schema", "schema-docValuesJoin.xml")
|
||||
.process(cluster.getSolrClient());
|
||||
|
||||
CollectionAdminRequest.createCollection(depts, configName, shards, replicas)
|
||||
.withProperty("config", "solrconfig-doctransformers.xml")
|
||||
.withProperty("schema", "schema-docValuesJoin.xml")
|
||||
.process(cluster.getSolrClient());
|
||||
|
||||
CloudSolrClient client = cluster.getSolrClient();
|
||||
client.setDefaultCollection(people);
|
||||
|
||||
|
|
|
@ -50,7 +50,8 @@ public class TestManagedSchemaAPI extends SolrCloudTestCase {
|
|||
@Test
|
||||
public void test() throws Exception {
|
||||
String collection = "testschemaapi";
|
||||
cluster.createCollection(collection, 1, 2, "conf1", null);
|
||||
CollectionAdminRequest.createCollection(collection, "conf1", 1, 2)
|
||||
.process(cluster.getSolrClient());
|
||||
testReloadAndAddSimple(collection);
|
||||
testAddFieldAndDocument(collection);
|
||||
}
|
||||
|
|
|
@ -30,10 +30,10 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
|
||||
import org.apache.solr.client.solrj.SolrServerException;
|
||||
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
|
||||
import org.apache.solr.client.solrj.response.FacetField;
|
||||
import org.apache.solr.client.solrj.response.FacetField.Count;
|
||||
import org.apache.solr.client.solrj.response.QueryResponse;
|
||||
import org.apache.solr.cloud.AbstractDistribZkTestBase;
|
||||
import org.apache.solr.cloud.SolrCloudTestCase;
|
||||
import org.apache.solr.common.SolrInputDocument;
|
||||
import org.apache.solr.common.params.ModifiableSolrParams;
|
||||
|
@ -64,13 +64,10 @@ public class BlockJoinFacetDistribTest extends SolrCloudTestCase{
|
|||
|
||||
int shards = 3;
|
||||
int replicas = 2 ;
|
||||
assertNotNull(cluster.createCollection(collection, shards, replicas,
|
||||
configName,
|
||||
collectionProperties));
|
||||
|
||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish(collection,
|
||||
cluster.getSolrClient().getZkStateReader(), false, true, 30);
|
||||
|
||||
CollectionAdminRequest.createCollection(collection, configName, shards, replicas)
|
||||
.setProperties(collectionProperties)
|
||||
.process(cluster.getSolrClient());
|
||||
|
||||
}
|
||||
|
||||
final static List<String> colors = Arrays.asList("red","blue","brown","white","black","yellow","cyan","magenta","blur",
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
package org.apache.solr.search.stats;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.lang.invoke.MethodHandles;
|
||||
|
||||
|
@ -59,10 +58,8 @@ public class TestDistribIDF extends SolrTestCaseJ4 {
|
|||
// set some system properties for use by tests
|
||||
System.setProperty("solr.test.sys.prop1", "propone");
|
||||
System.setProperty("solr.test.sys.prop2", "proptwo");
|
||||
File configDir = getFile("solr").toPath().resolve("collection1/conf").toFile();
|
||||
solrCluster.uploadConfigDir(configDir, "conf1");
|
||||
configDir = getFile("solr").toPath().resolve("configsets/configset-2/conf").toFile();
|
||||
solrCluster.uploadConfigDir(configDir, "conf2");
|
||||
solrCluster.uploadConfigSet(TEST_PATH().resolve("collection1/conf"), "conf1");
|
||||
solrCluster.uploadConfigSet(configset("configset-2"), "conf2");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -18,6 +18,7 @@ package org.apache.solr.client.solrj.request;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.Properties;
|
||||
import java.util.UUID;
|
||||
|
@ -460,6 +461,19 @@ public abstract class CollectionAdminRequest<T extends CollectionAdminResponse>
|
|||
return this;
|
||||
}
|
||||
|
||||
public Create setProperties(Map<String, String> properties) {
|
||||
this.properties = new Properties();
|
||||
this.properties.putAll(properties);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Create withProperty(String key, String value) {
|
||||
if (this.properties == null)
|
||||
this.properties = new Properties();
|
||||
this.properties.setProperty(key, value);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SolrParams getParams() {
|
||||
ModifiableSolrParams params = (ModifiableSolrParams) super.getParams();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
package org.apache.solr.common.cloud;
|
||||
|
||||
import java.lang.invoke.MethodHandles;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
@ -269,7 +268,8 @@ public class TestCollectionStateWatchers extends SolrCloudTestCase {
|
|||
|
||||
@Test
|
||||
public void testDeletionsTriggerWatches() throws Exception {
|
||||
cluster.createCollection("tobedeleted", 1, 1, "config", new HashMap<>());
|
||||
CollectionAdminRequest.createCollection("tobedeleted", "config", 1, 1)
|
||||
.process(cluster.getSolrClient());
|
||||
Future<Boolean> future = waitInBackground("tobedeleted", MAX_WAIT_TIMEOUT, TimeUnit.SECONDS, (l, c) -> c == null);
|
||||
|
||||
CollectionAdminRequest.deleteCollection("tobedeleted").process(cluster.getSolrClient());
|
||||
|
|
|
@ -393,12 +393,25 @@ public class MiniSolrCloudCluster {
|
|||
jetty.stop();
|
||||
return jetty;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #uploadConfigSet(Path, String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void uploadConfigDir(File configDir, String configName) throws IOException, KeeperException, InterruptedException {
|
||||
uploadConfigSet(configDir.toPath(), configName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Upload a config set
|
||||
* @param configDir a path to the config set to upload
|
||||
* @param configName the name to give the configset
|
||||
*/
|
||||
public void uploadConfigSet(Path configDir, String configName) throws IOException, KeeperException, InterruptedException {
|
||||
try(SolrZkClient zkClient = new SolrZkClient(zkServer.getZkAddress(),
|
||||
AbstractZkTestCase.TIMEOUT, AbstractZkTestCase.TIMEOUT, null)) {
|
||||
ZkConfigManager manager = new ZkConfigManager(zkClient);
|
||||
manager.uploadConfigDir(configDir.toPath(), configName);
|
||||
manager.uploadConfigDir(configDir, configName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,13 +423,21 @@ public class MiniSolrCloudCluster {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
public NamedList<Object> createCollection(String name, int numShards, int replicationFactor,
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link CollectionAdminRequest#createCollection(String, String, int, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
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);
|
||||
}
|
||||
|
||||
public NamedList<Object> createCollection(String name, int numShards, int replicationFactor,
|
||||
/**
|
||||
* @deprecated Use {@link CollectionAdminRequest#createCollection(String, String, int, int)}
|
||||
*/
|
||||
@Deprecated
|
||||
public NamedList<Object> createCollection(String name, int numShards, int replicationFactor,
|
||||
String configName, String createNodeSet, String asyncId, Map<String, String> collectionProperties) throws SolrServerException, IOException {
|
||||
final ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set(CoreAdminParams.ACTION, CollectionAction.CREATE.name());
|
||||
|
@ -439,6 +460,10 @@ public class MiniSolrCloudCluster {
|
|||
return makeCollectionsRequest(params);
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link CollectionAdminRequest#deleteCollection(String)}
|
||||
*/
|
||||
@Deprecated
|
||||
public NamedList<Object> deleteCollection(String name) throws SolrServerException, IOException {
|
||||
final ModifiableSolrParams params = new ModifiableSolrParams();
|
||||
params.set(CoreAdminParams.ACTION, CollectionAction.DELETE.name());
|
||||
|
|
Loading…
Reference in New Issue