Fix a silly test bug that was assuming numFound=0 would mean no facet results, even though these facet requests always use an explicit query domain.

Also fix the expected/actual facet response checks to ensure there are no 'extra' keys, since not checking that is how the the previous problem slipt through the cracks until it just hapened to affect a testBespoke query (because the randomized index didn't have any matches for that query) and manifested as 0 buckets being checked
This commit is contained in:
Chris Hostetter 2018-06-21 12:05:26 -07:00
parent bc9ac994a4
commit 08e3141f6c
1 changed files with 19 additions and 4 deletions

View File

@ -23,6 +23,7 @@ import java.nio.file.Paths;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
@ -330,11 +331,13 @@ public class TestCloudJSONFacetSKG extends SolrCloudTestCase {
assertNotNull("null facet results?", facetResponse); assertNotNull("null facet results?", facetResponse);
assertEquals("numFound mismatch with top count?", assertEquals("numFound mismatch with top count?",
rsp.getResults().getNumFound(), ((Number)facetResponse.get("count")).longValue()); 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 // Note: even if the query has numFound=0, our explicit background query domain should
expected = Collections.emptyMap(); // still force facet results
} // (even if the background query matches nothing, that just means there will be no
// buckets in those facets)
assertFacetSKGsAreCorrect(maxBucketsToCheck, expected, baseParams, facetResponse); assertFacetSKGsAreCorrect(maxBucketsToCheck, expected, baseParams, facetResponse);
} catch (AssertionError e) { } catch (AssertionError e) {
throw new AssertionError(initParams + " ===> " + topNamedList + " --> " + e.getMessage(), e); throw new AssertionError(initParams + " ===> " + topNamedList + " --> " + e.getMessage(), e);
} finally { } finally {
@ -390,6 +393,18 @@ public class TestCloudJSONFacetSKG extends SolrCloudTestCase {
} }
} }
} }
{ // make sure we don't have any facet keys we don't expect
// a little hackish because subfacets have extra keys...
final LinkedHashSet expectedKeys = new LinkedHashSet(expected.keySet());
expectedKeys.add("count");
if (0 <= actualFacetResponse.indexOf("val",0)) {
expectedKeys.add("val");
expectedKeys.add("skg");
}
assertEquals("Unexpected keys in facet response",
expectedKeys, actualFacetResponse.asShallowMap().keySet());
}
} }
/** /**