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 2016/12/30 15:56:54 UTC

[18/50] [abbrv] lucene-solr:jira/solr-9854: SOLR-9448: providing a test for workaround of a differently named uniqueKey field

SOLR-9448: providing a test for workaround of a differently named uniqueKey field


Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/54d8574f
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/54d8574f
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/54d8574f

Branch: refs/heads/jira/solr-9854
Commit: 54d8574f9662f89598a06fbb47de9a376ef5d2bc
Parents: 687f036
Author: Mikhail Khludnev <mk...@apache.org>
Authored: Sun Dec 25 10:00:50 2016 +0300
Committer: Mikhail Khludnev <mk...@apache.org>
Committed: Sun Dec 25 10:36:31 2016 +0300

----------------------------------------------------------------------
 solr/CHANGES.txt                                |  2 +
 .../schema-minimal-with-another-uniqkey.xml     | 23 ++++++++
 .../TestSubQueryTransformerDistrib.java         | 55 +++++++++++---------
 3 files changed, 56 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/54d8574f/solr/CHANGES.txt
----------------------------------------------------------------------
diff --git a/solr/CHANGES.txt b/solr/CHANGES.txt
index b2ec5ef..a6ea07b 100644
--- a/solr/CHANGES.txt
+++ b/solr/CHANGES.txt
@@ -332,6 +332,8 @@ Other Changes
 
 * SOLR-9758: refactor preferLocalShards implementation (Christine Poerschke)
 
+* SOLR-9448: providing a test to workaround a differently named uniqueKey field (Mikhail Khludnev)
+
 ==================  6.3.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/54d8574f/solr/core/src/test-files/solr/collection1/conf/schema-minimal-with-another-uniqkey.xml
----------------------------------------------------------------------
diff --git a/solr/core/src/test-files/solr/collection1/conf/schema-minimal-with-another-uniqkey.xml b/solr/core/src/test-files/solr/collection1/conf/schema-minimal-with-another-uniqkey.xml
new file mode 100644
index 0000000..2087a1d
--- /dev/null
+++ b/solr/core/src/test-files/solr/collection1/conf/schema-minimal-with-another-uniqkey.xml
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements.  See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License.  You may obtain a copy of the License at
+
+     http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<schema name="schema-minimal-with-another-uniqkey" version="1.1">
+  <fieldType name="string" class="solr.StrField"/>
+  <uniqueKey>notid</uniqueKey>
+  <field name="notid" type="string" indexed="true" stored="true" docValues="false" multiValued="false" required="true"/>
+  <dynamicField name="*" type="string" indexed="true" stored="true"/>
+</schema>

http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/54d8574f/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
index c417272..620cac0 100644
--- a/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
+++ b/solr/core/src/test/org/apache/solr/response/transform/TestSubQueryTransformerDistrib.java
@@ -26,7 +26,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Random;
 
-import org.apache.solr.SolrTestCaseJ4.SuppressSSL;
 import org.apache.solr.client.solrj.SolrServerException;
 import org.apache.solr.client.solrj.impl.CloudSolrClient;
 import org.apache.solr.client.solrj.request.CollectionAdminRequest;
@@ -42,15 +41,19 @@ import org.apache.solr.common.util.ContentStreamBase;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
-@SuppressSSL 
 public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
   
+  private static final String support = "These guys help customers";
+  private static final String engineering = "These guys develop stuff";
   final static String people = "people";
   final static String depts = "departments";
+  private static boolean differentUniqueId;
   
   @BeforeClass
   public static void setupCluster() throws Exception {
     
+    differentUniqueId = random().nextBoolean();
+    
     final Path configDir = Paths.get(TEST_HOME(), "collection1", "conf");
 
     String configName = "solrCloudCollectionConfig";
@@ -72,7 +75,9 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
 
     CollectionAdminRequest.createCollection(depts, configName, shards, replicas)
         .withProperty("config", "solrconfig-doctransformers.xml")
-        .withProperty("schema", "schema-docValuesJoin.xml")
+        .withProperty("schema", 
+              differentUniqueId ? "schema-minimal-with-another-uniqkey.xml":
+                                  "schema-docValuesJoin.xml")
         .process(cluster.getSolrClient());
 
     CloudSolrClient client = cluster.getSolrClient();
@@ -102,28 +107,22 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
           "fl","*,depts:[subquery "+((random1.nextBoolean() ? "" : "separator=,"))+"]", 
           "rows","" + peopleMultiplier,
           "depts.q","{!terms f=dept_id_s v=$row.dept_ss_dv "+((random1.nextBoolean() ? "" : "separator=,"))+"}", 
-          "depts.fl","text_t",
+          "depts.fl","text_t"+(differentUniqueId?",id:notid":""),
           "depts.indent","true",
           "depts.collection","departments",
+          differentUniqueId ? "depts.distrib.singlePass":"notnecessary","true",
           "depts.rows",""+(deptMultiplier*2),
-          "depts.logParamsList","q,fl,rows,row.dept_ss_dv"}));
+          "depts.logParamsList","q,fl,rows,row.dept_ss_dv",
+          random().nextBoolean()?"depts.wt":"whatever",anyWt(),
+          random().nextBoolean()?"wt":"whatever",anyWt()}));
       final QueryResponse  rsp = new QueryResponse();
       rsp.setResponse(cluster.getSolrClient().request(qr, people));
       final SolrDocumentList hits = rsp.getResults();
       
       assertEquals(peopleMultiplier, hits.getNumFound());
       
