+
-
-
-
-
- ${urlScheme:}
- ${socketTimeout:90000}
- ${connTimeout:15000}
-
-
+ ${shareSchema:false}
+ ${configSetBaseDir:configsets}
+ ${coreRootDirectory:.}
+
+
+ ${urlScheme:}
+ ${socketTimeout:90000}
+ ${connTimeout:15000}
+
+
+
+ 127.0.0.1
+ ${hostPort:8983}
+ ${hostContext:solr}
+ ${solr.zkclienttimeout:30000}
+ ${genericCoreNodeNames:true}
+ 0
+ ${distribUpdateConnTimeout:45000}
+ ${distribUpdateSoTimeout:340000}
+
diff --git a/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java b/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java
index 283dddc0894..42fea2ff59b 100644
--- a/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java
+++ b/solr/core/src/test/org/apache/solr/TestSolrCoreProperties.java
@@ -16,20 +16,21 @@
*/
package org.apache.solr;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-import java.util.Properties;
-
import org.apache.commons.io.FileUtils;
import org.apache.lucene.util.IOUtils;
+import org.apache.solr.client.solrj.embedded.JettySolrRunner;
import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.params.SolrParams;
import org.apache.solr.common.util.NamedList;
import org.junit.BeforeClass;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.OutputStreamWriter;
+import java.io.Writer;
import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.Properties;
/**
* Test for Loading core properties from a properties file
@@ -39,6 +40,8 @@ import java.nio.charset.StandardCharsets;
*/
public class TestSolrCoreProperties extends SolrJettyTestBase {
+ // TODO these properties files don't work with configsets
+
@BeforeClass
public static void beforeTest() throws Exception {
File homeDir = createTempDir().toFile();
@@ -68,7 +71,19 @@ public class TestSolrCoreProperties extends SolrJettyTestBase {
p.store(fos, null);
IOUtils.close(fos);
- createJetty(homeDir.getAbsolutePath(), null, null);
+ Files.createFile(collDir.toPath().resolve("core.properties"));
+
+ jetty = new JettySolrRunner(homeDir.getAbsolutePath(), "/solr", 0, null, null, true, null, sslConfig);
+
+ // this sets the property for jetty starting SolrDispatchFilter
+ if (System.getProperty("solr.data.dir") == null && System.getProperty("solr.hdfs.home") == null) {
+ jetty.setDataDir(createTempDir().toFile().getCanonicalPath());
+ }
+
+ jetty.start();
+ port = jetty.getLocalPort();
+
+ //createJetty(homeDir.getAbsolutePath(), null, null);
}
public void testSimple() throws Exception {
diff --git a/solr/core/src/test/org/apache/solr/TestTolerantSearch.java b/solr/core/src/test/org/apache/solr/TestTolerantSearch.java
index d6f781666fe..354df28c85b 100644
--- a/solr/core/src/test/org/apache/solr/TestTolerantSearch.java
+++ b/solr/core/src/test/org/apache/solr/TestTolerantSearch.java
@@ -1,12 +1,8 @@
package org.apache.solr;
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-
import org.apache.commons.io.FileUtils;
-import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrClient;
+import org.apache.solr.client.solrj.SolrQuery;
import org.apache.solr.client.solrj.SolrServerException;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CoreAdminRequest;
@@ -21,6 +17,10 @@ import org.apache.solr.response.SolrQueryResponse;
import org.junit.AfterClass;
import org.junit.BeforeClass;
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -60,7 +60,7 @@ public class TestTolerantSearch extends SolrJettyTestBase {
solrHome = createSolrHome();
createJetty(solrHome.getAbsolutePath(), null, null);
String url = jetty.getBaseUrl().toString();
- collection1 = new HttpSolrClient(url);
+ collection1 = new HttpSolrClient(url + "/collection1");
collection2 = new HttpSolrClient(url + "/collection2");
String urlCollection1 = jetty.getBaseUrl().toString() + "/" + "collection1";
@@ -69,9 +69,16 @@ public class TestTolerantSearch extends SolrJettyTestBase {
shard2 = urlCollection2.replaceAll("https?://", "");
//create second core
- CoreAdminRequest.Create req = new CoreAdminRequest.Create();
- req.setCoreName("collection2");
- collection1.request(req);
+ HttpSolrClient nodeClient = new HttpSolrClient(url);
+ try {
+ CoreAdminRequest.Create req = new CoreAdminRequest.Create();
+ req.setCoreName("collection2");
+ req.setConfigSet("collection1");
+ nodeClient.request(req);
+ }
+ finally {
+ nodeClient.shutdown();
+ }
SolrInputDocument doc = new SolrInputDocument();
doc.setField("id", "1");
diff --git a/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java b/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
index da26ae12db3..414e77f4bf6 100644
--- a/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/AliasIntegrationTest.java
@@ -41,6 +41,8 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
/**
* Test sync phase that occurs when Leader goes down and a new Leader is
@@ -48,6 +50,8 @@ import org.junit.BeforeClass;
*/
@Slow
public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {
+
+ private static final Logger logger = LoggerFactory.getLogger(AliasIntegrationTest.class);
@BeforeClass
public static void beforeSuperClass() throws Exception {
@@ -80,12 +84,14 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {
@Override
public void doTest() throws Exception {
-
+
handle.clear();
handle.put("timestamp", SKIPVAL);
-
+
waitForThingsToLevelOut(30);
+ logger.info("### STARTING ACTUAL TEST");
+
del("*:*");
createCollection("collection2", 2, 1, 10);
@@ -258,6 +264,8 @@ public class AliasIntegrationTest extends AbstractFullDistribZkTestBase {
sawException = true;
}
assertTrue(sawException);
+
+ logger.info("### FINISHED ACTUAL TEST");
}
private void createAlias(String alias, String collections)
diff --git a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
index a2e7c3e060c..5fa42b7a701 100644
--- a/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/CollectionsAPIDistributedZkTest.java
@@ -54,7 +54,6 @@ import org.apache.solr.common.util.StrUtils;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore;
import org.apache.solr.core.SolrInfoMBean.Category;
-import org.apache.solr.core.SolrResourceLoader;
import org.apache.solr.servlet.SolrDispatchFilter;
import org.apache.solr.update.DirectUpdateHandler2;
import org.apache.solr.util.DefaultSolrThreadFactory;
@@ -64,10 +63,12 @@ import org.junit.BeforeClass;
import javax.management.MBeanServer;
import javax.management.MBeanServerFactory;
import javax.management.ObjectName;
-
import java.io.File;
import java.io.IOException;
import java.lang.management.ManagementFactory;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
@@ -110,7 +111,6 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
// we randomly use a second config set rather than just one
private boolean secondConfigSet = random().nextBoolean();
- private boolean oldStyleSolrXml = false;
@BeforeClass
public static void beforeThisClass2() throws Exception {
@@ -123,13 +123,7 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
super.setUp();
useJettyDataDir = false;
-
- oldStyleSolrXml = random().nextBoolean();
- if (oldStyleSolrXml) {
- System.err.println("Using old style solr.xml");
- } else {
- System.err.println("Using new style solr.xml");
- }
+
if (secondConfigSet ) {
String zkHost = zkServer.getZkHost();
String zkAddress = zkServer.getZkAddress();
@@ -158,12 +152,11 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
}
System.setProperty("numShards", Integer.toString(sliceCount));
- System.setProperty("solr.xml.persist", "true");
+
}
protected String getSolrXml() {
- // test old style and new style solr.xml
- return oldStyleSolrXml ? "solr-no-core-old-style.xml" : "solr-no-core.xml";
+ return "solr-no-core.xml";
}
@@ -953,28 +946,22 @@ public class CollectionsAPIDistributedZkTest extends AbstractFullDistribZkTestBa
}
}
- private void checkInstanceDirs(JettySolrRunner jetty) {
+ private void checkInstanceDirs(JettySolrRunner jetty) throws IOException {
CoreContainer cores = ((SolrDispatchFilter) jetty.getDispatchFilter()
.getFilter()).getCores();
Collection theCores = cores.getCores();
for (SolrCore core : theCores) {
- if (!oldStyleSolrXml) {
- // look for core props file
- assertTrue("Could not find expected core.properties file",
- new File((String) core.getStatistics().get("instanceDir"),
- "core.properties").exists());
- }
- try {
- assertEquals(
- new File(SolrResourceLoader.normalizeDir(jetty.getSolrHome() + File.separator
- + core.getName())).getCanonicalPath(),
- new File(SolrResourceLoader.normalizeDir((String) core.getStatistics().get(
- "instanceDir"))).getCanonicalPath());
- } catch (IOException e) {
- log.error("Failed to get canonical path", e);
- fail("Failed to get canonical path");
- }
+ // look for core props file
+ assertTrue("Could not find expected core.properties file",
+ new File((String) core.getStatistics().get("instanceDir"),
+ "core.properties").exists());
+
+ Path expected = Paths.get(jetty.getSolrHome()).toAbsolutePath().resolve("cores").resolve(core.getName());
+ Path reported = Paths.get((String) core.getStatistics().get("instanceDir"));
+
+ assertTrue("Expected: " + expected + "\nFrom core stats: " + reported, Files.isSameFile(expected, reported));
+
}
}
diff --git a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
index 55a02a5b2e0..bed3d7280fc 100644
--- a/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/LeaderElectionIntegrationTest.java
@@ -23,6 +23,7 @@ import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.cloud.ZkNodeProps;
import org.apache.solr.common.cloud.ZkStateReader;
import org.apache.solr.core.CoreContainer;
+import org.apache.solr.core.CoreDescriptor;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -146,8 +147,7 @@ public class LeaderElectionIntegrationTest extends SolrTestCaseJ4 {
ports.add(port);
CoreContainer container = new CoreContainer();
container.load();
- assertTrue("Container " + port + " has no cores!", container.getCores()
- .size() > 0);
+ container.create(new CoreDescriptor(container, "collection1", "collection1", "collection", "collection1"));
containerMap.put(port, container);
System.clearProperty("solr.solr.home");
System.clearProperty("hostPort");
diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java b/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
index c873287ddbf..2c95ce964d6 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ZkCLITest.java
@@ -17,14 +17,6 @@ package org.apache.solr.cloud;
* limitations under the License.
*/
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.Collection;
-import java.util.List;
-
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.io.filefilter.RegexFileFilter;
@@ -44,6 +36,14 @@ import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.InputStream;
+import java.nio.charset.StandardCharsets;
+import java.util.Collection;
+import java.util.List;
+
// TODO: This test would be a lot faster if it used a solrhome with fewer config
// files - there are a lot of them to upload
public class ZkCLITest extends SolrTestCaseJ4 {
@@ -78,19 +78,10 @@ public class ZkCLITest extends SolrTestCaseJ4 {
log.info("####SETUP_START " + getTestName());
String exampleHome = SolrJettyTestBase.legacyExampleCollection1SolrHome();
-
- boolean useNewSolrXml = random().nextBoolean();
+
File tmpDir = createTempDir().toFile();
- if (useNewSolrXml) {
- solrHome = exampleHome;
- } else {
- File tmpSolrHome = new File(tmpDir, "tmp-solr-home");
- FileUtils.copyDirectory(new File(exampleHome), tmpSolrHome);
- FileUtils.copyFile(getFile("old-solr-example/solr.xml"), new File(tmpSolrHome, "solr.xml"));
- solrHome = tmpSolrHome.getAbsolutePath();
- }
-
-
+ solrHome = exampleHome;
+
zkDir = tmpDir.getAbsolutePath() + File.separator
+ "zookeeper/server1/data";
log.info("ZooKeeper dataDir:" + zkDir);
diff --git a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
index 6a93a1f6d4f..a9f1bcedf5c 100644
--- a/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
+++ b/solr/core/src/test/org/apache/solr/cloud/ZkControllerTest.java
@@ -17,12 +17,6 @@ package org.apache.solr.cloud;
* the License.
*/
-import java.io.File;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
import org.apache.lucene.util.LuceneTestCase.Slow;
import org.apache.solr.SolrJettyTestBase;
import org.apache.solr.SolrTestCaseJ4;
@@ -33,6 +27,7 @@ import org.apache.solr.core.ConfigSolr;
import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.CoreDescriptor;
import org.apache.solr.core.CoresLocator;
+import org.apache.solr.core.PluginInfo;
import org.apache.solr.handler.admin.CoreAdminHandler;
import org.apache.solr.handler.component.HttpShardHandlerFactory;
import org.apache.solr.update.UpdateShardHandler;
@@ -41,6 +36,12 @@ import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
+import java.io.File;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
@Slow
public class ZkControllerTest extends SolrTestCaseJ4 {
@@ -321,7 +322,7 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
@Override
public ConfigSolr getConfig() {
- return new ConfigSolr() {
+ return new ConfigSolr(null, null) {
@Override
public CoresLocator getCoresLocator() {
@@ -329,25 +330,22 @@ public class ZkControllerTest extends SolrTestCaseJ4 {
}
@Override
- protected String getShardHandlerFactoryConfigPath() {
- throw new UnsupportedOperationException();
+ public PluginInfo getShardHandlerFactoryPluginInfo() {
+ return null;
}
@Override
- public boolean isPersistent() {
- throw new UnsupportedOperationException();
- }};
+ protected String getProperty(CfgProp key) {
+ return null;
+ }
+
+ };
}
@Override
public UpdateShardHandler getUpdateShardHandler() {
return new UpdateShardHandler(null);
}
-
- @Override
- public String getAdminPath() {
- return "/admin/cores";
- }
}
}
diff --git a/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java b/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java
deleted file mode 100644
index 3862f1b319e..00000000000
--- a/solr/core/src/test/org/apache/solr/core/CoreContainerCoreInitFailuresTest.java
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.core;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.lucene.util.IOUtils;
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.SolrException;
-import org.junit.After;
-import org.xml.sax.SAXParseException;
-
-import java.io.File;
-import java.util.Collection;
-import java.util.Map;
-import java.util.regex.Pattern;
-
-public class CoreContainerCoreInitFailuresTest extends SolrTestCaseJ4 {
-
- File solrHome = null;
- CoreContainer cc = null;
-
- private void init(final String dirSuffix) {
- solrHome = createTempDir(dirSuffix).toFile();
- }
-
- @After
- public void cleanUp() throws Exception {
- if (cc != null) {
- cc.shutdown();
- cc = null;
- }
-
- solrHome = null;
- }
-
- public void testFlowWithEmpty() throws Exception {
- // reused state
- Map failures = null;
- Collection cores = null;
- Exception fail = null;
-
- init("empty_flow");
-
- // solr.xml
- File solrXml = new File(solrHome, "solr.xml");
- FileUtils.write(solrXml, EMPTY_SOLR_XML, IOUtils.UTF_8);
-
- // ----
- // init the CoreContainer
- cc = new CoreContainer(solrHome.getAbsolutePath());
- cc.load();
-
- // check that we have the cores we expect
- cores = cc.getCoreNames();
- assertNotNull("core names is null", cores);
- assertEquals("wrong number of cores", 0, cores.size());
-
- // check that we have the failures we expect
- failures = cc.getCoreInitFailures();
- assertNotNull("core failures is a null map", failures);
- assertEquals("wrong number of core failures", 0, failures.size());
-
- // -----
- // try to add a collection with a path that doesn't exist
- final CoreDescriptor bogus = new CoreDescriptor(cc, "bogus", "bogus_path");
- try {
- ignoreException(Pattern.quote("bogus_path"));
- cc.create(bogus);
- fail("bogus inst dir failed to trigger exception from create");
- } catch (SolrException e) {
- assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
- 0 < e.getCause().getCause().getMessage().indexOf("bogus_path"));
-
- }
-
- // check that we have the cores we expect
- cores = cc.getCoreNames();
- assertNotNull("core names is null", cores);
- assertEquals("wrong number of cores", 0, cores.size());
-
- // check that we have the failures we expect
- failures = cc.getCoreInitFailures();
- assertNotNull("core failures is a null map", failures);
- assertEquals("wrong number of core failures", 1, failures.size());
- fail = failures.get("bogus").exception;
- assertNotNull("null failure for test core", fail);
- assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
- 0 < fail.getCause().getMessage().indexOf("bogus_path"));
-
- // check that we get null accessing a non-existent core
- assertNull(cc.getCore("does_not_exist"));
- // check that we get a 500 accessing the core with an init failure
- try {
- SolrCore c = cc.getCore("bogus");
- fail("Failed to get Exception on accessing core with init failure");
- } catch (SolrException ex) {
- assertEquals(500, ex.code());
- // double wrapped
- String cause = ex.getCause().getCause().getMessage();
- assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
- 0 < cause.indexOf("bogus_path"));
-
- }
-
- // let the test end here, with some recorded failures, and let cleanUp()
- // verify that there is no problem shuting down CoreContainer with known
- // SolrCore failures
- }
-
- public void testFlowBadFromStart() throws Exception {
-
- // reused state
- Map failures = null;
- Collection cores = null;
- Exception fail = null;
-
- init("bad_flow");
-
- // start with two collections: one valid, and one broken
- File solrXml = new File(solrHome, "solr.xml");
- FileUtils.write(solrXml, BAD_SOLR_XML, IOUtils.UTF_8);
-
- // our "ok" collection
- FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
- FileUtils.getFile(solrHome, "col_ok", "conf", "solrconfig.xml"));
- FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
- FileUtils.getFile(solrHome, "col_ok", "conf", "schema.xml"));
-
- // our "bad" collection
- ignoreException(Pattern.quote("DummyMergePolicy"));
- FileUtils.copyFile(getFile("solr/collection1/conf/bad-mp-solrconfig.xml"),
- FileUtils.getFile(solrHome, "col_bad", "conf", "solrconfig.xml"));
- FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
- FileUtils.getFile(solrHome, "col_bad", "conf", "schema.xml"));
-
-
- // -----
- // init the CoreContainer with the mix of ok/bad cores
- cc = new CoreContainer(solrHome.getAbsolutePath());
- cc.load();
-
- // check that we have the cores we expect
- cores = cc.getCoreNames();
- assertNotNull("core names is null", cores);
- assertEquals("wrong number of cores", 1, cores.size());
- assertTrue("col_ok not found", cores.contains("col_ok"));
-
- // check that we have the failures we expect
- failures = cc.getCoreInitFailures();
- assertNotNull("core failures is a null map", failures);
- assertEquals("wrong number of core failures", 1, failures.size());
- fail = failures.get("col_bad").exception;
- assertNotNull("null failure for test core", fail);
- assertTrue("init failure doesn't mention problem: " + fail.getMessage(),
- 0 < fail.getMessage().indexOf("DummyMergePolicy"));
-
- // check that we get null accessing a non-existent core
- assertNull(cc.getCore("does_not_exist"));
- // check that we get a 500 accessing the core with an init failure
- try {
- SolrCore c = cc.getCore("col_bad");
- fail("Failed to get Exception on accessing core with init failure");
- } catch (SolrException ex) {
- assertEquals(500, ex.code());
- // double wrapped
- String cause = ex.getCause().getCause().getMessage();
- assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
- 0 < cause.indexOf("DummyMergePolicy"));
- }
-
- // -----
- // "fix" the bad collection
- FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
- FileUtils.getFile(solrHome, "col_bad", "conf", "solrconfig.xml"));
- final CoreDescriptor fixed = new CoreDescriptor(cc, "col_bad", "col_bad");
- cc.create(fixed);
-
- // check that we have the cores we expect
- cores = cc.getCoreNames();
- assertNotNull("core names is null", cores);
- assertEquals("wrong number of cores", 2, cores.size());
- assertTrue("col_ok not found", cores.contains("col_ok"));
- assertTrue("col_bad not found", cores.contains("col_bad"));
-
- // check that we have the failures we expect
- failures = cc.getCoreInitFailures();
- assertNotNull("core failures is a null map", failures);
- assertEquals("wrong number of core failures", 0, failures.size());
-
-
- // -----
- // try to add a collection with a path that doesn't exist
- final CoreDescriptor bogus = new CoreDescriptor(cc, "bogus", "bogus_path");
- try {
- ignoreException(Pattern.quote("bogus_path"));
- cc.create(bogus);
- fail("bogus inst dir failed to trigger exception from create");
- } catch (SolrException e) {
- assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
- 0 < e.getCause().getCause().getMessage().indexOf("bogus_path"));
-
- }
-
- // check that we have the cores we expect
- cores = cc.getCoreNames();
- assertNotNull("core names is null", cores);
- assertEquals("wrong number of cores", 2, cores.size());
- assertTrue("col_ok not found", cores.contains("col_ok"));
- assertTrue("col_bad not found", cores.contains("col_bad"));
-
- // check that we have the failures we expect
- failures = cc.getCoreInitFailures();
- assertNotNull("core failures is a null map", failures);
- assertEquals("wrong number of core failures", 1, failures.size());
- fail = failures.get("bogus").exception;
- assertNotNull("null failure for test core", fail);
- assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
- 0 < fail.getCause().getMessage().indexOf("bogus_path"));
-
- // check that we get null accessing a non-existent core
- assertNull(cc.getCore("does_not_exist"));
- // check that we get a 500 accessing the core with an init failure
- try {
- SolrCore c = cc.getCore("bogus");
- fail("Failed to get Exception on accessing core with init failure");
- } catch (SolrException ex) {
- assertEquals(500, ex.code());
- // double wrapped
- String cause = ex.getCause().getCause().getMessage();
- assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
- 0 < cause.indexOf("bogus_path"));
- }
-
- // -----
- // break col_bad's config and try to RELOAD to add failure
-
- final long col_bad_old_start = getCoreStartTime(cc, "col_bad");
-
- FileUtils.write
- (FileUtils.getFile(solrHome, "col_bad", "conf", "solrconfig.xml"),
- "This is giberish, not valid XML <",
- IOUtils.UTF_8);
-
- try {
- ignoreException(Pattern.quote("SAX"));
- cc.reload("col_bad");
- fail("corrupt solrconfig.xml failed to trigger exception from reload");
- } catch (SolrException e) {
- Throwable rootException = getWrappedException(e);
- assertTrue("We're supposed to have a wrapped SAXParserException here, but we don't",
- rootException instanceof SAXParseException);
- SAXParseException se = (SAXParseException) rootException;
- assertTrue("reload exception doesn't refer to slrconfig.xml " + se.getSystemId(),
- 0 < se.getSystemId().indexOf("solrconfig.xml"));
-
- }
-
- assertEquals("Failed core reload should not have changed start time",
- col_bad_old_start, getCoreStartTime(cc, "col_bad"));
-
- // check that we have the cores we expect
- cores = cc.getCoreNames();
- assertNotNull("core names is null", cores);
- assertEquals("wrong number of cores", 2, cores.size());
- assertTrue("col_ok not found", cores.contains("col_ok"));
- assertTrue("col_bad not found", cores.contains("col_bad"));
-
- // check that we have the failures we expect
- failures = cc.getCoreInitFailures();
- assertNotNull("core failures is a null map", failures);
- assertEquals("wrong number of core failures", 2, failures.size());
- Throwable ex = getWrappedException(failures.get("col_bad").exception);
- assertNotNull("null failure for test core", ex);
- assertTrue("init failure isn't SAXParseException",
- ex instanceof SAXParseException);
- SAXParseException saxEx = (SAXParseException) ex;
- assertTrue("init failure doesn't mention problem: " + saxEx.toString(), saxEx.getSystemId().contains("solrconfig.xml"));
-
- // ----
- // fix col_bad's config (again) and RELOAD to fix failure
- FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
- FileUtils.getFile(solrHome, "col_bad", "conf", "solrconfig.xml"));
- cc.reload("col_bad");
-
- assertTrue("Core reload should have changed start time",
- col_bad_old_start < getCoreStartTime(cc, "col_bad"));
-
-
- // check that we have the cores we expect
- cores = cc.getCoreNames();
- assertNotNull("core names is null", cores);
- assertEquals("wrong number of cores", 2, cores.size());
- assertTrue("col_ok not found", cores.contains("col_ok"));
- assertTrue("col_bad not found", cores.contains("col_bad"));
-
- // check that we have the failures we expect
- failures = cc.getCoreInitFailures();
- assertNotNull("core failures is a null map", failures);
- assertEquals("wrong number of core failures", 1, failures.size());
-
- }
-
- public void testJavaLangErrorFromHandlerOnStartup() throws Exception {
-
- // reused state
- Map failures = null;
- Collection cores = null;
- Exception fail = null;
-
- init("java_lang_error_handler");
-
- // start with two collections: 1 ok, and 1 that throws java.lang.Error on startup
- File solrXml = new File(solrHome, "solr.xml");
- FileUtils.write(solrXml, BAD_SOLR_XML, IOUtils.UTF_8);
-
- // our "ok" collection
- FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
- FileUtils.getFile(solrHome, "col_ok", "conf", "solrconfig.xml"));
- FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
- FileUtils.getFile(solrHome, "col_ok", "conf", "schema.xml"));
-
- // our "bad" collection
- ignoreException(Pattern.quote("my_error_handler"));
- FileUtils.copyFile(getFile("solr/collection1/conf/bad-error-solrconfig.xml"),
- FileUtils.getFile(solrHome, "col_bad", "conf", "solrconfig.xml"));
- FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
- FileUtils.getFile(solrHome, "col_bad", "conf", "schema.xml"));
-
-
- // -----
- // init the CoreContainer with the mix of ok/bad cores
- cc = new CoreContainer(solrHome.getAbsolutePath());
- cc.load();
-
- // check that we have the cores we expect
- cores = cc.getCoreNames();
- assertNotNull("core names is null", cores);
- assertEquals("wrong number of cores", 1, cores.size());
- assertTrue("col_ok not found", cores.contains("col_ok"));
-
- // check that we have the failures we expect
- failures = cc.getCoreInitFailures();
- assertNotNull("core failures is a null map", failures);
- assertEquals("wrong number of core failures", 1, failures.size());
- fail = failures.get("col_bad").exception;
- assertNotNull("null failure for test core", fail);
- assertTrue("init failure doesn't mention root problem: " + fail.getMessage(),
- 0 < fail.getMessage().indexOf("throwing a java.lang.Error"));
- }
-
- public void testJavaLangErrorFromSchemaOnStartup() throws Exception {
-
- // reused state
- Map failures = null;
- Collection cores = null;
- Exception fail = null;
-
- init("java_lang_error_schema");
-
- // start with two collections: 1 ok, and 1 that throws java.lang.Error on startup
- File solrXml = new File(solrHome, "solr.xml");
- FileUtils.write(solrXml, BAD_SOLR_XML, IOUtils.UTF_8);
-
- // our "ok" collection
- FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
- FileUtils.getFile(solrHome, "col_ok", "conf", "solrconfig.xml"));
- FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
- FileUtils.getFile(solrHome, "col_ok", "conf", "schema.xml"));
-
- // our "bad" collection
- ignoreException(Pattern.quote("error_ft"));
- FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
- FileUtils.getFile(solrHome, "col_bad", "conf", "solrconfig.xml"));
- FileUtils.copyFile(getFile("solr/collection1/conf/bad-schema-init-error.xml"),
- FileUtils.getFile(solrHome, "col_bad", "conf", "schema.xml"));
-
-
- // -----
- // init the CoreContainer with the mix of ok/bad cores
- cc = new CoreContainer(solrHome.getAbsolutePath());
- cc.load();
-
- // check that we have the cores we expect
- cores = cc.getCoreNames();
- assertNotNull("core names is null", cores);
- assertEquals("wrong number of cores", 1, cores.size());
- assertTrue("col_ok not found", cores.contains("col_ok"));
-
- // check that we have the failures we expect
- failures = cc.getCoreInitFailures();
- assertNotNull("core failures is a null map", failures);
- assertEquals("wrong number of core failures", 1, failures.size());
- fail = failures.get("col_bad").exception;
- assertNotNull("null failure for test core", fail);
- assertTrue("init failure doesn't mention root problem: " + fail.getMessage(),
- 0 < fail.getMessage().indexOf("throwing java.lang.Error"));
-
- }
-
- private long getCoreStartTime(final CoreContainer cc, final String name) {
- try (SolrCore tmp = cc.getCore(name)) {
- return tmp.getStartTime();
- }
- }
-
- private static final String EMPTY_SOLR_XML ="\n" +
- "\n" +
- " \n" +
- " \n" +
- "";
-
- private static final String BAD_SOLR_XML =
- "\n" +
- "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- "";
-
-}
diff --git a/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java b/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java
index 5dc1687675b..d787390bc93 100644
--- a/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java
+++ b/solr/core/src/test/org/apache/solr/core/OpenCloseCoreStressTest.java
@@ -105,47 +105,41 @@ public class OpenCloseCoreStressTest extends SolrTestCaseJ4 {
@Test
public void test5Seconds() throws Exception {
- doStress(5, random().nextBoolean());
+ doStress(5);
}
@Test
@Nightly
public void test15SecondsOld() throws Exception {
- doStress(15, true);
+ doStress(15);
}
@Test
@Nightly
public void test15SecondsNew() throws Exception {
- doStress(15, false);
+ doStress(15);
}
@Test
@Nightly
public void test10MinutesOld() throws Exception {
- doStress(300, true);
+ doStress(300);
}
@Test
@Nightly
public void test10MinutesNew() throws Exception {
- doStress(300, false);
+ doStress(300);
}
@Test
@Weekly
- public void test1HourOld() throws Exception {
- doStress(1800, true);
+ public void test1Hour() throws Exception {
+ doStress(1800);
}
-
- @Test
- @Weekly
- public void test1HourNew() throws Exception {
- doStress(1800, false);
- }
-
-
+
private void buildClients() throws Exception {
+
jetty.start();
url = buildUrl(jetty.getLocalPort(), "/solr/");
@@ -169,8 +163,8 @@ public class OpenCloseCoreStressTest extends SolrTestCaseJ4 {
}
// Unless things go _really_ well, stop after you have the directories set up.
- private void doStress(int secondsToRun, boolean oldStyle) throws Exception {
- makeCores(solrHomeDirectory, oldStyle);
+ private void doStress(int secondsToRun) throws Exception {
+ makeCores(solrHomeDirectory);
//MUST start the server after the cores are made.
buildClients();
@@ -213,25 +207,22 @@ public class OpenCloseCoreStressTest extends SolrTestCaseJ4 {
}
}
- private void makeCores(File home, boolean oldStyle) throws Exception {
+ private void makeCores(File home) throws Exception {
File testSrcRoot = new File(SolrTestCaseJ4.TEST_HOME());
String srcSolrXml = "solr-stress-new.xml";
- if (oldStyle) {
- srcSolrXml = "solr-stress-old.xml";
- }
FileUtils.copyFile(new File(testSrcRoot, srcSolrXml), new File(home, "solr.xml"));
// create directories in groups of 100 until you have enough.
for (int idx = 0; idx < numCores; ++idx) {
String coreName = String.format(Locale.ROOT, "%05d_core", idx);
- makeCore(new File(home, coreName), testSrcRoot, oldStyle);
+ makeCore(new File(home, coreName), testSrcRoot);
coreCounts.put(coreName, 0L);
coreNames.add(coreName);
}
}
- private void makeCore(File coreDir, File testSrcRoot, boolean oldStyle) throws IOException {
+ private void makeCore(File coreDir, File testSrcRoot) throws IOException {
File conf = new File(coreDir, "conf");
if (!conf.mkdirs()) log.warn("mkdirs returned false in makeCore... ignoring");
@@ -244,9 +235,7 @@ public class OpenCloseCoreStressTest extends SolrTestCaseJ4 {
FileUtils.copyFile(new File(testConf, "solrconfig.snippet.randomindexconfig.xml"),
new File(conf, "solrconfig.snippet.randomindexconfig.xml"));
- if (!oldStyle) {
- FileUtils.copyFile(new File(testSrcRoot, "conf/core.properties"), new File(coreDir, "core.properties"));
- }
+ FileUtils.copyFile(new File(testSrcRoot, "conf/core.properties"), new File(coreDir, "core.properties"));
}
diff --git a/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java b/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
index 42b4fef2538..b78b8d71ffd 100644
--- a/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
+++ b/solr/core/src/test/org/apache/solr/core/SolrCoreTest.java
@@ -51,35 +51,6 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
deleteCore();
super.tearDown();
}
-
- @Test
- public void testRemoveThenAddDefaultCore() throws Exception {
- final CoreContainer cores = h.getCoreContainer();
- SolrCore core = cores.getCore("");
-
- assertEquals(COLLECTION1, cores.getDefaultCoreName());
-
- cores.unload("");
- core.close();
-
- CoreDescriptor cd = new CoreDescriptor(cores, COLLECTION1, "collection1",
- CoreDescriptor.CORE_DATADIR, createTempDir("dataDir2").toFile().getAbsolutePath());
-
- cores.create(cd);
-
- assertEquals(COLLECTION1, cores.getDefaultCoreName());
-
- // so we should be able to get a core with collection1
- core = cores.getCore(COLLECTION1);
- assertNotNull(core);
- core.close();
-
- // and with ""
- core = cores.getCore("");
- assertNotNull(core);
-
- core.close();
- }
@Test
public void testRequestHandlerRegistry() {
@@ -100,7 +71,7 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
@Test
public void testClose() throws Exception {
final CoreContainer cores = h.getCoreContainer();
- SolrCore core = cores.getCore("");
+ SolrCore core = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
ClosingRequestHandler handler1 = new ClosingRequestHandler();
handler1.inform( core );
@@ -120,7 +91,7 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
assertTrue("Refcount != 1", core.getOpenCount() == 1);
final CoreContainer cores = h.getCoreContainer();
- SolrCore c1 = cores.getCore("");
+ SolrCore c1 = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
assertTrue("Refcount != 2", core.getOpenCount() == 2);
ClosingRequestHandler handler1 = new ClosingRequestHandler();
@@ -131,12 +102,12 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
assertNull( old ); // should not be anything...
assertEquals( core.getRequestHandlers().get( path ), handler1 );
- SolrCore c2 = cores.getCore("");
+ SolrCore c2 = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
c1.close();
assertTrue("Refcount < 1", core.getOpenCount() >= 1);
assertTrue("Handler is closed", handler1.closed == false);
- c1 = cores.getCore("");
+ c1 = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
assertTrue("Refcount < 2", core.getOpenCount() >= 2);
assertTrue("Handler is closed", handler1.closed == false);
@@ -184,7 +155,7 @@ public class SolrCoreTest extends SolrTestCaseJ4 {
try {
for (int l = 0; l < LOOP; ++l) {
r += 1;
- core = cores.getCore("");
+ core = cores.getCore(SolrTestCaseJ4.DEFAULT_TEST_CORENAME);
// sprinkle concurrency hinting...
yield(l);
assertTrue("Refcount < 1", core.getOpenCount() >= 1);
diff --git a/solr/core/src/test/org/apache/solr/core/TestConfigSets.java b/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
index 2e238675edd..7193b25105d 100644
--- a/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
+++ b/solr/core/src/test/org/apache/solr/core/TestConfigSets.java
@@ -46,7 +46,7 @@ public class TestConfigSets extends SolrTestCaseJ4 {
System.setProperty("configsets", configSetsBaseDir);
SolrResourceLoader loader = new SolrResourceLoader(testDirectory.getAbsolutePath());
- CoreContainer container = new CoreContainer(loader, ConfigSolr.fromString(loader, solrxml));
+ CoreContainer container = new CoreContainer(ConfigSolr.fromString(loader, solrxml));
container.load();
return container;
@@ -115,12 +115,12 @@ public class TestConfigSets extends SolrTestCaseJ4 {
System.setProperty("configsets", csd);
SolrResourceLoader loader = new SolrResourceLoader(testDirectory.getAbsolutePath());
- CoreContainer container = new CoreContainer(loader, ConfigSolr.fromString(loader, solrxml));
+ CoreContainer container = new CoreContainer(ConfigSolr.fromString(loader, solrxml));
container.load();
// We initially don't have a /get handler defined
SolrCore core = container.create(new CoreDescriptor(container, "core1", testDirectory + "/core", "configSet", "configset-2"));
- assertThat("No /get handler should be defined in the initial configuration",
+ assertThat("No /dump handler should be defined in the initial configuration",
core.getRequestHandler("/dump"), is(nullValue()));
// Now copy in a config with a /get handler and reload
@@ -129,7 +129,7 @@ public class TestConfigSets extends SolrTestCaseJ4 {
container.reload("core1");
core = container.getCore("core1");
- assertThat("A /get handler should be defined in the reloaded configuration",
+ assertThat("A /dump handler should be defined in the reloaded configuration",
core.getRequestHandler("/dump"), is(notNullValue()));
core.close();
diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
index 2b97664650b..a577ff8f1fd 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCoreContainer.java
@@ -18,6 +18,7 @@
package org.apache.solr.core;
import org.apache.commons.io.FileUtils;
+import org.apache.lucene.util.IOUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.handler.admin.CollectionsHandler;
@@ -26,19 +27,18 @@ import org.apache.solr.handler.admin.InfoHandler;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
-import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.BufferedWriter;
import java.io.File;
import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.nio.charset.StandardCharsets;
+import java.nio.file.Path;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.List;
+import java.util.Map;
import java.util.jar.JarEntry;
import java.util.jar.JarOutputStream;
+import java.util.regex.Pattern;
import static org.hamcrest.CoreMatchers.not;
import static org.hamcrest.CoreMatchers.nullValue;
@@ -55,7 +55,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
@BeforeClass
public static void beforeClass() throws Exception {
oldSolrHome = System.getProperty(SOLR_HOME_PROP);
- initCore("solrconfig.xml", "schema.xml");
+ System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
}
@AfterClass
@@ -67,16 +67,14 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
}
}
- private File solrHomeDirectory;
+ private CoreContainer init(String xml) throws Exception {
+ Path solrHomeDirectory = createTempDir();
+ return init(solrHomeDirectory, xml);
+ }
- private CoreContainer init(String dirName) throws Exception {
-
- solrHomeDirectory = createTempDir(dirName).toFile();
-
- FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME()), solrHomeDirectory);
- System.out.println("Using solrconfig from " + new File(SolrTestCaseJ4.TEST_HOME()).getAbsolutePath());
-
- CoreContainer ret = new CoreContainer(solrHomeDirectory.getAbsolutePath());
+ private CoreContainer init(Path homeDirectory, String xml) throws Exception {
+ SolrResourceLoader loader = new SolrResourceLoader(homeDirectory.toString());
+ CoreContainer ret = new CoreContainer(ConfigSolr.fromString(loader, xml));
ret.load();
return ret;
}
@@ -84,12 +82,14 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
@Test
public void testShareSchema() throws Exception {
System.setProperty("shareSchema", "true");
- final CoreContainer cores = init("_shareSchema");
+
+ CoreContainer cores = init(CONFIGSETS_SOLR_XML);
+
try {
- CoreDescriptor descriptor1 = new CoreDescriptor(cores, "core1", "./collection1");
+ CoreDescriptor descriptor1 = new CoreDescriptor(cores, "core1", "./collection1", "configSet", "minimal");
SolrCore core1 = cores.create(descriptor1);
- CoreDescriptor descriptor2 = new CoreDescriptor(cores, "core2", "./collection1");
+ CoreDescriptor descriptor2 = new CoreDescriptor(cores, "core2", "./collection1", "configSet", "minimal");
SolrCore core2 = cores.create(descriptor2);
assertSame(core1.getLatestSchema(), core2.getLatestSchema());
@@ -102,12 +102,14 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
@Test
public void testReloadSequential() throws Exception {
- final CoreContainer cc = init("_reloadSequential");
+ final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
+ CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1", "configSet", "minimal");
+ cc.create(descriptor1);
try {
- cc.reload("collection1");
- cc.reload("collection1");
- cc.reload("collection1");
- cc.reload("collection1");
+ cc.reload("core1");
+ cc.reload("core1");
+ cc.reload("core1");
+ cc.reload("core1");
} finally {
cc.shutdown();
@@ -116,63 +118,52 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
@Test
public void testReloadThreaded() throws Exception {
- final CoreContainer cc = init("_reloadThreaded");
+ final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
+ CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1", "configSet", "minimal");
+ cc.create(descriptor1);
- class TestThread extends Thread {
- @Override
- public void run() {
- cc.reload("collection1");
- }
+ class TestThread extends Thread {
+ @Override
+ public void run() {
+ cc.reload("core1");
}
+ }
- List threads = new ArrayList<>();
- int numThreads = 4;
- for (int i = 0; i < numThreads; i++) {
- threads.add(new TestThread());
- }
+ List threads = new ArrayList<>();
+ int numThreads = 4;
+ for (int i = 0; i < numThreads; i++) {
+ threads.add(new TestThread());
+ }
- for (Thread thread : threads) {
- thread.start();
- }
+ for (Thread thread : threads) {
+ thread.start();
+ }
- for (Thread thread : threads) {
- thread.join();
+ for (Thread thread : threads) {
+ thread.join();
}
cc.shutdown();
}
-
-
@Test
- public void testNoCores() throws IOException, ParserConfigurationException, SAXException {
- //create solrHome
- File solrHomeDirectory = createTempDir().toFile();
-
- boolean oldSolrXml = random().nextBoolean();
-
- SetUpHome(solrHomeDirectory, oldSolrXml ? EMPTY_SOLR_XML : EMPTY_SOLR_XML2);
- CoreContainer cores = new CoreContainer(solrHomeDirectory.getAbsolutePath());
- cores.load();
+ public void testNoCores() throws Exception {
+
+ CoreContainer cores = init(CONFIGSETS_SOLR_XML);
+
try {
//assert zero cores
assertEquals("There should not be cores", 0, cores.getCores().size());
- FileUtils.copyDirectory(new File(SolrTestCaseJ4.TEST_HOME(), "collection1"), solrHomeDirectory);
//add a new core
- CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", solrHomeDirectory.getAbsolutePath());
+ CoreDescriptor coreDescriptor = new CoreDescriptor(cores, "core1", "collection1", CoreDescriptor.CORE_CONFIGSET, "minimal");
SolrCore newCore = cores.create(coreDescriptor);
//assert one registered core
assertEquals("There core registered", 1, cores.getCores().size());
- if (oldSolrXml) {
- assertXmlFile(new File(solrHomeDirectory, "solr.xml"),
- "/solr/cores[@transientCacheSize='32']");
- }
-
cores.unload("core1");
//assert cero cores
assertEquals("There should not be cores", 0, cores.getCores().size());
@@ -193,27 +184,14 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
}
@Test
- public void testLogWatcherEnabledByDefault() {
- assertNotNull(h.getCoreContainer().getLogging());
- }
-
- private void SetUpHome(File solrHomeDirectory, String xmlFile) throws IOException {
- if (solrHomeDirectory.exists()) {
- FileUtils.deleteDirectory(solrHomeDirectory);
- }
- assertTrue("Failed to mkdirs workDir", solrHomeDirectory.mkdirs());
+ public void testLogWatcherEnabledByDefault() throws Exception {
+ CoreContainer cc = init("");
try {
- File solrXmlFile = new File(solrHomeDirectory, "solr.xml");
- BufferedWriter out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(solrXmlFile), StandardCharsets.UTF_8));
- out.write(xmlFile);
- out.close();
- } catch (IOException e) {
- FileUtils.deleteDirectory(solrHomeDirectory);
- throw e;
+ assertNotNull(cc.getLogging());
+ }
+ finally {
+ cc.shutdown();
}
-
- //init
- System.setProperty(SOLR_HOME_PROP, solrHomeDirectory.getAbsolutePath());
}
@Test
@@ -221,13 +199,12 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
MockCoresLocator cl = new MockCoresLocator();
- solrHomeDirectory = createTempDir("_deleteBadCores").toFile();
- SolrResourceLoader resourceLoader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
- File instanceDir = new File(solrHomeDirectory, "_deleteBadCores");
+ SolrResourceLoader resourceLoader = new SolrResourceLoader(createTempDir().toString());
+
System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
- final CoreContainer cc = new CoreContainer(resourceLoader, ConfigSolr.fromString(resourceLoader, EMPTY_SOLR_XML2), cl);
- CoreDescriptor badcore = new CoreDescriptor(cc, "badcore", instanceDir.getAbsolutePath(), "configSet", "nosuchconfigset");
+ final CoreContainer cc = new CoreContainer(ConfigSolr.fromString(resourceLoader, CONFIGSETS_SOLR_XML), cl);
+ CoreDescriptor badcore = new CoreDescriptor(cc, "badcore", "badcore", "configSet", "nosuchconfigset");
cl.add(badcore);
try {
@@ -238,7 +215,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
assertThat(cc.getCoreInitFailures().size(), is(0));
// can we create the core now with a good config?
- SolrCore core = cc.create(new CoreDescriptor(cc, "badcore", instanceDir.getAbsolutePath(), "configSet", "minimal"));
+ SolrCore core = cc.create(new CoreDescriptor(cc, "badcore", "badcore", "configSet", "minimal"));
assertThat(core, not(nullValue()));
}
@@ -249,13 +226,13 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
@Test
public void testClassLoaderHierarchy() throws Exception {
- final CoreContainer cc = init("_classLoaderHierarchy");
+ final CoreContainer cc = init(CONFIGSETS_SOLR_XML);
try {
ClassLoader sharedLoader = cc.loader.getClassLoader();
ClassLoader contextLoader = Thread.currentThread().getContextClassLoader();
assertSame(contextLoader, sharedLoader.getParent());
- CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1");
+ CoreDescriptor descriptor1 = new CoreDescriptor(cc, "core1", "./collection1", "configSet", "minimal");
SolrCore core1 = cc.create(descriptor1);
ClassLoader coreLoader = core1.getResourceLoader().getClassLoader();
assertSame(sharedLoader, coreLoader.getParent());
@@ -267,9 +244,9 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
@Test
public void testSharedLib() throws Exception {
- File tmpRoot = createTempDir("testSharedLib").toFile();
+ Path tmpRoot = createTempDir("testSharedLib");
- File lib = new File(tmpRoot, "lib");
+ File lib = new File(tmpRoot.toFile(), "lib");
lib.mkdirs();
JarOutputStream jar1 = new JarOutputStream(new FileOutputStream(new File(lib, "jar1.jar")));
@@ -277,7 +254,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
jar1.closeEntry();
jar1.close();
- File customLib = new File(tmpRoot, "customLib");
+ File customLib = new File(tmpRoot.toFile(), "customLib");
customLib.mkdirs();
JarOutputStream jar2 = new JarOutputStream(new FileOutputStream(new File(customLib, "jar2.jar")));
@@ -285,41 +262,32 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
jar2.closeEntry();
jar2.close();
- FileUtils.writeStringToFile(new File(tmpRoot, "default-lib-solr.xml"), "", "UTF-8");
- FileUtils.writeStringToFile(new File(tmpRoot, "explicit-lib-solr.xml"), "", "UTF-8");
- FileUtils.writeStringToFile(new File(tmpRoot, "custom-lib-solr.xml"), "", "UTF-8");
-
- final CoreContainer cc1 = CoreContainer.createAndLoad(tmpRoot.getAbsolutePath(), new File(tmpRoot, "default-lib-solr.xml"));
+ final CoreContainer cc1 = init(tmpRoot, "");
try {
cc1.loader.openResource("defaultSharedLibFile").close();
} finally {
cc1.shutdown();
}
- final CoreContainer cc2 = CoreContainer.createAndLoad(tmpRoot.getAbsolutePath(), new File(tmpRoot, "explicit-lib-solr.xml"));
+ final CoreContainer cc2 = init(tmpRoot, "lib");
try {
cc2.loader.openResource("defaultSharedLibFile").close();
} finally {
cc2.shutdown();
}
- final CoreContainer cc3 = CoreContainer.createAndLoad(tmpRoot.getAbsolutePath(), new File(tmpRoot, "custom-lib-solr.xml"));
+ final CoreContainer cc3 = init(tmpRoot, "customLib");
try {
cc3.loader.openResource("customSharedLibFile").close();
} finally {
cc3.shutdown();
}
}
-
- private static final String EMPTY_SOLR_XML ="\n" +
- "\n" +
- " \n" +
- " \n" +
- "";
-
- private static final String EMPTY_SOLR_XML2 ="\n" +
+
+ private static final String CONFIGSETS_SOLR_XML ="\n" +
"\n" +
- "${configsets:configsets}" +
+ "${configsets:configsets}\n" +
+ "${shareSchema:false}\n" +
"";
private static final String CUSTOM_HANDLERS_SOLR_XML = "\n" +
@@ -350,12 +318,7 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
@Test
public void testCustomHandlers() throws Exception {
- solrHomeDirectory = createTempDir("_customHandlers").toFile();
- SolrResourceLoader loader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
-
- ConfigSolr config = ConfigSolr.fromString(loader, CUSTOM_HANDLERS_SOLR_XML);
-
- CoreContainer cc = new CoreContainer(loader, config);
+ CoreContainer cc = init(CUSTOM_HANDLERS_SOLR_XML);
try {
cc.load();
assertThat(cc.getCollectionsHandler(), is(instanceOf(CustomCollectionsHandler.class)));
@@ -406,4 +369,262 @@ public class TestCoreContainer extends SolrTestCaseJ4 {
return cores;
}
}
+
+ @Test
+ public void testCoreInitFailuresFromEmptyContainer() throws Exception {
+ // reused state
+ Map failures = null;
+ Collection cores = null;
+ Exception fail = null;
+
+ // ----
+ // init the CoreContainer
+ CoreContainer cc = init(CONFIGSETS_SOLR_XML);
+
+ // check that we have the cores we expect
+ cores = cc.getCoreNames();
+ assertNotNull("core names is null", cores);
+ assertEquals("wrong number of cores", 0, cores.size());
+
+ // check that we have the failures we expect
+ failures = cc.getCoreInitFailures();
+ assertNotNull("core failures is a null map", failures);
+ assertEquals("wrong number of core failures", 0, failures.size());
+
+ // -----
+ // try to add a collection with a path that doesn't exist
+ final CoreDescriptor bogus = new CoreDescriptor(cc, "bogus", "bogus_path");
+ try {
+ ignoreException(Pattern.quote("bogus_path"));
+ cc.create(bogus);
+ fail("bogus inst dir failed to trigger exception from create");
+ } catch (SolrException e) {
+ assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
+ 0 < e.getCause().getCause().getMessage().indexOf("bogus_path"));
+
+ }
+
+ // check that we have the cores we expect
+ cores = cc.getCoreNames();
+ assertNotNull("core names is null", cores);
+ assertEquals("wrong number of cores", 0, cores.size());
+
+ // check that we have the failures we expect
+ failures = cc.getCoreInitFailures();
+ assertNotNull("core failures is a null map", failures);
+ assertEquals("wrong number of core failures", 1, failures.size());
+ fail = failures.get("bogus").exception;
+ assertNotNull("null failure for test core", fail);
+ assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
+ 0 < fail.getCause().getMessage().indexOf("bogus_path"));
+
+ // check that we get null accessing a non-existent core
+ assertNull(cc.getCore("does_not_exist"));
+ // check that we get a 500 accessing the core with an init failure
+ try {
+ SolrCore c = cc.getCore("bogus");
+ fail("Failed to get Exception on accessing core with init failure");
+ } catch (SolrException ex) {
+ assertEquals(500, ex.code());
+ // double wrapped
+ String cause = ex.getCause().getCause().getMessage();
+ assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
+ 0 < cause.indexOf("bogus_path"));
+
+ }
+
+ cc.shutdown();
+ }
+
+ @Test
+ public void testCoreInitFailuresOnReload() throws Exception {
+
+ // reused state
+ Map failures = null;
+ Collection cores = null;
+ Exception fail = null;
+
+ // -----
+ // init the CoreContainer with the mix of ok/bad cores
+ MockCoresLocator cl = new MockCoresLocator();
+
+ SolrResourceLoader resourceLoader = new SolrResourceLoader(createTempDir().toString());
+
+ System.setProperty("configsets", getFile("solr/configsets").getAbsolutePath());
+
+ final CoreContainer cc = new CoreContainer(ConfigSolr.fromString(resourceLoader, CONFIGSETS_SOLR_XML), cl);
+ cl.add(new CoreDescriptor(cc, "col_ok", "col_ok", "configSet", "minimal"));
+ cl.add(new CoreDescriptor(cc, "col_bad", "col_bad", "configSet", "bad-mergepolicy"));
+ cc.load();
+
+ // check that we have the cores we expect
+ cores = cc.getCoreNames();
+ assertNotNull("core names is null", cores);
+ assertEquals("wrong number of cores", 1, cores.size());
+ assertTrue("col_ok not found", cores.contains("col_ok"));
+
+ // check that we have the failures we expect
+ failures = cc.getCoreInitFailures();
+ assertNotNull("core failures is a null map", failures);
+ assertEquals("wrong number of core failures", 1, failures.size());
+ fail = failures.get("col_bad").exception;
+ assertNotNull("null failure for test core", fail);
+ assertTrue("init failure doesn't mention problem: " + fail.getMessage(),
+ 0 < fail.getMessage().indexOf("DummyMergePolicy"));
+
+ // check that we get null accessing a non-existent core
+ assertNull(cc.getCore("does_not_exist"));
+ // check that we get a 500 accessing the core with an init failure
+ try {
+ SolrCore c = cc.getCore("col_bad");
+ fail("Failed to get Exception on accessing core with init failure");
+ } catch (SolrException ex) {
+ assertEquals(500, ex.code());
+ // double wrapped
+ String cause = ex.getCause().getCause().getMessage();
+ assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
+ 0 < cause.indexOf("DummyMergePolicy"));
+ }
+
+ // -----
+ // "fix" the bad collection
+ FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
+ FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"));
+ FileUtils.copyFile(getFile("solr/collection1/conf/schema-minimal.xml"),
+ FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "schema.xml"));
+ final CoreDescriptor fixed = new CoreDescriptor(cc, "col_bad", "col_bad");
+ cc.create(fixed);
+
+ // check that we have the cores we expect
+ cores = cc.getCoreNames();
+ assertNotNull("core names is null", cores);
+ assertEquals("wrong number of cores", 2, cores.size());
+ assertTrue("col_ok not found", cores.contains("col_ok"));
+ assertTrue("col_bad not found", cores.contains("col_bad"));
+
+ // check that we have the failures we expect
+ failures = cc.getCoreInitFailures();
+ assertNotNull("core failures is a null map", failures);
+ assertEquals("wrong number of core failures", 0, failures.size());
+
+
+ // -----
+ // try to add a collection with a path that doesn't exist
+ final CoreDescriptor bogus = new CoreDescriptor(cc, "bogus", "bogus_path");
+ try {
+ ignoreException(Pattern.quote("bogus_path"));
+ cc.create(bogus);
+ fail("bogus inst dir failed to trigger exception from create");
+ } catch (SolrException e) {
+ assertTrue("init exception doesn't mention bogus dir: " + e.getCause().getCause().getMessage(),
+ 0 < e.getCause().getCause().getMessage().indexOf("bogus_path"));
+
+ }
+
+ // check that we have the cores we expect
+ cores = cc.getCoreNames();
+ assertNotNull("core names is null", cores);
+ assertEquals("wrong number of cores", 2, cores.size());
+ assertTrue("col_ok not found", cores.contains("col_ok"));
+ assertTrue("col_bad not found", cores.contains("col_bad"));
+
+ // check that we have the failures we expect
+ failures = cc.getCoreInitFailures();
+ assertNotNull("core failures is a null map", failures);
+ assertEquals("wrong number of core failures", 1, failures.size());
+ fail = failures.get("bogus").exception;
+ assertNotNull("null failure for test core", fail);
+ assertTrue("init failure doesn't mention problem: " + fail.getCause().getMessage(),
+ 0 < fail.getCause().getMessage().indexOf("bogus_path"));
+
+ // check that we get null accessing a non-existent core
+ assertNull(cc.getCore("does_not_exist"));
+ // check that we get a 500 accessing the core with an init failure
+ try {
+ SolrCore c = cc.getCore("bogus");
+ fail("Failed to get Exception on accessing core with init failure");
+ } catch (SolrException ex) {
+ assertEquals(500, ex.code());
+ // double wrapped
+ String cause = ex.getCause().getCause().getMessage();
+ assertTrue("getCore() ex cause doesn't mention init fail: " + cause,
+ 0 < cause.indexOf("bogus_path"));
+ }
+
+ // -----
+ // break col_bad's config and try to RELOAD to add failure
+
+ final long col_bad_old_start = getCoreStartTime(cc, "col_bad");
+
+ FileUtils.write
+ (FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"),
+ "This is giberish, not valid XML <",
+ IOUtils.UTF_8);
+
+ try {
+ ignoreException(Pattern.quote("SAX"));
+ cc.reload("col_bad");
+ fail("corrupt solrconfig.xml failed to trigger exception from reload");
+ } catch (SolrException e) {
+ Throwable rootException = getWrappedException(e);
+ assertTrue("We're supposed to have a wrapped SAXParserException here, but we don't",
+ rootException instanceof SAXParseException);
+ SAXParseException se = (SAXParseException) rootException;
+ assertTrue("reload exception doesn't refer to slrconfig.xml " + se.getSystemId(),
+ 0 < se.getSystemId().indexOf("solrconfig.xml"));
+
+ }
+
+ assertEquals("Failed core reload should not have changed start time",
+ col_bad_old_start, getCoreStartTime(cc, "col_bad"));
+
+ // check that we have the cores we expect
+ cores = cc.getCoreNames();
+ assertNotNull("core names is null", cores);
+ assertEquals("wrong number of cores", 2, cores.size());
+ assertTrue("col_ok not found", cores.contains("col_ok"));
+ assertTrue("col_bad not found", cores.contains("col_bad"));
+
+ // check that we have the failures we expect
+ failures = cc.getCoreInitFailures();
+ assertNotNull("core failures is a null map", failures);
+ assertEquals("wrong number of core failures", 2, failures.size());
+ Throwable ex = getWrappedException(failures.get("col_bad").exception);
+ assertNotNull("null failure for test core", ex);
+ assertTrue("init failure isn't SAXParseException",
+ ex instanceof SAXParseException);
+ SAXParseException saxEx = (SAXParseException) ex;
+ assertTrue("init failure doesn't mention problem: " + saxEx.toString(), saxEx.getSystemId().contains("solrconfig.xml"));
+
+ // ----
+ // fix col_bad's config (again) and RELOAD to fix failure
+ FileUtils.copyFile(getFile("solr/collection1/conf/solrconfig-defaults.xml"),
+ FileUtils.getFile(cc.getSolrHome(), "col_bad", "conf", "solrconfig.xml"));
+ cc.reload("col_bad");
+
+ assertTrue("Core reload should have changed start time",
+ col_bad_old_start < getCoreStartTime(cc, "col_bad"));
+
+
+ // check that we have the cores we expect
+ cores = cc.getCoreNames();
+ assertNotNull("core names is null", cores);
+ assertEquals("wrong number of cores", 2, cores.size());
+ assertTrue("col_ok not found", cores.contains("col_ok"));
+ assertTrue("col_bad not found", cores.contains("col_bad"));
+
+ // check that we have the failures we expect
+ failures = cc.getCoreInitFailures();
+ assertNotNull("core failures is a null map", failures);
+ assertEquals("wrong number of core failures", 1, failures.size());
+
+ cc.shutdown();
+
+ }
+
+ private long getCoreStartTime(final CoreContainer cc, final String name) {
+ try (SolrCore tmp = cc.getCore(name)) {
+ return tmp.getStartTime();
+ }
+ }
}
diff --git a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
index 95caf0edb27..96c7f5288cc 100644
--- a/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
+++ b/solr/core/src/test/org/apache/solr/core/TestCoreDiscovery.java
@@ -140,8 +140,6 @@ public class TestCoreDiscovery extends SolrTestCaseJ4 {
CoreContainer cc = init();
try {
- assertEquals(ConfigSolrXmlOld.DEFAULT_DEFAULT_CORE_NAME,
- cc.getDefaultCoreName());
TestLazyCores.checkInCores(cc, "core1");
TestLazyCores.checkNotInCores(cc, "lazy1", "core2", "collection1");
diff --git a/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java b/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java
index 9768221785e..b38ec0681b9 100644
--- a/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java
+++ b/solr/core/src/test/org/apache/solr/core/TestImplicitCoreProperties.java
@@ -1,7 +1,6 @@
package org.apache.solr.core;
import org.apache.solr.SolrTestCaseJ4;
-import java.io.File;
import org.junit.Test;
/*
@@ -22,17 +21,16 @@ import org.junit.Test;
*/
public class TestImplicitCoreProperties extends SolrTestCaseJ4 {
- public static final String SOLRXML =
- "";
-
@Test
public void testImplicitPropertiesAreSubstitutedInSolrConfig() {
- CoreContainer cc = createCoreContainer(TEST_HOME(), SOLRXML);
+ CoreContainer cc
+ = createCoreContainer("collection1", "data", "solrconfig-implicitproperties.xml", "schema.xml");
+
try {
assertQ(req("q", "*:*")
, "//str[@name='dummy1'][.='collection1']"
- , "//str[@name='dummy2'][.='data"+File.separator+"']"
+ , "//str[@name='dummy2'][.='data']"
, "//str[@name='dummy3'][.='solrconfig-implicitproperties.xml']"
, "//str[@name='dummy4'][.='schema.xml']"
, "//str[@name='dummy5'][.='false']"
diff --git a/solr/core/src/test/org/apache/solr/core/TestLazyCores.java b/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
index befd579993b..e15dcb63212 100644
--- a/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
+++ b/solr/core/src/test/org/apache/solr/core/TestLazyCores.java
@@ -17,9 +17,10 @@ package org.apache.solr.core;
* limitations under the License.
*/
-import org.apache.commons.lang.StringUtils;
+import com.google.common.collect.ImmutableList;
import org.apache.commons.codec.Charsets;
import org.apache.commons.io.FileUtils;
+import org.apache.commons.lang.StringUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CoreAdminParams;
@@ -31,9 +32,7 @@ import org.apache.solr.response.SolrQueryResponse;
import org.apache.solr.update.AddUpdateCommand;
import org.apache.solr.update.CommitUpdateCommand;
import org.apache.solr.update.UpdateHandler;
-import org.apache.solr.util.TestHarness;
-import org.junit.Before;
-import org.junit.BeforeClass;
+import org.apache.solr.util.ReadOnlyCoresLocator;
import org.junit.Test;
import java.io.File;
@@ -48,18 +47,7 @@ import java.util.regex.Pattern;
public class TestLazyCores extends SolrTestCaseJ4 {
- @BeforeClass
- public static void beforeClass() throws Exception {
- initCore("solrconfig-minimal.xml", "schema-tiny.xml");
- }
-
private File solrHomeDirectory;
-
- @Before
- @Override
- public void setUp() throws Exception {
- super.setUp();
- }
private CoreContainer init() throws Exception {
solrHomeDirectory = createTempDir().toFile();
@@ -69,17 +57,7 @@ public class TestLazyCores extends SolrTestCaseJ4 {
}
SolrResourceLoader loader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
-
- File solrXml = new File(solrHomeDirectory, "solr.xml");
- FileUtils.write(solrXml, LOTS_SOLR_XML, Charsets.UTF_8.toString());
- ConfigSolrXmlOld config = (ConfigSolrXmlOld) ConfigSolr.fromFile(loader, solrXml);
-
- CoresLocator locator = new SolrXMLCoresLocator.NonPersistingLocator(LOTS_SOLR_XML, config);
-
-
- final CoreContainer cores = new CoreContainer(loader, config, locator);
- cores.load();
- return cores;
+ return createCoreContainer(new LazyCoreTestConfig(loader));
}
@Test
@@ -172,14 +150,16 @@ public class TestLazyCores extends SolrTestCaseJ4 {
// Now just insure that the normal searching on "collection1" finds _0_ on the same query that found _2_ above.
// Use of makeReq above and req below is tricky, very tricky.
+ SolrCore collection1 = cc.getCore("collection1");
assertQ("test raw query",
- req("q", "{!raw f=v_t}hello", "wt", "xml")
+ makeReq(collection1, "q", "{!raw f=v_t}hello", "wt", "xml")
, "//result[@numFound='0']"
);
checkInCores(cc, "collectionLazy4");
core4.close();
+ collection1.close();
} finally {
cc.shutdown();
}
@@ -411,72 +391,6 @@ public class TestLazyCores extends SolrTestCaseJ4 {
}
}
-
- //Make sure persisting not-loaded lazy cores is done. See SOLR-4347
-
- @Test
- public void testPersistence() throws Exception {
- final CoreContainer cc = init();
- try {
- copyMinConf(new File(solrHomeDirectory, "core1"));
- copyMinConf(new File(solrHomeDirectory, "core2"));
- copyMinConf(new File(solrHomeDirectory, "core3"));
- copyMinConf(new File(solrHomeDirectory, "core4"));
-
- final CoreDescriptor cd1 = buildCoreDescriptor(cc, "core1", "./core1")
- .isTransient(true).loadOnStartup(true).build();
- final CoreDescriptor cd2 = buildCoreDescriptor(cc, "core2", "./core2")
- .isTransient(true).loadOnStartup(false).build();
- final CoreDescriptor cd3 = buildCoreDescriptor(cc, "core3", "./core3")
- .isTransient(false).loadOnStartup(true).build();
- final CoreDescriptor cd4 = buildCoreDescriptor(cc, "core4", "./core4")
- .isTransient(false).loadOnStartup(false).build();
-
-
- SolrCore core1 = cc.create(cd1);
- SolrCore core2 = cc.create(cd2);
- SolrCore core3 = cc.create(cd3);
- SolrCore core4 = cc.create(cd4);
-
- SolrXMLCoresLocator.NonPersistingLocator locator =
- (SolrXMLCoresLocator.NonPersistingLocator) cc.getCoresLocator();
-
- TestHarness.validateXPath(locator.xml,
- "/solr/cores/core[@name='collection1']",
- "/solr/cores/core[@name='collectionLazy2']",
- "/solr/cores/core[@name='collectionLazy3']",
- "/solr/cores/core[@name='collectionLazy4']",
- "/solr/cores/core[@name='collectionLazy5']",
- "/solr/cores/core[@name='collectionLazy6']",
- "/solr/cores/core[@name='collectionLazy7']",
- "/solr/cores/core[@name='collectionLazy8']",
- "/solr/cores/core[@name='collectionLazy9']",
- "/solr/cores/core[@name='core1']",
- "/solr/cores/core[@name='core2']",
- "/solr/cores/core[@name='core3']",
- "/solr/cores/core[@name='core4']",
- "13=count(/solr/cores/core)");
-
- removeOne(cc, "collectionLazy2");
- removeOne(cc, "collectionLazy3");
- removeOne(cc, "collectionLazy4");
- removeOne(cc, "collectionLazy5");
- removeOne(cc, "collectionLazy6");
- removeOne(cc, "collectionLazy7");
- removeOne(cc, "core1");
- removeOne(cc, "core2");
- removeOne(cc, "core3");
- removeOne(cc, "core4");
-
- // now test that unloading a core means the core is not persisted
- TestHarness.validateXPath(locator.xml, "3=count(/solr/cores/core)");
-
- } finally {
- cc.shutdown();
- }
- }
-
-
// Test that transient cores
// 1> produce errors as appropriate when the config or schema files are foo'd
// 2> "self heal". That is, if the problem is corrected can the core be reloaded and used?
@@ -627,12 +541,8 @@ public class TestLazyCores extends SolrTestCaseJ4 {
SolrResourceLoader loader = new SolrResourceLoader(solrHomeDirectory.getAbsolutePath());
ConfigSolrXml config = (ConfigSolrXml) ConfigSolr.fromFile(loader, solrXml);
- CoresLocator locator = new CorePropertiesLocator(solrHomeDirectory.getAbsolutePath());
-
// OK this should succeed, but at the end we should have recorded a series of errors.
- final CoreContainer cores = new CoreContainer(loader, config, locator);
- cores.load();
- return cores;
+ return createCoreContainer(config);
}
// We want to see that the core "heals itself" if an un-corrupted file is written to the directory.
@@ -669,9 +579,6 @@ public class TestLazyCores extends SolrTestCaseJ4 {
}
}
- private void removeOne(CoreContainer cc, String coreName) {
- cc.unload(coreName);
- }
public static void checkNotInCores(CoreContainer cc, String... nameCheck) {
Collection names = cc.getCoreNames();
for (String name : nameCheck) {
@@ -712,26 +619,51 @@ public class TestLazyCores extends SolrTestCaseJ4 {
return StringUtils.join(args, File.separator);
}
- private final static String LOTS_SOLR_XML = " " +
- " " +
- " " +
+ public static class LazyCoreTestConfig extends ConfigSolr {
- " " +
+ public LazyCoreTestConfig(SolrResourceLoader loader) {
+ super(loader, null);
+ }
- " " +
+ static CoreDescriptor makeCoreDescriptor(CoreContainer cc, String coreName, String instanceDir, String isTransient, String loadOnStartup) {
+ return new CoreDescriptor(cc, coreName, instanceDir,
+ CoreDescriptor.CORE_TRANSIENT, isTransient,
+ CoreDescriptor.CORE_LOADONSTARTUP, loadOnStartup);
+ }
- " " +
+ @Override
+ public CoresLocator getCoresLocator() {
+ return new ReadOnlyCoresLocator() {
+ @Override
+ public List discover(CoreContainer cc) {
+ return ImmutableList.of(
+ new CoreDescriptor(cc, "collection1", "collection1"),
+ makeCoreDescriptor(cc, "collectionLazy2", "collection2", "true", "true"),
+ makeCoreDescriptor(cc, "collectionLazy3", "collection3", "on", "false"),
+ makeCoreDescriptor(cc, "collectionLazy4", "collection4", "false", "false"),
+ makeCoreDescriptor(cc, "collectionLazy5", "collection5", "false", "true"),
+ makeCoreDescriptor(cc, "collectionLazy6", "collection6", "true", "false"),
+ makeCoreDescriptor(cc, "collectionLazy7", "collection7", "true", "false"),
+ makeCoreDescriptor(cc, "collectionLazy8", "collection8", "true", "false"),
+ makeCoreDescriptor(cc, "collectionLazy9", "collection9", "true", "false")
+ );
+ }
+ };
+ }
- " " +
+ @Override
+ public PluginInfo getShardHandlerFactoryPluginInfo() {
+ return null;
+ }
- " " +
+ @Override
+ protected String getProperty(CfgProp key) {
+ switch (key) {
+ case SOLR_TRANSIENTCACHESIZE:
+ return "4";
+ }
+ return null;
+ }
+ }
- " " +
-
- " " +
-
- " " +
-
- " " +
- "";
}
diff --git a/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java b/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java
index 778b23b14ef..849146800c7 100644
--- a/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java
+++ b/solr/core/src/test/org/apache/solr/core/TestShardHandlerFactory.java
@@ -38,13 +38,4 @@ public class TestShardHandlerFactory extends SolrTestCaseJ4 {
cc.shutdown();
}
- public void testOldXML() throws Exception {
- CoreContainer cc = CoreContainer.createAndLoad(TEST_HOME(), new File(TEST_HOME(), "solr-shardhandler-old.xml"));
- ShardHandlerFactory factory = cc.getShardHandlerFactory();
- assertTrue(factory instanceof MockShardHandlerFactory);
- NamedList args = ((MockShardHandlerFactory)factory).args;
- assertEquals("myMagicRequiredValue", args.get("myMagicRequiredParameter"));
- factory.close();
- cc.shutdown();
- }
}
diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java
index 443f71cbab6..49500093228 100644
--- a/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java
+++ b/solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java
@@ -18,30 +18,10 @@ package org.apache.solr.core;
*/
-import java.io.File;
-import java.io.IOException;
-import java.io.StringReader;
-import java.nio.charset.StandardCharsets;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.SortedMap;
-import java.util.TreeMap;
-import java.util.concurrent.TimeUnit;
-
import com.google.common.collect.ImmutableList;
import org.apache.commons.io.FileUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.client.solrj.impl.CloudSolrClient;
-import org.apache.solr.common.cloud.DocCollection;
-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.handler.TestBlobHandler;
import org.apache.solr.handler.TestSolrConfigHandlerConcurrent;
import org.apache.solr.util.RestTestBase;
import org.apache.solr.util.RestTestHarness;
@@ -54,6 +34,19 @@ import org.restlet.ext.servlet.ServerServlet;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.text.MessageFormat;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.concurrent.TimeUnit;
+
import static org.apache.solr.core.ConfigOverlay.getObjectByPath;
import static org.apache.solr.handler.TestBlobHandler.getAsString;
diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
index 4327ec0a4ac..9855bcd10fd 100644
--- a/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
+++ b/solr/core/src/test/org/apache/solr/core/TestSolrXml.java
@@ -88,8 +88,6 @@ public class TestSolrXml extends SolrTestCaseJ4 {
assertEquals("trans cache size", 66, cfg.getTransientCacheSize());
assertEquals("zk client timeout", 77, cfg.getZkClientTimeout());
assertEquals("zk host", "testZkHost", cfg.getZkHost());
- assertEquals("persistent", true, cfg.isPersistent());
- assertEquals("core admin path", ConfigSolr.DEFAULT_CORE_ADMIN_PATH, cfg.getAdminPath());
}
// Test a few property substitutions that happen to be in solr-50-all.xml.
diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java b/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java
deleted file mode 100644
index 2e43e61f3ca..00000000000
--- a/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistence.java
+++ /dev/null
@@ -1,613 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.solr.core;
-
-import com.carrotsearch.randomizedtesting.rules.SystemPropertiesRestoreRule;
-import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang.StringUtils;
-import org.apache.lucene.util.IOUtils;
-import org.apache.lucene.util.LuceneTestCase;
-import org.apache.solr.SolrTestCaseJ4;
-import org.apache.solr.common.params.CoreAdminParams;
-import org.apache.solr.handler.admin.CoreAdminHandler;
-import org.apache.solr.response.SolrQueryResponse;
-import org.apache.solr.util.TestHarness;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.RuleChain;
-import org.junit.rules.TestRule;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.SAXException;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.nio.charset.StandardCharsets;
-import java.util.ArrayList;
-import java.util.List;
-
-import static org.hamcrest.core.Is.is;
-
-public class TestSolrXmlPersistence extends SolrTestCaseJ4 {
-
- private File solrHomeDirectory = createTempDir().toFile();
-
- @Rule
- public TestRule solrTestRules =
- RuleChain.outerRule(new SystemPropertiesRestoreRule());
-
- @Before
- public void setupTest() {
- solrHomeDirectory = createTempDir(LuceneTestCase.getTestClass().getSimpleName()).toFile();
- }
-
- private CoreContainer init(String solrXmlString, String... subDirs) throws Exception {
-
- for (String s : subDirs) {
- copyMinConf(new File(solrHomeDirectory, s));
- }
-
- File solrXml = new File(solrHomeDirectory, "solr.xml");
- FileUtils.write(solrXml, solrXmlString, IOUtils.UTF_8);
-
- final CoreContainer cores = createCoreContainer(solrHomeDirectory.getAbsolutePath(), solrXmlString);
- return cores;
- }
-
-
- // take a solr.xml with system vars in , and and tags that have system
- // variables defined. Insure that after persisting solr.xml, they're all still there as ${} syntax.
- // Also insure that nothing extra crept in.
- @Test
- public void testSystemVars() throws Exception {
- //Set these system props in order to insure that we don't write out the values rather than the ${} syntax.
- System.setProperty("solr.zkclienttimeout", "93");
- System.setProperty("solrconfig", "solrconfig.xml");
- System.setProperty("schema", "schema.xml");
- System.setProperty("zkHostSet", "localhost:9983");
-
- CoreContainer cc = init(SOLR_XML_LOTS_SYSVARS, "SystemVars1", "SystemVars2");
- try {
- origMatchesPersist(cc, SOLR_XML_LOTS_SYSVARS);
- } finally {
- cc.shutdown();
- }
- }
-
- @Test
- public void testReload() throws Exception {
- // Whether the core is transient or not can make a difference.
- doReloadTest("SystemVars2");
- doReloadTest("SystemVars1");
-
- }
-
- private void doReloadTest(String which) throws Exception {
-
- CoreContainer cc = init(SOLR_XML_LOTS_SYSVARS, "SystemVars1", "SystemVars2");
- try {
- final CoreAdminHandler admin = new CoreAdminHandler(cc);
- SolrQueryResponse resp = new SolrQueryResponse();
- admin.handleRequestBody
- (req(CoreAdminParams.ACTION,
- CoreAdminParams.CoreAdminAction.RELOAD.toString(),
- CoreAdminParams.CORE, which),
- resp);
- assertNull("Exception on reload", resp.getException());
-
- origMatchesPersist(cc, SOLR_XML_LOTS_SYSVARS);
- } finally {
- cc.shutdown();
- if (solrHomeDirectory.exists()) {
- FileUtils.deleteDirectory(solrHomeDirectory);
- }
- }
-
- }
-
- @Test
- public void testRename() throws Exception {
- doTestRename("SystemVars1");
- doTestRename("SystemVars2");
- }
-
- private void doTestRename(String which) throws Exception {
- CoreContainer cc = init(SOLR_XML_LOTS_SYSVARS, "SystemVars1", "SystemVars2");
- SolrXMLCoresLocator.NonPersistingLocator locator
- = (SolrXMLCoresLocator.NonPersistingLocator) cc.getCoresLocator();
-
- try {
- final CoreAdminHandler admin = new CoreAdminHandler(cc);
- SolrQueryResponse resp = new SolrQueryResponse();
- admin.handleRequestBody
- (req(CoreAdminParams.ACTION,
- CoreAdminParams.CoreAdminAction.RENAME.toString(),
- CoreAdminParams.CORE, which,
- CoreAdminParams.OTHER, "RenamedCore"),
- resp);
- assertNull("Exception on rename", resp.getException());
-
- // OK, Assure that if I change everything that has been renamed with the original value for the core, it matches
- // the old list
- String[] persistList = getAllNodes();
- String[] expressions = new String[persistList.length];
-
- for (int idx = 0; idx < persistList.length; ++idx) {
- expressions[idx] = persistList[idx].replaceAll("RenamedCore", which);
- }
-
- //assertXmlFile(origXml, expressions);
- TestHarness.validateXPath(SOLR_XML_LOTS_SYSVARS, expressions);
-
- // Now the other way, If I replace the original name in the original XML file with "RenamedCore", does it match
- // what was persisted?
- persistList = getAllNodes(SOLR_XML_LOTS_SYSVARS);
- expressions = new String[persistList.length];
- for (int idx = 0; idx < persistList.length; ++idx) {
- // /solr/cores/core[@name='SystemVars1' and @collection='${collection:collection1}']
- expressions[idx] = persistList[idx].replace("@name='" + which + "'", "@name='RenamedCore'");
- }
-
- TestHarness.validateXPath(locator.xml, expressions);
-
- } finally {
- cc.shutdown();
- if (solrHomeDirectory.exists()) {
- FileUtils.deleteDirectory(solrHomeDirectory);
- }
- }
- }
-
- @Test
- public void testSwap() throws Exception {
- doTestSwap("SystemVars1", "SystemVars2");
- doTestSwap("SystemVars2", "SystemVars1");
- }
-
- /*
- Count the number of times substring appears in target
- */
- private int countOccurrences(String target, String substring) {
- int pos = -1, count = 0;
- while ((pos = target.indexOf(substring, pos + 1)) != -1) {
- count++;
- }
- return count;
- }
-
- private void doTestSwap(String from, String to) throws Exception {
- CoreContainer cc = init(SOLR_XML_LOTS_SYSVARS, "SystemVars1", "SystemVars2");
- SolrXMLCoresLocator.NonPersistingLocator locator
- = (SolrXMLCoresLocator.NonPersistingLocator) cc.getCoresLocator();
-
- int coreCount = countOccurrences(locator.xml, " expressions = new ArrayList<>(); // XPATH and value for all elements in the indicated XML
- DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory
- .newInstance();
- DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
- Document document = docBuilder.parse(is);
-
- Node root = document.getDocumentElement();
- gatherNodes(root, expressions, "");
- return expressions.toArray(new String[expressions.size()]);
- }
-
- private String[] getAllNodes() throws ParserConfigurationException, IOException, SAXException {
- return getAllNodes(new FileInputStream(new File(solrHomeDirectory, "solr.xml")));
- }
-
- private String[] getAllNodes(String xmlString) throws ParserConfigurationException, IOException, SAXException {
- return getAllNodes(new ByteArrayInputStream(xmlString.getBytes(StandardCharsets.UTF_8)));
- }
-
- /*
- private void assertSolrXmlFile(String... xpathExpressions) throws IOException, SAXException {
- assertXmlFile(new File(solrHomeDirectory, "solr.xml"), xpathExpressions);
- }
- */
-
- // Note this is pretty specialized for a solr.xml file because working with the DOM is such a pain.
-
- private static List qualified = new ArrayList() {{
- add("core");
- add("property");
- add("int");
- add("str");
- add("long");
- add("property");
- }};
-
- private static List addText = new ArrayList() {{
- add("int");
- add("str");
- add("long");
- }};
-
- // path is the path to parent node
-
- private void gatherNodes(Node node, List expressions, String path) {
-
- String nodeName = node.getNodeName();
- String thisPath = path + "/" + nodeName;
- //Parent[@id='1']/Children/child[@name]
- // Add in the xpaths for verification of any attributes.
- NamedNodeMap attrs = node.getAttributes();
- String qualifier = "";
- if (attrs.getLength() > 0) {
- // Assemble the prefix for qualifying all of the attributes with the same name
- if (qualified.contains(nodeName)) {
- qualifier = "@name='" + node.getAttributes().getNamedItem("name").getTextContent() + "'";
- }
-
- for (int idx = 0; idx < attrs.getLength(); ++idx) {
-
- Node attr = attrs.item(idx);
- if (StringUtils.isNotBlank(qualifier) && "name".equals(attr.getNodeName())) {
- continue; // Already added "name" attribute in qualifier string.
- }
- if (StringUtils.isNotBlank(qualifier)) {
- // Create [@name="stuff" and @attrib="value"] fragment
- expressions.add(thisPath +
- "[" + qualifier + " and @" + attr.getNodeName() + "='" + attr.getTextContent() + "']");
-
- } else {
- // Create [@attrib="value"] fragment
- expressions.add(thisPath +
- "[" + qualifier + " @" + attr.getNodeName() + "='" + attr.getTextContent() + "']");
- }
- }
- }
- // Now add the text for special nodes
- // a[normalize-space(text())='somesite']
- if (addText.contains(nodeName)) {
- expressions.add(thisPath + "[" + qualifier + " and text()='" + node.getTextContent() + "']");
- }
- // Now collect all the child element nodes.
- NodeList nodeList = node.getChildNodes();
- for (int i = 0; i < nodeList.getLength(); i++) {
-
- Node currentNode = nodeList.item(i);
- if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
- if (StringUtils.isNotBlank(qualifier)) {
- gatherNodes(currentNode, expressions, thisPath + "[" + qualifier + "]");
- } else {
- gatherNodes(currentNode, expressions, thisPath);
- }
- }
- }
- }
-
- public static String SOLR_XML_LOTS_SYSVARS =
- "\n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " \n" +
- " ${socketTimeout:120000} \n" +
- " ${connTimeout:15000} \n" +
- " ${arbitrarySysValue:foobar}\n" +
- " \n" +
- " \n" +
- "";
-
-
- private static String SOLR_XML_MINIMAL =
- "\n" +
- " \n" +
- " \n" +
- " \n" +
- "";
-
-}
diff --git a/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistor.java b/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistor.java
deleted file mode 100644
index f93117f54fb..00000000000
--- a/solr/core/src/test/org/apache/solr/core/TestSolrXmlPersistor.java
+++ /dev/null
@@ -1,127 +0,0 @@
-package org.apache.solr.core;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import java.io.File;
-import java.io.IOException;
-import java.util.List;
-
-import org.apache.commons.io.FileUtils;
-import org.apache.solr.SolrTestCaseJ4;
-import org.junit.Test;
-
-import com.google.common.collect.ImmutableList;
-
-public class TestSolrXmlPersistor extends SolrTestCaseJ4 {
-
- private static final List EMPTY_CD_LIST = ImmutableList.builder().build();
-
- @Test
- public void selfClosingCoresTagIsPersisted() {
-
- final String solrxml = "";
-
- SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(solrxml, null);
- assertEquals("", persistor.buildSolrXML(EMPTY_CD_LIST));
-
- }
-
- @Test
- public void emptyCoresTagIsPersisted() {
- final String solrxml = "";
-
- SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(solrxml, null);
- assertEquals("", persistor.buildSolrXML(EMPTY_CD_LIST));
- }
-
- @Test
- public void emptySolrXmlIsPersisted() {
- final String solrxml = "";
-
- SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(solrxml, null);
- assertEquals("", persistor.buildSolrXML(EMPTY_CD_LIST));
- }
-
- @Test
- public void simpleCoreDescriptorIsPersisted() throws IOException {
-
- final String solrxml = "";
-
- final File solrHomeDirectory = createTempDir().toFile();
-
- copyMinFullSetup(solrHomeDirectory);
-
- CoreContainer cc = new CoreContainer(solrHomeDirectory.getAbsolutePath());
-
- final CoreDescriptor cd = new CoreDescriptor(cc, "testcore",
- "instance/dir/");
- List cds = ImmutableList.of(cd);
-
- SolrXMLCoresLocator persistor = new SolrXMLCoresLocator(solrxml, null);
- String xml = persistor.buildSolrXML(cds);
-
- assertTrue(xml.contains(""));
- assertTrue(xml.contains("name=\"testcore\""));
- assertTrue(xml.contains("instanceDir=\"instance/dir/\""));
- assertTrue(xml.contains(""));
- }
-
- @Test
- public void shardHandlerInfoIsPersisted() {
-
- final String solrxml =
- "" +
- "" +
- "" +
- "" +
- "${socketTimeout:500}" +
- "arbitraryValue" +
- "" +
- "" +
- "";
-
- SolrXMLCoresLocator locator = new SolrXMLCoresLocator(solrxml, null);
- assertTrue(locator.getTemplate().contains("{{CORES_PLACEHOLDER}}"));
- assertTrue(locator.getTemplate().contains("" +
- "" +
- "" +
- "" +
- "" +
- "";
-
- SolrXMLCoresLocator locator = new SolrXMLCoresLocator(solrxml, null);
- assertTrue(locator.getTemplate().contains("{{CORES_PLACEHOLDER}}"));
- assertTrue(locator.getTemplate().contains(" reloadCore(SolrClient s, String core) throws Exception {
-
+
ModifiableSolrParams params = new ModifiableSolrParams();
params.set("action","reload");
params.set("core", core);
params.set("qt","/admin/cores");
QueryRequest req = new QueryRequest(params);
- NamedList