SOLR-14595: add AwaitsFix test to TestJsonFacetRefinement demonstrating problem, and work around to randomized testing in TestCloudJSONFacetSKGEquiv

This commit is contained in:
Chris Hostetter 2020-07-05 13:28:08 -07:00
parent 3642aa3d4e
commit fea6c1b9da
2 changed files with 60 additions and 3 deletions

View File

@ -307,7 +307,7 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
}
}
/**
* Test some small, hand crafted, but non-trivial queries that are
* easier to trace/debug then a pure random monstrosity.
@ -717,7 +717,7 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
final String facetField = randomFacetField(random());
return new TermFacet(facetField,
map("limit", randomLimitParam(random()),
"overrequest", randomOverrequestParam(random()),
"overrequest", randomOverrequestParam(random(), sort),
"prefix", randomPrefixParam(random(), facetField),
"perSeg", randomPerSegParam(random()),
"sort", sort,
@ -896,11 +896,25 @@ public class TestCloudJSONFacetSKGEquiv extends SolrCloudTestCase {
/**
* picks a random value for the "overrequest" param, biased in favor of interesting test cases.
* <p>
* <b>NOTE:</b> due to variations in overrequest behavior betewen <code>metod:enum<code> and other
* processors (see <a href="https://issues.apache.org/jira/browse/SOLR-14595">SOLR-14595</a>) this
* method takes in the "sort" param and returns a constant value of <code>0</code> if the sort is
* <code>index asc</code> to ensure that the set of candidate buckets considered during merging
* (and refinement) is consistent regardless of what processor is used (and/or what sort is used
* on the parent facet)
* </p>
*
* @return a number to specify in the request, or null to specify nothing (trigger default behavior)
* @see #UNIQUE_FIELD_VALS
* @see <a href="https://issues.apache.org/jira/browse/SOLR-14595">SOLR-14595</a>
*/
public static Integer randomOverrequestParam(final Random r) {
public static Integer randomOverrequestParam(final Random r, final String sort) {
if ("index asc".equals(sort)) {
return 0; // test work around for SOLR-14595
}
switch(r.nextInt(10)) {
case 0:
case 1:

View File

@ -1472,4 +1472,47 @@ public class TestJsonFacetRefinement extends SolrTestCaseHS {
} // end method loop
}
@AwaitsFix(bugUrl="https://issues.apache.org/jira/browse/SOLR-14595")
public void testIndexAscRefineConsistency() throws Exception {
initServers();
final Client client = servers.getClient(random().nextInt());
client.queryDefaults().set("shards", servers.getShards(), "debugQuery", Boolean.toString(random().nextBoolean()));
List<SolrClient> clients = client.getClientProvider().all();
assertTrue(clients.size() >= 3);
final SolrClient c0 = clients.get(0);
final SolrClient c1 = clients.get(1);
final SolrClient c2 = clients.get(2);
client.deleteByQuery("*:*", null);
int id = 0;
c0.add(sdoc("id", id++, "cat_s", "Z", "price_i", 10));
c1.add(sdoc("id", id++, "cat_s", "Z", "price_i", -5000));
c1.add(sdoc("id", id++, "cat_s", "X", "price_i", 2, "child_s", "A" ));
c2.add(sdoc("id", id++, "cat_s", "X", "price_i", 2, "child_s", "B" ));
c2.add(sdoc("id", id++, "cat_s", "X", "price_i", 2, "child_s", "C" ));
client.commit();
// TODO once SOLR-14595 is fixed, modify test to check full EnumSet, not just these two...
for (String m : Arrays.asList("smart", "enum")) {
client.testJQ(params("q", "*:*", "rows", "0", "json.facet", "{"
+ " cat : { type:terms, field:cat_s, limit:1, refine:true,"
+ " overrequest:0, " // to trigger parent refinement given small data set
+ " sort:'sum desc', "
+ " facet: { sum : 'sum(price_i)', "
+ " child_"+m+" : { "
+ " type:terms, field:child_s, limit:1, refine:true,"
+ " sort:'index asc', method:" + m + " } "
+ " }} }"
)
, "facets=={ count:5"
+ ", cat:{buckets:[ { val:X, count:3, sum:6.0, "
+ " child_"+m+":{buckets:[{val:A, count:1}]}}]}}"
);
}
}
}