This is an automated email from the ASF dual-hosted git repository.

cpoerschke pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git


The following commit(s) were added to refs/heads/main by this push:
     new da16d9f  SOLR-15676: extend 
PeerSyncTest.handleVersionsWithRangesTests() to consider duplicates (#327)
da16d9f is described below

commit da16d9f4bed725b4cb5b2c816b99ecd703992ba6
Author: Christine Poerschke <[email protected]>
AuthorDate: Mon Oct 18 10:54:18 2021 +0100

    SOLR-15676: extend PeerSyncTest.handleVersionsWithRangesTests() to consider 
duplicates (#327)
---
 .../core/src/java/org/apache/solr/update/PeerSync.java |  3 +++
 .../src/test/org/apache/solr/update/PeerSyncTest.java  | 18 +++++++++++-------
 2 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/update/PeerSync.java 
b/solr/core/src/java/org/apache/solr/update/PeerSync.java
index 270b10d..ee75d98 100644
--- a/solr/core/src/java/org/apache/solr/update/PeerSync.java
+++ b/solr/core/src/java/org/apache/solr/update/PeerSync.java
@@ -717,6 +717,9 @@ public class PeerSync implements SolrMetricProducer {
     }
 
     @VisibleForTesting
+    /**
+     * Implementation assumes the passed in lists are sorted and contain no 
duplicates.
+     */
     static MissedUpdatesRequest handleVersionsWithRanges(List<Long> 
otherVersions, boolean completeList,
         List<Long> ourUpdates, long ourLowThreshold) {
       // we may endup asking for updates for too many versions, causing 2MB 
post payload limit. Construct a range of
diff --git a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java 
b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
index 3c3cf64..4d9b744 100644
--- a/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
+++ b/solr/core/src/test/org/apache/solr/update/PeerSyncTest.java
@@ -364,7 +364,8 @@ public class PeerSyncTest extends 
BaseDistributedSearchTestCase {
     testHandleVersionsWithRangesMissingOneOfTwo(false /* highestMissing */);
     testHandleVersionsWithRangesMissingOneOfTwo(true /* highestMissing */);
     testHandleVersionsWithRangesMissingMiddleOfThree();
-    testHandleVersionsWithRangesMissingOneRange();
+    testHandleVersionsWithRangesMissingOneRange(false /* duplicateMiddle */);
+    testHandleVersionsWithRangesMissingOneRange(true /* duplicateMiddle */);
     testHandleVersionsWithRangesMissingTwoRanges();
   }
 
@@ -466,16 +467,19 @@ public class PeerSyncTest extends 
BaseDistributedSearchTestCase {
     }
   }
 
-  private static void testHandleVersionsWithRangesMissingOneRange() throws 
Exception {
+  private static void testHandleVersionsWithRangesMissingOneRange(boolean 
duplicateMiddle) throws Exception {
     for (boolean completeList : new boolean[] { false , true }) {
-      List<Long> otherVersions = List.of(9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L);
+      List<Long> otherVersions = duplicateMiddle
+          ? List.of(9L, 8L, 7L, 6L, 5L, 5L, 4L, 3L, 2L, 1L)
+              : List.of(9L, 8L, 7L, 6L, 5L, 4L, 3L, 2L, 1L);
       LinkedList<Long> ourUpdates = new LinkedList<>(List.of(9L, 8L, 7L, 3L, 
2L, 1L));
+      long expectedTotalRequestedUpdates = duplicateMiddle ? 4L : 3L;
       {
         long ourLowThreshold = ourUpdates.getLast(); // lowest in descending 
list
         MissedUpdatesRequest mur = 
PeerSync.MissedUpdatesFinderBase.handleVersionsWithRanges(
             otherVersions, completeList, ourUpdates, ourLowThreshold);
         // request all we are missing
-        assertEquals(3L, mur.totalRequestedUpdates);
+        assertEquals(expectedTotalRequestedUpdates, mur.totalRequestedUpdates);
         assertEquals("4...6", mur.versionsAndRanges);
       }
       {
@@ -484,7 +488,7 @@ public class PeerSyncTest extends 
BaseDistributedSearchTestCase {
             otherVersions, completeList, ourUpdates, ourLowThreshold);
         if (completeList) {
           // request all we are missing since we want a complete list
-          assertEquals(3L, mur.totalRequestedUpdates);
+          assertEquals(expectedTotalRequestedUpdates, 
mur.totalRequestedUpdates);
           assertEquals("4...6", mur.versionsAndRanges);
         } else {
           // request no updates because ???
@@ -498,7 +502,7 @@ public class PeerSyncTest extends 
BaseDistributedSearchTestCase {
             otherVersions, completeList, ourUpdates, ourLowThreshold);
         if (completeList) {
           // request all we are missing since we want a complete list
-          assertEquals(3L, mur.totalRequestedUpdates);
+          assertEquals(expectedTotalRequestedUpdates, 
mur.totalRequestedUpdates);
           assertEquals("4...6", mur.versionsAndRanges);
         } else {
           // request no updates because ???
@@ -512,7 +516,7 @@ public class PeerSyncTest extends 
BaseDistributedSearchTestCase {
             otherVersions, completeList, ourUpdates, ourLowThreshold);
         if (completeList) {
           // request all we are missing since we want a complete list
-          assertEquals(3L, mur.totalRequestedUpdates);
+          assertEquals(expectedTotalRequestedUpdates, 
mur.totalRequestedUpdates);
           assertEquals("4...6", mur.versionsAndRanges);
         } else {
           // request no updates since we don't need a complete list ...

Reply via email to