You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ds...@apache.org on 2015/05/27 05:55:58 UTC
svn commit: r1681901 -
/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
Author: dsmiley
Date: Wed May 27 03:55:57 2015
New Revision: 1681901
URL: http://svn.apache.org/r1681901
Log:
SOLR-7594: Fix test bug on RptWithGeometryField's cache state
The bug was that I can't compare the segment count; I should compare cache keys
Modified:
lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java?rev=1681901&r1=1681900&r2=1681901&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/search/TestSolr4Spatial2.java Wed May 27 03:55:57 2015
@@ -126,18 +126,23 @@ public class TestSolr4Spatial2 extends S
assertEquals("1", cache.getStatistics().get("cumulative_hits").toString());
assertEquals("1 segment",
- 1, ((SolrIndexSearcher) h.getCore().getInfoRegistry().get("searcher")).getRawReader().leaves().size());
+ 1, getSearcher().getRawReader().leaves().size());
+ // Get key of first leaf reader -- this one contains the match for sure.
+ Object leafKey1 = getFirstLeafReaderKey();
+
// add new segment
assertU(adoc("id", "3"));
+
assertU(commit()); // sometimes merges (to one seg), sometimes won't
- boolean newSeg =
- (((SolrIndexSearcher)h.getCore().getInfoRegistry().get("searcher")).getRawReader().leaves().size() > 1);
// can still find the same document
assertJQ(sameReq, "/response/numFound==1", "/response/docs/[0]/id=='1'");
- // when there are new segments, we accumulate another hit. This tests the cache was not blown away on commit.
- assertEquals(newSeg ? "2" : "1", cache.getStatistics().get("cumulative_hits").toString());
+ // When there are new segments, we accumulate another hit. This tests the cache was not blown away on commit.
+ // Checking equality for the first reader's cache key indicates wether the cache should still be valid.
+ Object leafKey2 = getFirstLeafReaderKey();
+ assertEquals(leafKey1.equals(leafKey2) ? "2" : "1", cache.getStatistics().get("cumulative_hits").toString());
+
// Now try to see if heatmaps work:
assertJQ(req("q", "*:*", "facet", "true", FacetParams.FACET_HEATMAP, fieldName, "json.nl", "map"),
@@ -145,4 +150,14 @@ public class TestSolr4Spatial2 extends S
}
+ protected SolrIndexSearcher getSearcher() {
+ // neat trick; needn't deal with the hassle RefCounted
+ return (SolrIndexSearcher) h.getCore().getInfoRegistry().get("searcher");
+ }
+
+
+ protected Object getFirstLeafReaderKey() {
+ return getSearcher().getRawReader().leaves().get(0).reader().getCoreCacheKey();
+ }
+
}