mirror of https://github.com/apache/lucene.git
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 git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1681901 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
c7db078677
commit
b70192e95c
|
@ -126,18 +126,23 @@ public class TestSolr4Spatial2 extends SolrTestCaseJ4 {
|
||||||
assertEquals("1", cache.getStatistics().get("cumulative_hits").toString());
|
assertEquals("1", cache.getStatistics().get("cumulative_hits").toString());
|
||||||
|
|
||||||
assertEquals("1 segment",
|
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
|
// add new segment
|
||||||
assertU(adoc("id", "3"));
|
assertU(adoc("id", "3"));
|
||||||
|
|
||||||
assertU(commit()); // sometimes merges (to one seg), sometimes won't
|
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
|
// can still find the same document
|
||||||
assertJQ(sameReq, "/response/numFound==1", "/response/docs/[0]/id=='1'");
|
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.
|
// 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());
|
// 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:
|
// Now try to see if heatmaps work:
|
||||||
assertJQ(req("q", "*:*", "facet", "true", FacetParams.FACET_HEATMAP, fieldName, "json.nl", "map"),
|
assertJQ(req("q", "*:*", "facet", "true", FacetParams.FACET_HEATMAP, fieldName, "json.nl", "map"),
|
||||||
|
@ -145,4 +150,14 @@ public class TestSolr4Spatial2 extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue