epugh commented on code in PR #2247:
URL: https://github.com/apache/solr/pull/2247#discussion_r1483277681


##########
solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java:
##########
@@ -1011,4 +1011,61 @@ public static LinkedHashMapWriter getRespMap(String 
path, RestTestHarness restHa
       return new LinkedHashMapWriter<>();
     }
   }
+
+  public void testCacheDisableSolrConfig() throws Exception {
+    restTestHarness.setServerProvider(() -> getBaseUrl());
+    MapWriter confMap = getRespMap("/admin/metrics", restTestHarness);
+    assertNotNull(
+        confMap._get(
+            asList("metrics", "solr.core.collection1", 
"CACHE.searcher.fieldValueCache"), null));
+    // Here documentCache is disabled at initialization in SolrConfig
+    assertNull(
+        confMap._get(
+            asList("metrics", "solr.core.collection1", 
"CACHE.searcher.documentCache"), null));
+  }
+
+  public void testSetPropertyCacheSize() throws Exception{
+    RESTfulServerProvider oldProvider = restTestHarness.getServerProvider();
+    // Changing cache size
+    String payload = "{\n" + " 'set-property' : { 'query.documentCache.size': 
399} \n" + " }";
+    restTestHarness.setServerProvider(oldProvider);
+    runConfigCommand(restTestHarness, "/config", payload);

Review Comment:
   not sure I understand the behavior of the "oldProvider"?  Looks like we get 
it and then set it again?



##########
solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java:
##########
@@ -1011,4 +1011,61 @@ public static LinkedHashMapWriter getRespMap(String 
path, RestTestHarness restHa
       return new LinkedHashMapWriter<>();
     }
   }
+
+  public void testCacheDisableSolrConfig() throws Exception {
+    restTestHarness.setServerProvider(() -> getBaseUrl());
+    MapWriter confMap = getRespMap("/admin/metrics", restTestHarness);
+    assertNotNull(
+        confMap._get(
+            asList("metrics", "solr.core.collection1", 
"CACHE.searcher.fieldValueCache"), null));
+    // Here documentCache is disabled at initialization in SolrConfig
+    assertNull(
+        confMap._get(
+            asList("metrics", "solr.core.collection1", 
"CACHE.searcher.documentCache"), null));
+  }
+
+  public void testSetPropertyCacheSize() throws Exception{
+    RESTfulServerProvider oldProvider = restTestHarness.getServerProvider();
+    // Changing cache size
+    String payload = "{\n" + " 'set-property' : { 'query.documentCache.size': 
399} \n" + " }";
+    restTestHarness.setServerProvider(oldProvider);
+    runConfigCommand(restTestHarness, "/config", payload);
+    MapWriter overlay = getRespMap("/config/overlay", restTestHarness);
+    assertEquals("399", 
overlay._getStr("overlay/props/query/documentCache/size", null));
+    // Setting size only will not enable the cache
+    restTestHarness.setServerProvider(() -> getBaseUrl());
+    MapWriter confMap = getRespMap("/admin/metrics", restTestHarness);
+    assertNull(
+            confMap._get(
+                    asList("metrics", "solr.core.collection1", 
"CACHE.searcher.documentCache"), null));
+    restTestHarness.setServerProvider(oldProvider);
+  }
+  public void testSetPropertyEnableAndDisableCache() throws Exception {
+    RESTfulServerProvider oldProvider = restTestHarness.getServerProvider();
+    // Enabling Cache
+    String payload = "{\n" + " 'set-property' : { 
'query.documentCache.enabled': true} \n" + " }";

Review Comment:
   i think, for readablity, can we remove the extra `\n` formatting, or, if we 
want it to be multi line, then format it over mulitple liens?  (I look forward 
to the version of Java that lets us have multiple line strings!!!)



##########
solr/core/src/test/org/apache/solr/core/TestSolrConfigHandler.java:
##########
@@ -1011,4 +1011,61 @@ public static LinkedHashMapWriter getRespMap(String 
path, RestTestHarness restHa
       return new LinkedHashMapWriter<>();
     }
   }
+
+  public void testCacheDisableSolrConfig() throws Exception {
+    restTestHarness.setServerProvider(() -> getBaseUrl());
+    MapWriter confMap = getRespMap("/admin/metrics", restTestHarness);
+    assertNotNull(
+        confMap._get(
+            asList("metrics", "solr.core.collection1", 
"CACHE.searcher.fieldValueCache"), null));
+    // Here documentCache is disabled at initialization in SolrConfig
+    assertNull(
+        confMap._get(
+            asList("metrics", "solr.core.collection1", 
"CACHE.searcher.documentCache"), null));
+  }
+
+  public void testSetPropertyCacheSize() throws Exception{
+    RESTfulServerProvider oldProvider = restTestHarness.getServerProvider();
+    // Changing cache size
+    String payload = "{\n" + " 'set-property' : { 'query.documentCache.size': 
399} \n" + " }";
+    restTestHarness.setServerProvider(oldProvider);
+    runConfigCommand(restTestHarness, "/config", payload);
+    MapWriter overlay = getRespMap("/config/overlay", restTestHarness);
+    assertEquals("399", 
overlay._getStr("overlay/props/query/documentCache/size", null));
+    // Setting size only will not enable the cache
+    restTestHarness.setServerProvider(() -> getBaseUrl());
+    MapWriter confMap = getRespMap("/admin/metrics", restTestHarness);
+    assertNull(
+            confMap._get(
+                    asList("metrics", "solr.core.collection1", 
"CACHE.searcher.documentCache"), null));
+    restTestHarness.setServerProvider(oldProvider);
+  }
+  public void testSetPropertyEnableAndDisableCache() throws Exception {
+    RESTfulServerProvider oldProvider = restTestHarness.getServerProvider();
+    // Enabling Cache
+    String payload = "{\n" + " 'set-property' : { 
'query.documentCache.enabled': true} \n" + " }";
+    restTestHarness.setServerProvider(oldProvider);
+    runConfigCommand(restTestHarness, "/config", payload);
+    MapWriter overlay = getRespMap("/config/overlay", restTestHarness);
+    assertEquals("true", 
overlay._getStr("overlay/props/query/documentCache/enabled", null));
+    restTestHarness.setServerProvider(() -> getBaseUrl());

Review Comment:
   like wise not sure we need this?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to