From 4ee7fc38907a94f025785ebd388dd372b260913d Mon Sep 17 00:00:00 2001 From: David Smiley Date: Thu, 16 Mar 2017 18:30:57 -0400 Subject: [PATCH] SOLR-10286: fix test; we were writing to read-only dir. Expand solrconfig-managed-schema.xml to have toggle-able elements vis system property flags --- .../conf/solrconfig-managed-schema.xml | 25 ++++++++++++++++ .../apache/solr/search/LargeFieldTest.java | 29 ++++++++----------- 2 files changed, 37 insertions(+), 17 deletions(-) diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-managed-schema.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-managed-schema.xml index 26224ad9b79..c1390c8f8c1 100644 --- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-managed-schema.xml +++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-managed-schema.xml @@ -29,6 +29,31 @@ + + + + + + + + ${enableLazyFieldLoading:false} + + ${solr.ulog.dir:} diff --git a/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java b/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java index d05c69cec6a..09e7e9034de 100644 --- a/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java +++ b/solr/core/src/test/org/apache/solr/search/LargeFieldTest.java @@ -29,6 +29,7 @@ import org.apache.solr.request.SolrQueryRequestBase; import org.apache.solr.response.SolrQueryResponse; import org.apache.solr.schema.IndexSchema; import org.apache.solr.util.RefCounted; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Test; @@ -40,29 +41,17 @@ public class LargeFieldTest extends SolrTestCaseJ4 { @BeforeClass public static void initManagedSchemaCore() throws Exception { - // TODO propose convenience API for this? - // This testing approach means no new solrconfig or schema file or per-test temp solr-home! + // This testing approach means no schema file or per-test temp solr-home! System.setProperty("managed.schema.mutable", "true"); System.setProperty("managed.schema.resourceName", "schema-one-field-no-dynamic-field-unique-key.xml"); System.setProperty("enable.update.log", "false"); + System.setProperty("documentCache.enabled", "true"); + System.setProperty("enableLazyFieldLoading", "true"); + initCore("solrconfig-managed-schema.xml", "ignoredSchemaName?"); - // modify solr config TODO propose more convenient API for this; maybe with JSON-ification of a map - try (SolrQueryRequestBase req = (SolrQueryRequestBase) req()) { - req.getContext().put("httpMethod", "POST"); - req.setContentStreams(Collections.singleton(new ContentStreamBase.StringStream( - "{ 'set-property':{" + - "'query.enableLazyFieldLoading':true, " + - "'query.documentCache.class':'solr.LRUCache'" + - "}}" - ))); - SolrQueryResponse rsp = new SolrQueryResponse(); - h.getCore().execute(h.getCore().getRequestHandler("/config"), req, rsp); - assertNull(rsp.getException()); - } - + // TODO SOLR-10229 will make this easier boolean PERSIST_FALSE = false; // don't write to test resource dir - IndexSchema schema = h.getCore().getLatestSchema(); schema = schema.addFieldTypes(Collections.singletonList( schema.newFieldType("textType", "solr.TextField", // redundant; TODO improve api @@ -78,6 +67,12 @@ public class LargeFieldTest extends SolrTestCaseJ4 { h.getCore().setLatestSchema(schema); } + @AfterClass + public static void afterClass() { + System.clearProperty("documentCache.enabled"); + System.clearProperty("enableLazyFieldLoading"); + } + @Test public void test() throws Exception { // add just one document (docid 0)