SOLR-5448: ShowFileRequestHandler treats everything as Directory, when in Cloud-Mode

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1542436 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Erick Erickson 2013-11-16 00:53:41 +00:00
parent 7f2b8bc419
commit a40ee0f5bc
3 changed files with 39 additions and 1 deletions

View File

@ -297,7 +297,7 @@ public class ShowFileRequestHandler extends RequestHandlerBase
SimpleOrderedMap<Object> fileInfo = new SimpleOrderedMap<Object>(); SimpleOrderedMap<Object> fileInfo = new SimpleOrderedMap<Object>();
files.add(f, fileInfo); files.add(f, fileInfo);
List<String> fchildren = zkClient.getChildren(adminFile, null, true); List<String> fchildren = zkClient.getChildren(adminFile + "/" + f, null, true);
if (fchildren.size() > 0) { if (fchildren.size() > 0) {
fileInfo.add("directory", true); fileInfo.add("directory", true);
} else { } else {

View File

@ -20,6 +20,8 @@ import org.apache.solr.client.solrj.impl.HttpSolrServer;
import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.client.solrj.request.QueryRequest;
import org.apache.solr.common.cloud.SolrZkClient; import org.apache.solr.common.cloud.SolrZkClient;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
public class TestModifyConfFiles extends AbstractFullDistribZkTestBase { public class TestModifyConfFiles extends AbstractFullDistribZkTestBase {
@ -91,6 +93,22 @@ public class TestModifyConfFiles extends AbstractFullDistribZkTestBase {
contents = new String(zkClient.getData("/configs/conf1/velocity/test.vm", null, null, true), "UTF-8"); contents = new String(zkClient.getData("/configs/conf1/velocity/test.vm", null, null, true), "UTF-8");
assertTrue("Should have found new content in a velocity/test.vm.", assertTrue("Should have found new content in a velocity/test.vm.",
contents.indexOf("Some bogus stuff for a test.") != -1); contents.indexOf("Some bogus stuff for a test.") != -1);
params = new ModifiableSolrParams();
request = new QueryRequest(params);
request.setPath("/admin/file");
NamedList<Object> res = client.request(request);
NamedList files = (NamedList)res.get("files");
assertNotNull("Should have gotten files back", files);
SimpleOrderedMap schema = (SimpleOrderedMap)files.get("schema.xml");
assertNotNull("Should have a schema returned", schema);
assertNull("Schema.xml should not be a directory", schema.get("directory"));
SimpleOrderedMap velocity = (SimpleOrderedMap)files.get("velocity");
assertNotNull("Should have velocity dir returned", velocity);
assertTrue("Velocity should be a directory", (boolean)velocity.get("directory"));
} }
} }

View File

@ -24,6 +24,8 @@ import org.apache.solr.SolrTestCaseJ4;
import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.params.ModifiableSolrParams;
import org.apache.solr.common.util.ContentStream; import org.apache.solr.common.util.ContentStream;
import org.apache.solr.common.util.ContentStreamBase; import org.apache.solr.common.util.ContentStreamBase;
import org.apache.solr.common.util.NamedList;
import org.apache.solr.common.util.SimpleOrderedMap;
import org.apache.solr.core.CoreContainer; import org.apache.solr.core.CoreContainer;
import org.apache.solr.core.SolrCore; import org.apache.solr.core.SolrCore;
import org.apache.solr.request.LocalSolrQueryRequest; import org.apache.solr.request.LocalSolrQueryRequest;
@ -110,6 +112,24 @@ public class ModifyConfFileTest extends SolrTestCaseJ4 {
"conf/velocity/test.vm")); "conf/velocity/test.vm"));
assertEquals("Schema contents should have changed!", "Some bogus stuff for a test.", contents); assertEquals("Schema contents should have changed!", "Some bogus stuff for a test.", contents);
streams.clear();
params = params();
locReq = new LocalSolrQueryRequest(core, params);
core.execute(handler, locReq, rsp);
NamedList<Object> res = rsp.getValues();
NamedList files = (NamedList)res.get("files");
assertNotNull("Should have gotten files back", files);
SimpleOrderedMap schema = (SimpleOrderedMap)files.get("schema.xml");
assertNotNull("Should have a schema returned", schema);
assertNull("Schema.xml should not be a directory", schema.get("directory"));
SimpleOrderedMap velocity = (SimpleOrderedMap)files.get("velocity");
assertNotNull("Should have velocity dir returned", velocity);
assertTrue("Velocity should be a directory", (boolean)velocity.get("directory"));
core.close(); core.close();
} finally { } finally {
cc.shutdown(); cc.shutdown();