mirror of https://github.com/apache/lucene.git
SOLR-14413 fix unit test to use delayed handler (#2189)
This commit is contained in:
parent
6711eb7571
commit
a429b969d8
|
@ -33,7 +33,7 @@
|
||||||
<searchComponent name="delayingSearchComponent"
|
<searchComponent name="delayingSearchComponent"
|
||||||
class="org.apache.solr.search.DelayingSearchComponent"/>
|
class="org.apache.solr.search.DelayingSearchComponent"/>
|
||||||
|
|
||||||
<requestHandler name="/select" class="solr.SearchHandler">
|
<requestHandler name="/delayed" class="solr.SearchHandler">
|
||||||
<arr name="first-components">
|
<arr name="first-components">
|
||||||
<str>delayingSearchComponent</str>
|
<str>delayingSearchComponent</str>
|
||||||
</arr>
|
</arr>
|
||||||
|
@ -47,12 +47,12 @@
|
||||||
|
|
||||||
<!-- deep paging better play nice with caching -->
|
<!-- deep paging better play nice with caching -->
|
||||||
<query>
|
<query>
|
||||||
<!-- no wautowarming, it screws up our ability to sanity check cache stats in tests -->
|
<!-- no autowarming, it screws up our ability to sanity check cache stats in tests -->
|
||||||
<filterCache size="50" initialSize="50" autowarmCount="0"/>
|
<filterCache size="50" initialSize="50" autowarmCount="0"/>
|
||||||
<queryResultCache size="50" initialSize="50" autowarmCount="0"/>
|
<queryResultCache size="50" initialSize="50" autowarmCount="0"/>
|
||||||
<queryResultWindowSize>50</queryResultWindowSize>
|
<queryResultWindowSize>50</queryResultWindowSize>
|
||||||
<queryResultMaxDocsCached>500</queryResultMaxDocsCached>
|
<queryResultMaxDocsCached>500</queryResultMaxDocsCached>
|
||||||
<!-- randomized so we excersize cursors using various paths in SolrIndexSearcher -->
|
<!-- randomized so we exercise cursors using various paths in SolrIndexSearcher -->
|
||||||
<useFilterForSortedQuery>${solr.test.useFilterForSortedQuery}</useFilterForSortedQuery>
|
<useFilterForSortedQuery>${solr.test.useFilterForSortedQuery}</useFilterForSortedQuery>
|
||||||
</query>
|
</query>
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@ import org.apache.solr.metrics.MetricsMap;
|
||||||
import org.apache.solr.metrics.SolrMetricManager;
|
import org.apache.solr.metrics.SolrMetricManager;
|
||||||
import org.apache.solr.request.SolrQueryRequest;
|
import org.apache.solr.request.SolrQueryRequest;
|
||||||
import org.apache.solr.search.CursorMark;
|
import org.apache.solr.search.CursorMark;
|
||||||
|
import org.apache.solr.util.LogLevel;
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.BeforeClass;
|
import org.junit.BeforeClass;
|
||||||
|
|
||||||
|
@ -57,6 +58,7 @@ import static org.apache.solr.common.util.Utils.fromJSONString;
|
||||||
public class CursorPagingTest extends SolrTestCaseJ4 {
|
public class CursorPagingTest extends SolrTestCaseJ4 {
|
||||||
|
|
||||||
/** solrconfig.xml file name, shared with other cursor related tests */
|
/** solrconfig.xml file name, shared with other cursor related tests */
|
||||||
|
|
||||||
public final static String TEST_SOLRCONFIG_NAME = "solrconfig-deeppaging.xml";
|
public final static String TEST_SOLRCONFIG_NAME = "solrconfig-deeppaging.xml";
|
||||||
/** schema.xml file name, shared with other cursor related tests */
|
/** schema.xml file name, shared with other cursor related tests */
|
||||||
public final static String TEST_SCHEMAXML_NAME = "schema-sorts.xml";
|
public final static String TEST_SCHEMAXML_NAME = "schema-sorts.xml";
|
||||||
|
@ -139,7 +141,7 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
|
||||||
assertEquals(CURSOR_MARK_START, cursorMark);
|
assertEquals(CURSOR_MARK_START, cursorMark);
|
||||||
|
|
||||||
|
|
||||||
// don't add in order of any field to ensure we aren't inadvertantly
|
// don't add in order of any field to ensure we aren't inadvertently
|
||||||
// counting on internal docid ordering
|
// counting on internal docid ordering
|
||||||
assertU(adoc("id", "9", "str", "c", "float", "-3.2", "int", "42"));
|
assertU(adoc("id", "9", "str", "c", "float", "-3.2", "int", "42"));
|
||||||
assertU(adoc("id", "7", "str", "c", "float", "-3.2", "int", "-1976"));
|
assertU(adoc("id", "7", "str", "c", "float", "-3.2", "int", "-1976"));
|
||||||
|
@ -499,6 +501,7 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
|
||||||
* test that timeAllowed parameter can be used with cursors
|
* test that timeAllowed parameter can be used with cursors
|
||||||
* uses DelayingSearchComponent in solrconfig-deeppaging.xml
|
* uses DelayingSearchComponent in solrconfig-deeppaging.xml
|
||||||
*/
|
*/
|
||||||
|
@LogLevel("org.apache.solr.search.SolrIndexSearcher=ERROR;org.apache.solr.handler.component.SearchHandler=ERROR")
|
||||||
public void testTimeAllowed() throws Exception {
|
public void testTimeAllowed() throws Exception {
|
||||||
String wontExceedTimeout = "10000";
|
String wontExceedTimeout = "10000";
|
||||||
int numDocs = 1000;
|
int numDocs = 1000;
|
||||||
|
@ -521,6 +524,7 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
|
||||||
"fl", "id",
|
"fl", "id",
|
||||||
"sort", "id asc",
|
"sort", "id asc",
|
||||||
"rows", "50",
|
"rows", "50",
|
||||||
|
"qt", "/delayed",
|
||||||
"sleep", "10");
|
"sleep", "10");
|
||||||
|
|
||||||
List<String> foundDocIds = new ArrayList<>();
|
List<String> foundDocIds = new ArrayList<>();
|
||||||
|
@ -533,15 +537,12 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
|
||||||
// execute the query
|
// execute the query
|
||||||
String json = assertJQ(req(params, CURSOR_MARK_PARAM, cursorMark, TIME_ALLOWED, timeAllowed));
|
String json = assertJQ(req(params, CURSOR_MARK_PARAM, cursorMark, TIME_ALLOWED, timeAllowed));
|
||||||
|
|
||||||
@SuppressWarnings({"unchecked"})
|
Map<?, ?> response = (Map<?, ?>) fromJSONString(json);
|
||||||
Map<Object, Object> response = (Map<Object, Object>) fromJSONString(json);
|
Map<?, ?> responseHeader = (Map<?, ?>) response.get("responseHeader");
|
||||||
@SuppressWarnings({"unchecked"})
|
Map<?, ?> responseBody = (Map<?, ?>) response.get("response");
|
||||||
Map<Object, Object> responseHeader = (Map<Object, Object>) response.get("responseHeader");
|
|
||||||
@SuppressWarnings({"unchecked"})
|
|
||||||
Map<Object, Object> responseBody = (Map<Object, Object>) response.get("response");
|
|
||||||
nextCursorMark = (String) response.get(CURSOR_MARK_NEXT);
|
nextCursorMark = (String) response.get(CURSOR_MARK_NEXT);
|
||||||
|
|
||||||
// count occurance of partialResults (confirm at the end at least one)
|
// count occurrence of partialResults (confirm at the end at least one)
|
||||||
if (responseHeader.containsKey("partialResults")) {
|
if (responseHeader.containsKey("partialResults")) {
|
||||||
partialCount++;
|
partialCount++;
|
||||||
}
|
}
|
||||||
|
@ -560,11 +561,10 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
|
||||||
}
|
}
|
||||||
} while (!cursorMark.equals(nextCursorMark));
|
} while (!cursorMark.equals(nextCursorMark));
|
||||||
|
|
||||||
List<String> sortedFoundDocIds = new ArrayList<>();
|
ArrayList<String> sortedFoundDocIds = new ArrayList<>(foundDocIds);
|
||||||
sortedFoundDocIds.addAll(foundDocIds);
|
sortedFoundDocIds.sort(null);
|
||||||
Collections.sort(sortedFoundDocIds);
|
|
||||||
// Note: it is not guaranteed that all docs will be found, because a query may time out
|
// Note: it is not guaranteed that all docs will be found, because a query may time out
|
||||||
// before reaching all segments, this causes documents in the skipped segements to be skipped
|
// before reaching all segments, this causes documents in the skipped segments to be skipped
|
||||||
// in the overall result set as the cursor pages through.
|
// in the overall result set as the cursor pages through.
|
||||||
assertEquals("Should have found last doc id eventually", ids.get(ids.size() -1), foundDocIds.get(foundDocIds.size() -1));
|
assertEquals("Should have found last doc id eventually", ids.get(ids.size() -1), foundDocIds.get(foundDocIds.size() -1));
|
||||||
assertEquals("Documents arrived in sorted order within and between pages", sortedFoundDocIds, foundDocIds);
|
assertEquals("Documents arrived in sorted order within and between pages", sortedFoundDocIds, foundDocIds);
|
||||||
|
@ -576,10 +576,10 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
|
||||||
* test that our assumptions about how caches are affected hold true
|
* test that our assumptions about how caches are affected hold true
|
||||||
*/
|
*/
|
||||||
public void testCacheImpacts() throws Exception {
|
public void testCacheImpacts() throws Exception {
|
||||||
// cursor queryies can't live in the queryResultCache, but independent filters
|
// cursor queries can't live in the queryResultCache, but independent filters
|
||||||
// should still be cached & reused
|
// should still be cached & reused
|
||||||
|
|
||||||
// don't add in order of any field to ensure we aren't inadvertantly
|
// don't add in order of any field to ensure we aren't inadvertently
|
||||||
// counting on internal docid ordering
|
// counting on internal docid ordering
|
||||||
assertU(adoc("id", "9", "str", "c", "float", "-3.2", "int", "42"));
|
assertU(adoc("id", "9", "str", "c", "float", "-3.2", "int", "42"));
|
||||||
assertU(adoc("id", "7", "str", "c", "float", "-3.2", "int", "-1976"));
|
assertU(adoc("id", "7", "str", "c", "float", "-3.2", "int", "-1976"));
|
||||||
|
@ -621,7 +621,7 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
|
||||||
final long postFcHits = (Long) filterCacheStats.getValue().get("hits");
|
final long postFcHits = (Long) filterCacheStats.getValue().get("hits");
|
||||||
|
|
||||||
assertEquals("query cache inserts changed", preQcIn, postQcIn);
|
assertEquals("query cache inserts changed", preQcIn, postQcIn);
|
||||||
// NOTE: use of pure negative filters causees "*:* to be tracked in filterCache
|
// NOTE: use of pure negative filters clauses "*:* to be tracked in filterCache
|
||||||
assertEquals("filter cache did not grow correctly", 3, postFcIn-preFcIn);
|
assertEquals("filter cache did not grow correctly", 3, postFcIn-preFcIn);
|
||||||
assertTrue("filter cache did not have any new cache hits", 0 < postFcHits-preFcHits);
|
assertTrue("filter cache did not have any new cache hits", 0 < postFcHits-preFcHits);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue