lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From yo...@apache.org
Subject svn commit: r1230178 - in /lucene/dev/branches/solrcloud/solr: core/src/test/org/apache/solr/update/PeerSyncTest.java test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
Date Wed, 11 Jan 2012 18:28:55 GMT
Author: yonik
Date: Wed Jan 11 18:28:55 2012
New Revision: 1230178

URL: http://svn.apache.org/viewvc?rev=1230178&view=rev
Log:
tests: use random fields, compare complete responses

Modified:
    lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
    lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java

Modified: lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java?rev=1230178&r1=1230177&r2=1230178&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
(original)
+++ lucene/dev/branches/solrcloud/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
Wed Jan 11 18:28:55 2012
@@ -54,19 +54,28 @@ public class PeerSyncTest extends BaseDi
   
   @Override
   public void doTest() throws Exception {
+    handle.clear();
+    handle.put("QTime", SKIPVAL);
+    handle.put("timestamp", SKIPVAL);
+    handle.put("score", SKIPVAL);
+    handle.put("maxScore", SKIPVAL);
+
     SolrServer clients0 = clients.get(0);
     SolrServer clients1 = clients.get(1);
     SolrServer clients2 = clients.get(2);
 
-    clients0.add(sdoc("id",1));
+    clients0.add(addRandFields(sdoc("id",1)));
+    clients0.add(addRandFields(sdoc("id",1)));
+    clients0.add(addRandFields(sdoc("id",2)));
 
     QueryRequest qr = new QueryRequest(params("qt","/get", "getVersions","100", "sync",shardsArr[0]));
     NamedList rsp = clients1.request(qr);
     // System.out.println("RESPONSE="+rsp);
     assertTrue( (Boolean)rsp.get("sync") );
+    clients0.commit();
     clients1.commit();
-    assertEquals(1, clients1.query(params("q","id:1")).getResults().getNumFound());
 
+    queryAndCompare(params("q","*:*"), clients0, clients1);
   }
 
 

Modified: lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java?rev=1230178&r1=1230177&r2=1230178&view=diff
==============================================================================
--- lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
(original)
+++ lucene/dev/branches/solrcloud/solr/test-framework/src/java/org/apache/solr/BaseDistributedSearchTestCase.java
Wed Jan 11 18:28:55 2012
@@ -41,7 +41,9 @@ import org.apache.solr.common.SolrDocume
 import org.apache.solr.common.SolrDocumentList;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.params.ModifiableSolrParams;
+import org.apache.solr.common.params.SolrParams;
 import org.apache.solr.common.util.NamedList;
+import org.apache.solr.response.SolrQueryResponse;
 import org.apache.solr.schema.TrieDateField;
 import org.apache.solr.util.AbstractSolrTestCase;
 import org.junit.Test;
@@ -274,9 +276,14 @@ public abstract class BaseDistributedSea
     SolrInputDocument doc = new SolrInputDocument();
     addFields(doc, fields);
     addFields(doc, "rnd_b", true);
-    addFields(doc, getRandFields(getFieldNames(), getRandValues()));
+    addRandFields(doc);
     indexDoc(doc);
   }
+  
+  protected SolrInputDocument addRandFields(SolrInputDocument sdoc) {
+    addFields(sdoc, getRandFields(getFieldNames(), getRandValues()));
+    return sdoc;
+  }
 
   protected void index(Object... fields) throws Exception {
     SolrInputDocument doc = new SolrInputDocument();
@@ -369,6 +376,20 @@ public abstract class BaseDistributedSea
       }
     }
   }
+  
+  public QueryResponse queryAndCompare(SolrParams params, SolrServer... servers) throws SolrServerException
{
+    QueryResponse first = null;
+    for (SolrServer server : servers) {
+      QueryResponse rsp = server.query(new ModifiableSolrParams(params));
+      if (first == null) {
+        first = rsp;
+      } else {
+        compareResponses(first, rsp);
+      }
+    }
+
+    return first;
+  }
 
   public static boolean eq(String a, String b) {
     return a == b || (a != null && a.equals(b));



Mime
View raw message