lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject lucene-solr:branch_7x: SOLR-11372: tests: add refine to TestCloudJSONFacetJoinDomain
Date Wed, 20 Sep 2017 10:23:34 GMT
Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 80d0ea17f -> 8c969c540


SOLR-11372: tests: add refine to TestCloudJSONFacetJoinDomain


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/8c969c54
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/8c969c54
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/8c969c54

Branch: refs/heads/branch_7x
Commit: 8c969c5400a45152a6471408a545ebde95ab6959
Parents: 80d0ea1
Author: yonik <yonik@apache.org>
Authored: Wed Sep 20 06:21:55 2017 -0400
Committer: yonik <yonik@apache.org>
Committed: Wed Sep 20 06:23:30 2017 -0400

----------------------------------------------------------------------
 .../cloud/TestCloudJSONFacetJoinDomain.java     | 51 ++++++++++++++++++--
 1 file changed, 47 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/8c969c54/solr/core/src/test/org/apache/solr/cloud/TestCloudJSONFacetJoinDomain.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestCloudJSONFacetJoinDomain.java b/solr/core/src/test/org/apache/solr/cloud/TestCloudJSONFacetJoinDomain.java
index 48de49a..b104c92 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudJSONFacetJoinDomain.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudJSONFacetJoinDomain.java
@@ -88,7 +88,7 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
   @BeforeClass
   private static void createMiniSolrCloudCluster() throws Exception {
     // sanity check constants
-    assertTrue("bad test constants: must have UNIQUE_FIELD_VALS < FACET_LIMIT since refinement
not currently supported",
+    assertTrue("bad test constants: must have UNIQUE_FIELD_VALS < FACET_LIMIT to get accurate
counts without refinements",
                UNIQUE_FIELD_VALS < FACET_LIMIT);
     assertTrue("bad test constants: some suffixes will never be tested",
                (STR_FIELD_SUFFIXES.length < MAX_FIELD_NUM) && (INT_FIELD_SUFFIXES.length
< MAX_FIELD_NUM));
@@ -135,6 +135,12 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
         }
       }
       CLOUD_CLIENT.add(doc);
+      if (random().nextInt(100) < 1) {
+        CLOUD_CLIENT.commit();  // commit 1% of the time to create new segments
+      }
+      if (random().nextInt(100) < 5) {
+        CLOUD_CLIENT.add(doc);  // duplicate the doc 5% of the time to create deleted docs
+      }
     }
     CLOUD_CLIENT.commit();
   }
@@ -299,7 +305,7 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
 
   public void testRandom() throws Exception {
 
-    final int numIters = atLeast(3);
+    final int numIters = atLeast(10);
     for (int iter = 0; iter < numIters; iter++) {
       assertFacetCountsAreCorrect(TermFacet.buildRandomFacets(), buildRandomQuery());
     }
@@ -449,8 +455,45 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
      * recursively generates the <code>json.facet</code> param value to use for
testing this facet
      */
     private CharSequence toJSONFacetParamValue() {
-      // NOTE: since refinement isn't supported, we have to use the max cardinality of the
field as limit
-      StringBuilder sb = new StringBuilder("{ type:terms, field:" + field + ", limit: " +
FACET_LIMIT);
+      int limit = random().nextInt(FACET_LIMIT*2);
+      String limitStr = ", limit:" + limit;
+      if (limit >= FACET_LIMIT && random().nextBoolean()) {
+        limitStr = ", limit:-1"; // unlimited
+      } else if (limit == 10 && random().nextBoolean()) {
+        limitStr=""; // don't specify limit since it's the default
+      }
+
+      int overrequest = -1;
+      switch(random().nextInt(10)) {
+        case 0:
+        case 1:
+        case 2:
+        case 3:
+          overrequest = 0; // 40% of the time, no overrequest to better stress refinement
+          break;
+        case 4:
+        case 5:
+          overrequest = random().nextInt(FACET_LIMIT);
+          break;
+        case 6:
+          overrequest = random().nextInt(Integer.MAX_VALUE);
+          break;
+        default: break;
+      }
+      String overrequestStr = overrequest==-1 ? "" : ", overrequest:"+overrequest;
+
+      boolean refine = (overrequest >= 0 && (long)limit + overrequest < FACET_LIMIT)
+          || (overrequest < 0 && limit < FACET_LIMIT) // don't assume how much
overrequest we do by default, just check the limit
+          || random().nextInt(10)==0; // once in a while, turn on refinement even when it
isn't needed.
+
+      // refine = false; // NOTE: Uncomment this line to see if refinement testing is adequate
(should get fails occasionally)
+      String refineStr=", refine:" + refine;
+      if (!refine) {
+        // if refine==false, don't specify it sometimes (it's the default)
+        if (random().nextBoolean()) refineStr="";
+      }
+
+      StringBuilder sb = new StringBuilder("{ type:terms, field:" + field + limitStr + overrequestStr
+ refineStr);
       if (! subFacets.isEmpty()) {
         sb.append(", facet:");
         sb.append(toJSONFacetParamValue(subFacets));


Mime
View raw message