You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2019/10/16 22:50:10 UTC
[lucene-solr] branch master updated: SOLR-13852: Fix
TestCloudNestedDocsSort to ensure child docs are never created in a way
that violates uniqueKey rules
This is an automated email from the ASF dual-hosted git repository.
hossman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/master by this push:
new ebc720c SOLR-13852: Fix TestCloudNestedDocsSort to ensure child docs are never created in a way that violates uniqueKey rules
ebc720c is described below
commit ebc720c5b09ae06b8ab093b296bf87e4f6ed978f
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Wed Oct 16 15:48:50 2019 -0700
SOLR-13852: Fix TestCloudNestedDocsSort to ensure child docs are never created in a way that violates uniqueKey rules
---
.../apache/solr/search/join/TestCloudNestedDocsSort.java | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java b/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java
index 9bae53c..968523e 100644
--- a/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java
+++ b/solr/core/src/test/org/apache/solr/search/join/TestCloudNestedDocsSort.java
@@ -49,7 +49,8 @@ public class TestCloudNestedDocsSort extends SolrCloudTestCase {
@BeforeClass
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));
}
@@ -75,12 +76,13 @@ public class TestCloudNestedDocsSort extends SolrCloudTestCase {
AbstractDistribZkTestBase.waitForRecoveriesToFinish("collection1", zkStateReader, true, true, 30);
{
- List<SolrInputDocument> docs = new ArrayList<>();
- int parentsNum = 10 +random().nextInt(20)
+ int id = 42;
+ final List<SolrInputDocument> docs = new ArrayList<>();
+ final int parentsNum = atLeast(20);
;
for (int i=0; i<parentsNum || (matchingParent==null ||matchingChild==null); i++) {
final String parentTieVal = "" + random().nextInt(5);
- final String parentId = ""+random().nextInt();
+ final String parentId = ""+(id++);
final SolrInputDocument parent = new SolrInputDocument("id", parentId,
"type_s", "parent",
"parentTie_s1", parentTieVal,
@@ -89,7 +91,7 @@ public class TestCloudNestedDocsSort extends SolrCloudTestCase {
final List<String> parentFilter = addValsField(parent, "parentFilter_s");
final int kids = usually() ? atLeast(20) : 0;
for(int c = 0; c< kids; c++){
- SolrInputDocument child = new SolrInputDocument("id", ""+random().nextInt(),
+ SolrInputDocument child = new SolrInputDocument("id", ""+(id++),
"type_s", "child",
"parentTie_s1", parentTieVal,
"parent_id_s1", parentId);
@@ -108,9 +110,11 @@ public class TestCloudNestedDocsSort extends SolrCloudTestCase {
matchingChild = (String) chVals.iterator().next();
}
}
- maxDocs+=parent.getChildDocumentCount()+1;
+ maxDocs += parent.getChildDocumentCount()+1;
docs.add(parent);
}
+ // don't add parents in increasing uniqueKey order
+ Collections.shuffle(docs, random());
client.add(docs);
client.commit();
}