You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by tf...@apache.org on 2017/05/23 00:03:48 UTC

[26/27] lucene-solr:jira/solr-10233: Fix issue with test tlog replica

Fix issue with test tlog replica


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

Branch: refs/heads/jira/solr-10233
Commit: 7382b65644a9d704f44039063947dc8583f6135e
Parents: 70bd593
Author: Tomas Fernandez Lobbe <tf...@apache.org>
Authored: Mon May 22 16:26:37 2017 -0700
Committer: Tomas Fernandez Lobbe <tf...@apache.org>
Committed: Mon May 22 16:26:37 2017 -0700

----------------------------------------------------------------------
 .../test/org/apache/solr/cloud/TestTlogReplica.java   | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/7382b656/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
----------------------------------------------------------------------
diff --git a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
index a4070b3..b778789 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
@@ -466,8 +466,8 @@ public class TestTlogReplica extends SolrCloudTestCase {
     ChaosMonkey.start(solrRunner);
     waitForState("Replica didn't recover", collectionName, activeReplicaCount(0,2,0));
     // We skip peerSync, so replica will always trigger commit on leader
-//    waitForNumDocsInAllActiveReplicas(4);
-    waitForNumDocsInAllReplicas(4, getCollectionState(collectionName).getReplicas(), 0);// Should be immediate
+    // We query only the non-leader replicas, since we haven't opened a new searcher on the leader yet
+    waitForNumDocsInAllReplicas(4, getNonLeaderReplias(collectionName), 0);// Should be immediate
     
     // If I add the doc immediately, the leader fails to communicate with the follower with broken pipe.
     // Options are, wait or retry...
@@ -489,7 +489,8 @@ public class TestTlogReplica extends SolrCloudTestCase {
     ChaosMonkey.start(solrRunner);
     waitForState("Replica didn't recover", collectionName, activeReplicaCount(0,2,0));
     checkRTG(3,7, cluster.getJettySolrRunners());
-    waitForNumDocsInAllReplicas(5, getCollectionState(collectionName).getReplicas(), 0);// Should be immediate
+    waitForNumDocsInAllReplicas(5, getNonLeaderReplias(collectionName), 0);// Should be immediate
+    cluster.getSolrClient().commit(collectionName);
 
     // Test replica recovery apply buffer updates
     Semaphore waitingForBufferUpdates = new Semaphore(0);
@@ -526,6 +527,11 @@ public class TestTlogReplica extends SolrCloudTestCase {
     }
   }
   
+  private List<Replica> getNonLeaderReplias(String collectionName) {
+    return getCollectionState(collectionName).getReplicas().stream().filter(
+        (r)-> !r.getBool("leader", false)).collect(Collectors.toList());
+  }
+  
   public void testDeleteById() throws Exception{
     createAndWaitForCollection(1,0,2,0);
     CloudSolrClient cloudClient = cluster.getSolrClient();
@@ -667,7 +673,7 @@ public class TestTlogReplica extends SolrCloudTestCase {
       try (HttpSolrClient replicaClient = getHttpSolrClient(r.getCoreUrl())) {
         while (true) {
           try {
-            assertEquals("Replica " + r.getName() + " not up to date after " + REPLICATION_TIMEOUT_SECS + " seconds",
+            assertEquals("Replica " + r.getName() + " not up to date after " + timeout + " seconds",
                 numDocs, replicaClient.query(new SolrQuery(query)).getResults().getNumFound());
             break;
           } catch (AssertionError e) {