You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by md...@apache.org on 2021/01/11 18:15:52 UTC

[lucene-solr] branch master updated: SOLR-14413 fix unit test to use delayed handler (#2189)

This is an automated email from the ASF dual-hosted git repository.

mdrob pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new a429b96  SOLR-14413 fix unit test to use delayed handler (#2189)
a429b96 is described below

commit a429b969d87090c9cc1ec787553528bece0d809e
Author: Mike Drob <md...@apache.org>
AuthorDate: Mon Jan 11 12:15:30 2021 -0600

    SOLR-14413 fix unit test to use delayed handler (#2189)
---
 .../collection1/conf/solrconfig-deeppaging.xml     |  6 ++---
 .../src/test/org/apache/solr/CursorPagingTest.java | 30 +++++++++++-----------
 2 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/solr/core/src/test-files/solr/collection1/conf/solrconfig-deeppaging.xml b/solr/core/src/test-files/solr/collection1/conf/solrconfig-deeppaging.xml
index 698342c..6825dab 100644
--- a/solr/core/src/test-files/solr/collection1/conf/solrconfig-deeppaging.xml
+++ b/solr/core/src/test-files/solr/collection1/conf/solrconfig-deeppaging.xml
@@ -33,7 +33,7 @@
   <searchComponent name="delayingSearchComponent"
                    class="org.apache.solr.search.DelayingSearchComponent"/>
 
-  <requestHandler name="/select" class="solr.SearchHandler">
+  <requestHandler name="/delayed" class="solr.SearchHandler">
     <arr name="first-components">
       <str>delayingSearchComponent</str>
     </arr>
@@ -47,12 +47,12 @@
 
   <!-- deep paging better play nice with caching -->
   <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"/>
     <queryResultCache size="50" initialSize="50" autowarmCount="0"/>
     <queryResultWindowSize>50</queryResultWindowSize>
     <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>
   </query>
 
diff --git a/solr/core/src/test/org/apache/solr/CursorPagingTest.java b/solr/core/src/test/org/apache/solr/CursorPagingTest.java
index f601cb0..169aaa7 100644
--- a/solr/core/src/test/org/apache/solr/CursorPagingTest.java
+++ b/solr/core/src/test/org/apache/solr/CursorPagingTest.java
@@ -42,6 +42,7 @@ import org.apache.solr.metrics.MetricsMap;
 import org.apache.solr.metrics.SolrMetricManager;
 import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.search.CursorMark;
+import org.apache.solr.util.LogLevel;
 import org.junit.After;
 import org.junit.BeforeClass;
 
@@ -57,6 +58,7 @@ import static org.apache.solr.common.util.Utils.fromJSONString;
 public class CursorPagingTest extends SolrTestCaseJ4 {
 
   /** solrconfig.xml file name, shared with other cursor related tests */
+
   public final static String TEST_SOLRCONFIG_NAME = "solrconfig-deeppaging.xml";
   /** schema.xml file name, shared with other cursor related tests */
   public final static String TEST_SCHEMAXML_NAME = "schema-sorts.xml";
@@ -139,7 +141,7 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
     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
     assertU(adoc("id", "9", "str", "c", "float", "-3.2", "int", "42"));
     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
    * 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 {
     String wontExceedTimeout = "10000";
     int numDocs = 1000;
@@ -521,6 +524,7 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
         "fl", "id",
         "sort", "id asc",
         "rows", "50",
+        "qt", "/delayed",
         "sleep", "10");
 
     List<String> foundDocIds = new ArrayList<>();
@@ -533,15 +537,12 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
         // execute the query
         String json = assertJQ(req(params, CURSOR_MARK_PARAM, cursorMark, TIME_ALLOWED, timeAllowed));
 
-        @SuppressWarnings({"unchecked"})
-        Map<Object, Object> response = (Map<Object, Object>) fromJSONString(json);
-        @SuppressWarnings({"unchecked"})
-        Map<Object, Object> responseHeader = (Map<Object, Object>) response.get("responseHeader");
-        @SuppressWarnings({"unchecked"})
-        Map<Object, Object> responseBody = (Map<Object, Object>) response.get("response");
+        Map<?, ?> response = (Map<?, ?>) fromJSONString(json);
+        Map<?, ?> responseHeader = (Map<?, ?>) response.get("responseHeader");
+        Map<?, ?> responseBody = (Map<?, ?>) response.get("response");
         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")) {
           partialCount++;
         }
@@ -560,11 +561,10 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
       }
     } while (!cursorMark.equals(nextCursorMark));
 
-    List<String> sortedFoundDocIds = new ArrayList<>();
-    sortedFoundDocIds.addAll(foundDocIds);
-    Collections.sort(sortedFoundDocIds);
+    ArrayList<String> sortedFoundDocIds = new ArrayList<>(foundDocIds);
+    sortedFoundDocIds.sort(null);
     // 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.
     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);
@@ -576,10 +576,10 @@ public class CursorPagingTest extends SolrTestCaseJ4 {
    * test that our assumptions about how caches are affected hold true
    */
   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
 
-    // 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
     assertU(adoc("id", "9", "str", "c", "float", "-3.2", "int", "42"));
     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");
     
     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);
     assertTrue("filter cache did not have any new cache hits", 0 < postFcHits-preFcHits);