You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by da...@apache.org on 2017/10/23 06:59:45 UTC

lucene-solr:branch_7x: SOLR-11452: Delay between open new searcher and copy over updates can cause the test to fail.

Repository: lucene-solr
Updated Branches:
  refs/heads/branch_7x 60273fc52 -> 21c5d1a5d


SOLR-11452: Delay between open new searcher and copy over updates can cause the test to fail.


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

Branch: refs/heads/branch_7x
Commit: 21c5d1a5d6f10a962a5107ae188af6da3d7a84c1
Parents: 60273fc
Author: Cao Manh Dat <da...@apache.org>
Authored: Fri Oct 20 18:11:13 2017 +0700
Committer: Cao Manh Dat <da...@apache.org>
Committed: Mon Oct 23 13:59:34 2017 +0700

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


http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/21c5d1a5/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 c978a5f..b79ae73 100644
--- a/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
+++ b/solr/core/src/test/org/apache/solr/cloud/TestTlogReplica.java
@@ -487,7 +487,16 @@ public class TestTlogReplica extends SolrCloudTestCase {
         .commit(cloudClient, collectionName);
 
     waitForNumDocsInAllActiveReplicas(2);
-    assertCopyOverOldUpdates(1, timeCopyOverPerCores);
+    // There are a small delay between new searcher and copy over old updates operation
+    TimeOut timeOut = new TimeOut(5, TimeUnit.SECONDS);
+    while (!timeOut.hasTimedOut()) {
+      if (assertCopyOverOldUpdates(1, timeCopyOverPerCores)) {
+        break;
+      } else {
+        Thread.sleep(500);
+      }
+    }
+    assertTrue("Expect only one copy over updates per cores", assertCopyOverOldUpdates(1, timeCopyOverPerCores));
 
     boolean firstCommit = true;
     // UpdateLog copy over old updates
@@ -498,7 +507,7 @@ public class TestTlogReplica extends SolrCloudTestCase {
           // because tlog replicas periodically ask leader for new segments,
           // therefore the copy over old updates action must not be triggered until
           // tlog replicas actually get new segments
-          assertCopyOverOldUpdates(1, timeCopyOverPerCores);
+          assertTrue("Expect only one copy over updates per cores", assertCopyOverOldUpdates(1, timeCopyOverPerCores));
           firstCommit = false;
         }
         cloudClient.commit(collectionName);
@@ -911,10 +920,11 @@ public class TestTlogReplica extends SolrCloudTestCase {
 
   }
 
-  private void assertCopyOverOldUpdates(long delta, Map<SolrCore, Long> timesPerCore) {
+  private boolean assertCopyOverOldUpdates(long delta, Map<SolrCore, Long> timesPerCore) {
     for (SolrCore core : timesPerCore.keySet()) {
-      assertEquals(timesPerCore.get(core) + delta, getTimesCopyOverOldUpdates(core));
+      if (timesPerCore.get(core) + delta != getTimesCopyOverOldUpdates(core)) return false;
     }
+    return true;
   }
 
   private Map<SolrCore, Long> getTimesCopyOverOldUpdates(List<SolrCore> cores) {