Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 28B02200D0C for ; Wed, 20 Sep 2017 12:23:36 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 271C91609E2; Wed, 20 Sep 2017 10:23:36 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 660AC1609E1 for ; Wed, 20 Sep 2017 12:23:35 +0200 (CEST) Received: (qmail 55047 invoked by uid 500); 20 Sep 2017 10:23:34 -0000 Mailing-List: contact commits-help@lucene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@lucene.apache.org Delivered-To: mailing list commits@lucene.apache.org Received: (qmail 55038 invoked by uid 99); 20 Sep 2017 10:23:34 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Sep 2017 10:23:34 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 62DF5F1741; Wed, 20 Sep 2017 10:23:34 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: yonik@apache.org To: commits@lucene.apache.org Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: lucene-solr:branch_7x: SOLR-11372: tests: add refine to TestCloudJSONFacetJoinDomain Date: Wed, 20 Sep 2017 10:23:34 +0000 (UTC) archived-at: Wed, 20 Sep 2017 10:23:36 -0000 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 Authored: Wed Sep 20 06:21:55 2017 -0400 Committer: yonik 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 json.facet 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));