You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2015/03/12 18:58:29 UTC
svn commit: r1666266 - in /lucene/dev/trunk/solr: ./
core/src/test/org/apache/solr/cloud/
test-framework/src/java/org/apache/solr/cloud/
Author: thelabdude
Date: Thu Mar 12 17:58:29 2015
New Revision: 1666266
URL: http://svn.apache.org/r1666266
Log:
SOLR-7173: Fix ReplicationFactorTest on Windows
Modified:
lucene/dev/trunk/solr/CHANGES.txt
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
Modified: lucene/dev/trunk/solr/CHANGES.txt
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/CHANGES.txt?rev=1666266&r1=1666265&r2=1666266&view=diff
==============================================================================
--- lucene/dev/trunk/solr/CHANGES.txt (original)
+++ lucene/dev/trunk/solr/CHANGES.txt Thu Mar 12 17:58:29 2015
@@ -307,6 +307,9 @@ Other Changes
* SOLR-7180: MiniSolrCloudCluster will startup and shutdown its jetties in
parallel (Alan Woodward, Tomás Fernández Löbbe, Vamsee Yarlagadda)
+* SOLR-7173: Fix ReplicationFactorTest on Windows by adding better retry
+ support after seeing no response exceptions. (Ishan Chattopadhyaya via Timothy Potter)
+
================== 5.0.0 ==================
Consult the LUCENE_CHANGES.txt file for additional, low level, changes in this release.
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java?rev=1666266&r1=1666265&r2=1666266&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/HttpPartitionTest.java Thu Mar 12 17:58:29 2015
@@ -48,6 +48,7 @@ import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -473,38 +474,15 @@ public class HttpPartitionTest extends A
String url = zkProps.getBaseUrl() + "/" + coll;
return new HttpSolrClient(url);
}
-
- protected void doSendDoc(int docid) throws Exception {
- UpdateRequest up = new UpdateRequest();
- up.setParam(UpdateRequest.MIN_REPFACT, String.valueOf(2));
- SolrInputDocument doc = new SolrInputDocument();
- doc.addField(id, String.valueOf(docid));
- doc.addField("a_t", "hello" + docid);
- up.add(doc);
- int minAchievedRf =
- cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), cloudClient.request(up));
- }
-
+
protected void sendDoc(int docId) throws Exception {
- try {
- doSendDoc(docId);
- } catch (SolrServerException e) {
- if (e.getRootCause() instanceof NoHttpResponseException) {
- // we don't know if the doc was accepted or not, we send again
- Thread.sleep(100);
- try {
- doSendDoc(docId);
- } catch (SolrServerException e2) {
- if (e2.getRootCause() instanceof NoHttpResponseException) {
- // we don't know if the doc was accepted or not, we send again
- Thread.sleep(3000);
- doSendDoc(docId);
- }
- }
- }
- }
+ SolrInputDocument doc = new SolrInputDocument();
+ doc.addField(id, String.valueOf(docId));
+ doc.addField("a_t", "hello" + docId);
+
+ sendDocsWithRetry(Collections.singletonList(doc), 2, 3, 100);
}
-
+
/**
* Query the real-time get handler for a specific doc by ID to verify it
* exists in the provided server, using distrib=false so it doesn't route to another replica.
Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java?rev=1666266&r1=1666265&r2=1666266&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/cloud/ReplicationFactorTest.java Thu Mar 12 17:58:29 2015
@@ -30,6 +30,7 @@ import org.apache.solr.client.solrj.impl
import org.apache.solr.client.solrj.request.CollectionAdminRequest;
import org.apache.solr.client.solrj.request.UpdateRequest;
import org.apache.solr.client.solrj.response.CollectionAdminResponse;
+import org.apache.solr.common.SolrException;
import org.apache.solr.common.SolrInputDocument;
import org.apache.solr.common.cloud.Replica;
import org.apache.solr.common.cloud.ZkCoreNodeProps;
@@ -258,11 +259,7 @@ public class ReplicationFactorTest exten
batch.add(doc);
}
- UpdateRequest up = new UpdateRequest();
- up.setParam(UpdateRequest.MIN_REPFACT, String.valueOf(minRf));
- up.add(batch);
- int batchRf =
- cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), cloudClient.request(up));
+ int batchRf = sendDocsWithRetry(batch, minRf, 5, 1);
assertRf(3, "batch should have succeeded on all replicas", batchRf);
// add some chaos to the batch
@@ -276,12 +273,8 @@ public class ReplicationFactorTest exten
doc.addField("a_t", "hello" + i);
batch.add(doc);
}
-
- up = new UpdateRequest();
- up.setParam(UpdateRequest.MIN_REPFACT, String.valueOf(minRf));
- up.add(batch);
- batchRf =
- cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), cloudClient.request(up));
+
+ batchRf = sendDocsWithRetry(batch, minRf, 5, 1);
assertRf(2, "batch should have succeeded on 2 replicas (only one replica should be down)", batchRf);
// close the 2nd replica, and send a 3rd batch with expected achieved rf=1
@@ -294,12 +287,8 @@ public class ReplicationFactorTest exten
doc.addField("a_t", "hello" + i);
batch.add(doc);
}
-
- up = new UpdateRequest();
- up.setParam(UpdateRequest.MIN_REPFACT, String.valueOf(minRf));
- up.add(batch);
- batchRf =
- cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), cloudClient.request(up));
+
+ batchRf = sendDocsWithRetry(batch, minRf, 5, 1);
assertRf(1, "batch should have succeeded on the leader only (both replicas should be down)", batchRf);
getProxyForReplica(replicas.get(0)).reopen();
Modified: lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java?rev=1666266&r1=1666265&r2=1666266&view=diff
==============================================================================
--- lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java (original)
+++ lucene/dev/trunk/solr/test-framework/src/java/org/apache/solr/cloud/AbstractFullDistribZkTestBase.java Thu Mar 12 17:58:29 2015
@@ -778,6 +778,30 @@ public abstract class AbstractFullDistri
}
}
+ @SuppressWarnings("rawtypes")
+ protected int sendDocsWithRetry(List<SolrInputDocument> batch, int minRf, int maxRetries, int waitBeforeRetry) throws Exception {
+ UpdateRequest up = new UpdateRequest();
+ up.setParam(UpdateRequest.MIN_REPFACT, String.valueOf(minRf));
+ up.add(batch);
+ NamedList resp = null;
+ int numRetries = 0;
+ while(true) {
+ try {
+ resp = cloudClient.request(up);
+ return cloudClient.getMinAchievedReplicationFactor(cloudClient.getDefaultCollection(), resp);
+ } catch (Exception exc) {
+ Throwable rootCause = SolrException.getRootCause(exc);
+ if (++numRetries <= maxRetries) {
+ log.warn("ERROR: " + rootCause + " ... Sleeping for " + waitBeforeRetry + " seconds before re-try ...");
+ Thread.sleep(waitBeforeRetry * 1000L);
+ } else {
+ log.error("No more retries available! Add batch failed due to: " + rootCause);
+ throw exc;
+ }
+ }
+ }
+ }
+
@Override
protected void indexDoc(SolrInputDocument doc) throws IOException,
SolrServerException {