You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ab...@apache.org on 2017/07/07 13:43:06 UTC
[25/32] lucene-solr:jira/solr-10996: SOLR-11016: Fix
TestCloudJSONFacetJoinDomain test-only bug
SOLR-11016: Fix TestCloudJSONFacetJoinDomain test-only bug
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/d81daf54
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/d81daf54
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/d81daf54
Branch: refs/heads/jira/solr-10996
Commit: d81daf54b4b567327c6ebde94b2b2eedacf19cd6
Parents: 510608d
Author: Chris Hostetter <ho...@apache.org>
Authored: Thu Jul 6 09:33:20 2017 -0700
Committer: Chris Hostetter <ho...@apache.org>
Committed: Thu Jul 6 09:33:20 2017 -0700
----------------------------------------------------------------------
solr/CHANGES.txt | 2 +
.../cloud/TestCloudJSONFacetJoinDomain.java | 54 ++++++++++++++++----
2 files changed, 45 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d81daf54/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index ddb0337..596e971 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -468,6 +468,8 @@ Other Changes
* SOLR-10967: Cleanup the default configset. The changes involve some documentation corrections, removing the currency
field from the examples and a few dynamic fields (Varun Thacker)
+* SOLR-11016: Fix TestCloudJSONFacetJoinDomain test-only bug (hossman)
+
================== 6.7.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/d81daf54/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 1acf92e..e18312c 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestCloudJSONFacetJoinDomain.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestCloudJSONFacetJoinDomain.java
@@ -23,6 +23,7 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
@@ -39,6 +40,7 @@ import org.apache.solr.client.solrj.impl.CloudSolrClient;
import org.apache.solr.client.solrj.impl.HttpSolrClient;
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.QueryRequest;
+import org.apache.solr.client.solrj.response.QueryResponse;
import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.params.ModifiableSolrParams;
@@ -243,7 +245,6 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
}
}
-
/**
* Test some small, hand crafted, but non-trivial queries that are
* easier to trace/debug then a pure random monstrosity.
@@ -251,6 +252,30 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
*/
public void testBespoke() throws Exception {
+ { // sanity check our test methods can handle a query matching no docs
+ Map<String,TermFacet> facets = new LinkedHashMap<>();
+ TermFacet top = new TermFacet(strfield(9), new JoinDomain(strfield(5), strfield(9), strfield(9)+":[* TO *]"));
+ top.subFacets.put("sub", new TermFacet(strfield(11), new JoinDomain(strfield(8), strfield(8), null)));
+ facets.put("empty_top", top);
+ assertFacetCountsAreCorrect(facets, strfield(7) + ":bogus");
+ }
+
+ { // sanity check our test methods can handle a query where a facet filter prevents any doc from having terms
+ Map<String,TermFacet> facets = new LinkedHashMap<>();
+ TermFacet top = new TermFacet(strfield(9), new JoinDomain(null, null, "-*:*"));
+ top.subFacets.put("sub", new TermFacet(strfield(11), new JoinDomain(strfield(8), strfield(8), null)));
+ facets.put("filtered_top", top);
+ assertFacetCountsAreCorrect(facets, "*:*");
+ }
+
+ { // sanity check our test methods can handle a query where a facet filter prevents any doc from having sub-terms
+ Map<String,TermFacet> facets = new LinkedHashMap<>();
+ TermFacet top = new TermFacet(strfield(9), new JoinDomain(strfield(8), strfield(8), null));
+ top.subFacets.put("sub", new TermFacet(strfield(11), new JoinDomain(null, null, "-*:*")));
+ facets.put("filtered_top", top);
+ assertFacetCountsAreCorrect(facets, "*:*");
+ }
+
{ // strings
Map<String,TermFacet> facets = new LinkedHashMap<>();
TermFacet top = new TermFacet(strfield(9), new JoinDomain(strfield(5), strfield(9), strfield(9)+":[* TO *]"));
@@ -274,11 +299,8 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
assertFacetCountsAreCorrect(facets, "("+strfield(7)+":6 OR "+strfield(9)+":6 OR "+strfield(6)+":19 OR "+strfield(0)+":11)");
}
-
-
}
-
public void testRandom() throws Exception {
final int numIters = atLeast(3);
@@ -320,21 +342,31 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
final SolrParams initParams = SolrParams.wrapAppended(facetParams, baseParams);
log.info("Doing full run: {}", initParams);
-
- NamedList topResponse = null;
+
+ QueryResponse rsp = null;
+ // JSON Facets not (currently) available from QueryResponse...
+ NamedList topNamedList = null;
try {
- topResponse = getRandClient(random()).request(new QueryRequest(initParams));
- assertNotNull(initParams + " is null response?", topResponse);
+ rsp = (new QueryRequest(initParams)).process(getRandClient(random()));
+ assertNotNull(initParams + " is null rsp?", rsp);
+ topNamedList = rsp.getResponse();
+ assertNotNull(initParams + " is null topNamedList?", topNamedList);
} catch (Exception e) {
throw new RuntimeException("init query failed: " + initParams + ": " +
e.getMessage(), e);
}
try {
- final NamedList facetResponse = (NamedList) topResponse.get("facets");
+ final NamedList facetResponse = (NamedList) topNamedList.get("facets");
assertNotNull("null facet results?", facetResponse);
+ assertEquals("numFound mismatch with top count?",
+ rsp.getResults().getNumFound(), ((Number)facetResponse.get("count")).longValue());
+ if (0 == rsp.getResults().getNumFound()) {
+ // when the query matches nothing, we should expect no top level facets
+ expected = Collections.emptyMap();
+ }
assertFacetCountsAreCorrect(expected, baseParams, facetResponse);
} catch (AssertionError e) {
- throw new AssertionError(initParams + " ===> " + topResponse + " --> " + e.getMessage(), e);
+ throw new AssertionError(initParams + " ===> " + topNamedList + " --> " + e.getMessage(), e);
} finally {
log.info("Ending full run");
}
@@ -373,7 +405,7 @@ public class TestCloudJSONFacetJoinDomain extends SolrCloudTestCase {
}
}
}
- assertTrue("facets have unexpeted keys left over: " + actualFacetResponse,
+ assertTrue("facets have unexpected keys left over: " + actualFacetResponse,
// should alwasy be a count, maybe a 'val' if we're a subfacet
(actualFacetResponse.size() == expected.size() + 1) ||
(actualFacetResponse.size() == expected.size() + 2));