From a40ee0f5bcdc9a9c2245c8641c63b245576c6fb4 Mon Sep 17 00:00:00 2001 From: Erick Erickson Date: Sat, 16 Nov 2013 00:53:41 +0000 Subject: [PATCH] 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 --- .../handler/admin/ShowFileRequestHandler.java | 2 +- .../solr/cloud/TestModifyConfFiles.java | 18 +++++++++++++++++ .../solr/schema/ModifyConfFileTest.java | 20 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) diff --git a/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java b/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java index 2c5a361b613..224723904b5 100644 --- a/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java +++ b/solr/core/src/java/org/apache/solr/handler/admin/ShowFileRequestHandler.java @@ -297,7 +297,7 @@ public class ShowFileRequestHandler extends RequestHandlerBase SimpleOrderedMap fileInfo = new SimpleOrderedMap(); files.add(f, fileInfo); - List fchildren = zkClient.getChildren(adminFile, null, true); + List fchildren = zkClient.getChildren(adminFile + "/" + f, null, true); if (fchildren.size() > 0) { fileInfo.add("directory", true); } else { diff --git a/solr/core/src/test/org/apache/solr/cloud/TestModifyConfFiles.java b/solr/core/src/test/org/apache/solr/cloud/TestModifyConfFiles.java index 56eaf5833fa..f633b77ee7c 100644 --- a/solr/core/src/test/org/apache/solr/cloud/TestModifyConfFiles.java +++ b/solr/core/src/test/org/apache/solr/cloud/TestModifyConfFiles.java @@ -20,6 +20,8 @@ import org.apache.solr.client.solrj.impl.HttpSolrServer; import org.apache.solr.client.solrj.request.QueryRequest; import org.apache.solr.common.cloud.SolrZkClient; 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 { @@ -91,6 +93,22 @@ public class TestModifyConfFiles extends AbstractFullDistribZkTestBase { 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.", contents.indexOf("Some bogus stuff for a test.") != -1); + + params = new ModifiableSolrParams(); + request = new QueryRequest(params); + request.setPath("/admin/file"); + NamedList 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")); } } diff --git a/solr/core/src/test/org/apache/solr/schema/ModifyConfFileTest.java b/solr/core/src/test/org/apache/solr/schema/ModifyConfFileTest.java index 9ce47685160..60420887dbb 100644 --- a/solr/core/src/test/org/apache/solr/schema/ModifyConfFileTest.java +++ b/solr/core/src/test/org/apache/solr/schema/ModifyConfFileTest.java @@ -24,6 +24,8 @@ import org.apache.solr.SolrTestCaseJ4; import org.apache.solr.common.params.ModifiableSolrParams; import org.apache.solr.common.util.ContentStream; 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.SolrCore; import org.apache.solr.request.LocalSolrQueryRequest; @@ -110,6 +112,24 @@ public class ModifyConfFileTest extends SolrTestCaseJ4 { "conf/velocity/test.vm")); 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 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(); } finally { cc.shutdown();