dsmiley commented on a change in pull request #624: URL: https://github.com/apache/solr/pull/624#discussion_r805495496
########## File path: solr/core/src/test/org/apache/solr/search/TestFiltersQueryCaching.java ########## @@ -0,0 +1,127 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.solr.search; + +import java.util.Map; + +import org.apache.solr.SolrTestCaseJ4; +import org.apache.solr.core.SolrCore; +import org.apache.solr.metrics.MetricsMap; +import org.apache.solr.metrics.SolrMetricManager; +import org.junit.BeforeClass; +import org.junit.Test; + +import static org.apache.solr.common.util.Utils.fromJSONString; + +/** + * Verify caching impacts of FiltersQParser and FilterQuery + */ +public class TestFiltersQueryCaching extends SolrTestCaseJ4 { + + private static final int NUM_DOCS = 20; + + @BeforeClass + public static void beforeClass() throws Exception { + initCore("solrconfig.xml", "schema_latest.xml"); + createIndex(); + } + + public static void createIndex() { + for (int i = 0; i < NUM_DOCS; i++) { + assertU(adoc("id", Integer.toString(i), "field_s", "d" + i)); + if (random().nextInt(NUM_DOCS) == 0) { + assertU(commit()); // sometimes make multiple segments + } + } + assertU(commit()); + } + + private static final String MATCH_ALL_DOCS_QUERY = "*:*"; + + private static Map<String, Object> coreToFilterCacheMetrics(SolrCore core) { + return ((MetricsMap)((SolrMetricManager.GaugeWrapper<?>)core.getCoreMetricManager().getRegistry() + .getMetrics().get("CACHE.searcher.filterCache")).getGauge()).getValue(); + } + + private static long coreToInserts(SolrCore core) { + return (long)((MetricsMap)((SolrMetricManager.GaugeWrapper<?>)core + .getCoreMetricManager().getRegistry().getMetrics().get("CACHE.searcher.filterCache")).getGauge()) + .getValue().get("inserts"); + } + + private static long getNumFound(String response) { Review comment: ````java assertJQ(req("q", "WHATEVER"), "/response/numFound==0" ); ```` -- 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]
