mirror of https://github.com/apache/lucene.git
SOLR-13852: Fix TestCloudNestedDocsSort to ensure child docs are never created in a way that violates uniqueKey rules
This commit is contained in:
parent
611c4f960e
commit
ebc720c5b0
|
@ -49,7 +49,8 @@ public class TestCloudNestedDocsSort extends SolrCloudTestCase {
|
||||||
|
|
||||||
@BeforeClass
|
@BeforeClass
|
||||||
public static void setupCluster() throws Exception {
|
public static void setupCluster() throws Exception {
|
||||||
for (int i=0; i<10+random().nextInt(20); i++) {
|
final int numVals = atLeast(10);
|
||||||
|
for (int i=0; i < numVals; i++) {
|
||||||
vals.add(""+Integer.toString(random().nextInt(1000000), Character.MAX_RADIX));
|
vals.add(""+Integer.toString(random().nextInt(1000000), Character.MAX_RADIX));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,12 +76,13 @@ public class TestCloudNestedDocsSort extends SolrCloudTestCase {
|
||||||
AbstractDistribZkTestBase.waitForRecoveriesToFinish("collection1", zkStateReader, true, true, 30);
|
AbstractDistribZkTestBase.waitForRecoveriesToFinish("collection1", zkStateReader, true, true, 30);
|
||||||
|
|
||||||
{
|
{
|
||||||
List<SolrInputDocument> docs = new ArrayList<>();
|
int id = 42;
|
||||||
int parentsNum = 10 +random().nextInt(20)
|
final List<SolrInputDocument> docs = new ArrayList<>();
|
||||||
|
final int parentsNum = atLeast(20);
|
||||||
;
|
;
|
||||||
for (int i=0; i<parentsNum || (matchingParent==null ||matchingChild==null); i++) {
|
for (int i=0; i<parentsNum || (matchingParent==null ||matchingChild==null); i++) {
|
||||||
final String parentTieVal = "" + random().nextInt(5);
|
final String parentTieVal = "" + random().nextInt(5);
|
||||||
final String parentId = ""+random().nextInt();
|
final String parentId = ""+(id++);
|
||||||
final SolrInputDocument parent = new SolrInputDocument("id", parentId,
|
final SolrInputDocument parent = new SolrInputDocument("id", parentId,
|
||||||
"type_s", "parent",
|
"type_s", "parent",
|
||||||
"parentTie_s1", parentTieVal,
|
"parentTie_s1", parentTieVal,
|
||||||
|
@ -89,7 +91,7 @@ public class TestCloudNestedDocsSort extends SolrCloudTestCase {
|
||||||
final List<String> parentFilter = addValsField(parent, "parentFilter_s");
|
final List<String> parentFilter = addValsField(parent, "parentFilter_s");
|
||||||
final int kids = usually() ? atLeast(20) : 0;
|
final int kids = usually() ? atLeast(20) : 0;
|
||||||
for(int c = 0; c< kids; c++){
|
for(int c = 0; c< kids; c++){
|
||||||
SolrInputDocument child = new SolrInputDocument("id", ""+random().nextInt(),
|
SolrInputDocument child = new SolrInputDocument("id", ""+(id++),
|
||||||
"type_s", "child",
|
"type_s", "child",
|
||||||
"parentTie_s1", parentTieVal,
|
"parentTie_s1", parentTieVal,
|
||||||
"parent_id_s1", parentId);
|
"parent_id_s1", parentId);
|
||||||
|
@ -111,6 +113,8 @@ public class TestCloudNestedDocsSort extends SolrCloudTestCase {
|
||||||
maxDocs += parent.getChildDocumentCount()+1;
|
maxDocs += parent.getChildDocumentCount()+1;
|
||||||
docs.add(parent);
|
docs.add(parent);
|
||||||
}
|
}
|
||||||
|
// don't add parents in increasing uniqueKey order
|
||||||
|
Collections.shuffle(docs, random());
|
||||||
client.add(docs);
|
client.add(docs);
|
||||||
client.commit();
|
client.commit();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue