SOLR-5906: Collection create API ignores property.instanceDir parameter

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1581341 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2014-03-25 14:20:36 +00:00
parent 1152acb681
commit 436fc3149a
3 changed files with 49 additions and 5 deletions

View File

@ -335,6 +335,9 @@ Bug Fixes
* SOLR-5905: CollapsingQParserPlugin throws a NPE if required 'field' param is missing.
(Spyros Kapnissis via shalin)
* SOLR-5906: Collection create API ignores property.instanceDir parameter.
(Varun Thacker, shalin)
Other Changes
---------------------

View File

@ -503,11 +503,6 @@ public class CoreAdminHandler extends RequestHandlerBase {
String name = checkNotEmpty(params.get(CoreAdminParams.NAME),
"Missing parameter [" + CoreAdminParams.NAME + "]");
String instancedir = params.get(CoreAdminParams.INSTANCE_DIR);
if (StringUtils.isEmpty(instancedir)) {
instancedir = name; // will be resolved later against solr.home
//instancedir = container.getSolrHome() + "/" + name;
}
Properties coreProps = new Properties();
for (String param : paramToProp.keySet()) {
@ -526,6 +521,14 @@ public class CoreAdminHandler extends RequestHandlerBase {
coreProps.setProperty(propName, propValue);
}
String instancedir = params.get(CoreAdminParams.INSTANCE_DIR);
if (StringUtils.isEmpty(instancedir) && coreProps.getProperty(CoreAdminParams.INSTANCE_DIR) != null) {
instancedir = coreProps.getProperty(CoreAdminParams.INSTANCE_DIR);
} else if (StringUtils.isEmpty(instancedir)){
instancedir = name; // will be resolved later against solr.home
//instancedir = container.getSolrHome() + "/" + name;
}
return new CoreDescriptor(container, name, instancedir, coreProps, params);
}

View File

@ -22,6 +22,7 @@ import org.apache.lucene.util.IOUtils;
import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.params.CoreAdminParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.core.CorePropertiesLocator;
import org.apache.solr.response.SolrQueryResponse;
import org.junit.AfterClass;
@ -192,6 +193,43 @@ public class CoreAdminCreateDiscoverTest extends SolrTestCaseJ4 {
}
@Test
public void testInstanceDirAsPropertyParam() throws Exception {
setupCore("testInstanceDirAsPropertyParam-XYZ", true);
// make sure workDir is different even if core name is used as instanceDir
File workDir = new File(solrHomeDirectory, "testInstanceDirAsPropertyParam-XYZ");
File data = new File(workDir, "data");
// Create one core
SolrQueryResponse resp = new SolrQueryResponse();
admin.handleRequestBody
(req(CoreAdminParams.ACTION,
CoreAdminParams.CoreAdminAction.CREATE.toString(),
CoreAdminParams.NAME, "testInstanceDirAsPropertyParam",
"property.instanceDir", workDir.getAbsolutePath(),
CoreAdminParams.CONFIG, "solrconfig_ren.xml",
CoreAdminParams.SCHEMA, "schema_ren.xml",
CoreAdminParams.DATA_DIR, data.getAbsolutePath()),
resp);
assertNull("Exception on create", resp.getException());
resp = new SolrQueryResponse();
admin.handleRequestBody
(req(CoreAdminParams.ACTION,
CoreAdminParams.CoreAdminAction.STATUS.toString(),
CoreAdminParams.CORE, "testInstanceDirAsPropertyParam"),
resp);
NamedList status = (NamedList) resp.getValues().get("status");
assertNotNull(status);
NamedList coreProps = (NamedList) status.get("testInstanceDirAsPropertyParam");
assertNotNull(status);
String instanceDir = (String) coreProps.get("instanceDir");
assertNotNull(instanceDir);
assertEquals("Instance dir does not match param given in property.instanceDir syntax", workDir.getAbsolutePath(), new File(instanceDir).getAbsolutePath());
}
@Test
public void testCreateSavesRegProps() throws Exception {