-      Map<String,String> engText = new HashMap<String,String>() {
-        { put("text_t", "These guys develop stuff");
-        }
-      };
-      Map<String,String> suppText = new HashMap<String,String>() {
-        { put("text_t", "These guys help customers");
-        }
-      };
-      
-      int engineer = 0;
-      int support = 0;
+      int engineerCount = 0;
+      int supportCount = 0;
       
       for (int res : new int [] {0, (peopleMultiplier-1) /2, peopleMultiplier-1}) {
         SolrDocument doc = hits.get(res);
@@ -133,16 +132,23 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
             deptMultiplier * 2, relDepts.getNumFound());
         for (int deptN = 0 ; deptN < relDepts.getNumFound(); deptN++ ) {
           SolrDocument deptDoc = relDepts.get(deptN);
-          assertTrue(deptDoc + "should be either "+engText +" or "+suppText,
-              (engText.equals(deptDoc) && ++engineer>0) || 
-                   (suppText.equals(deptDoc) && ++support>0));
+          String actual = (String) deptDoc.get("text_t");
+          assertTrue(deptDoc + "should be either "+engineering +" or "+support,
+              (engineering.equals(actual) && ++engineerCount>0) || 
+                   (support.equals(actual) && ++supportCount>0));
         }
       }
-      assertEquals(hits.toString(), engineer, support); 
+      assertEquals(hits.toString(), engineerCount, supportCount); 
     }
     
   }
 
+  private String anyWt() {
+    String[] wts = new String[]{"javabin","xml","json"};
+    return wts[random().nextInt(wts.length)];
+  }
+
+
   private void createIndex(String people, int peopleMultiplier, String depts, int deptMultiplier)
       throws SolrServerException, IOException {
     
@@ -175,14 +181,15 @@ public class TestSubQueryTransformerDistrib extends SolrCloudTestCase {
     addDocs(people, peopleDocs);
 
     List<String> deptsDocs = new ArrayList<>();
+    String deptIdField = differentUniqueId? "notid":"id";
     for (int d=0; d < deptMultiplier; d++) {
-      deptsDocs.add(add(doc("id",""+id++, "dept_id_s", "Engineering", "text_t","These guys develop stuff", "salary_i_dv", "1000",
+      deptsDocs.add(add(doc(deptIdField,""+id++, "dept_id_s", "Engineering", "text_t",engineering, "salary_i_dv", "1000",
                                      "dept_id_i", "0")));
-      deptsDocs.add(add(doc("id",""+id++, "dept_id_s", "Marketing", "text_t","These guys make you look good","salary_i_dv", "1500",
+      deptsDocs.add(add(doc(deptIdField,""+id++, "dept_id_s", "Marketing", "text_t","These guys make you look good","salary_i_dv", "1500",
                                      "dept_id_i", "1")));
-      deptsDocs.add(add(doc("id",""+id++, "dept_id_s", "Sales", "text_t","These guys sell stuff","salary_i_dv", "1600",
+      deptsDocs.add(add(doc(deptIdField,""+id++, "dept_id_s", "Sales", "text_t","These guys sell stuff","salary_i_dv", "1600",
                                     "dept_id_i", "2")));
-      deptsDocs.add(add(doc("id",""+id++, "dept_id_s", "Support", "text_t","These guys help customers","salary_i_dv", "800",
+      deptsDocs.add(add(doc(deptIdField,""+id++, "dept_id_s", "Support", "text_t",support,"salary_i_dv", "800",
                                     "dept_id_i", "3")));
       
     }