lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r1545011 - in /lucene/dev/branches/branch_4x: ./ solr/ solr/core/ solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
Date Sun, 24 Nov 2013 17:15:43 GMT
Author: markrmiller
Date: Sun Nov 24 17:15:43 2013
New Revision: 1545011

URL: http://svn.apache.org/r1545011
Log:
tests: improve test

Modified:
    lucene/dev/branches/branch_4x/   (props changed)
    lucene/dev/branches/branch_4x/solr/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/   (props changed)
    lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java

Modified: lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java?rev=1545011&r1=1545010&r2=1545011&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
(original)
+++ lucene/dev/branches/branch_4x/solr/core/src/test/org/apache/solr/cloud/BasicDistributedZk2Test.java
Sun Nov 24 17:15:43 2013
@@ -29,7 +29,6 @@ import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 import org.apache.commons.io.IOUtils;
-import org.apache.lucene.util.Constants;
 import org.apache.solr.client.solrj.SolrQuery;
 import org.apache.solr.client.solrj.SolrServer;
 import org.apache.solr.client.solrj.SolrServerException;
@@ -55,6 +54,7 @@ import org.junit.BeforeClass;
  * work as expected.
  */
 public class BasicDistributedZk2Test extends AbstractFullDistribZkTestBase {
+  private static final String SHARD2 = "shard2";
   private static final String SHARD1 = "shard1";
   private static final String ONE_NODE_COLLECTION = "onenodecollection";
 
@@ -169,8 +169,7 @@ public class BasicDistributedZk2Test ext
     try {
       final String baseUrl = getBaseUrl((HttpSolrServer) clients.get(0));
       HttpSolrServer server = new HttpSolrServer(baseUrl);
-      server.setConnectionTimeout(15000);
-      server.setSoTimeout(60000);
+      server.setConnectionTimeout(30000);
       Create createCmd = new Create();
       createCmd.setRoles("none");
       createCmd.setCoreName(ONE_NODE_COLLECTION + "core");
@@ -189,32 +188,42 @@ public class BasicDistributedZk2Test ext
     
     cloudClient.getZkStateReader().getLeaderRetry(ONE_NODE_COLLECTION, SHARD1, 30000);
     
-    final String baseUrl2 = getBaseUrl((HttpSolrServer) clients.get(random().nextInt(clients.size())));
-    HttpSolrServer qclient = new HttpSolrServer(baseUrl2 + "/onenodecollection" + "core");
+    int docs = 2;
+    for (SolrServer client : clients) {
+      final String baseUrl = getBaseUrl((HttpSolrServer) client);
+      addAndQueryDocs(baseUrl, docs);
+      docs += 2;
+    }
+  }
+
+  // 2 docs added every call
+  private void addAndQueryDocs(final String baseUrl, int docs)
+      throws SolrServerException, IOException {
+    HttpSolrServer qclient = new HttpSolrServer(baseUrl + "/onenodecollection" + "core");
     
     // add a doc
     SolrInputDocument doc = new SolrInputDocument();
-    doc.addField("id", "1");
+    doc.addField("id", docs);
     qclient.add(doc);
     qclient.commit();
     
     SolrQuery query = new SolrQuery("*:*");
     QueryResponse results = qclient.query(query);
-    assertEquals(1, results.getResults().getNumFound());
+    assertEquals(docs - 1, results.getResults().getNumFound());
     
-    qclient = new HttpSolrServer(baseUrl2 + "/onenodecollection");
+    qclient = new HttpSolrServer(baseUrl + "/onenodecollection");
     results = qclient.query(query);
-    assertEquals(1, results.getResults().getNumFound());
+    assertEquals(docs - 1, results.getResults().getNumFound());
     
     doc = new SolrInputDocument();
-    doc.addField("id", "2");
+    doc.addField("id", docs + 1);
     qclient.add(doc);
     qclient.commit();
     
     query = new SolrQuery("*:*");
     query.set("rows", 0);
     results = qclient.query(query);
-    assertEquals(2, results.getResults().getNumFound());
+    assertEquals(docs, results.getResults().getNumFound());
   }
   
   private long testUpdateAndDelete() throws Exception {
@@ -508,13 +517,13 @@ public class BasicDistributedZk2Test ext
       if (VERBOSE) System.err.println("shard1 total:"
           + cjetty.client.solrClient.query(new SolrQuery("*:*")).getResults().getNumFound());
     }
-    for (CloudJettyRunner cjetty : shardToJetty.get("shard2")) {
+    for (CloudJettyRunner cjetty : shardToJetty.get(SHARD2)) {
       if (VERBOSE) System.err.println("shard2 total:"
           + cjetty.client.solrClient.query(new SolrQuery("*:*")).getResults().getNumFound());
     }
     
     checkShardConsistency(SHARD1);
-    checkShardConsistency("shard2");
+    checkShardConsistency(SHARD2);
     
     assertDocCounts(VERBOSE);
   }



Mime
View raw message