snleee commented on a change in pull request #8071:
URL: https://github.com/apache/pinot/pull/8071#discussion_r792324304



##########
File path: 
pinot-controller/src/test/java/org/apache/pinot/controller/helix/core/PinotHelixResourceManagerTest.java
##########
@@ -816,6 +819,48 @@ public void testSegmentReplacementForRefresh()
     Assert.assertEquals(new 
HashSet<>(ControllerTestUtils.getHelixResourceManager()
             .getSegmentsFor(OFFLINE_SEGMENTS_REPLACE_TEST_REFRESH_TABLE_NAME, 
true)),
         new HashSet<>(Arrays.asList("s9", "s10", "s11")));
+
+    // Call revert segment replacements
+    ControllerTestUtils.getHelixResourceManager()
+        
.revertReplaceSegments(OFFLINE_SEGMENTS_REPLACE_TEST_REFRESH_TABLE_NAME, 
lineageEntryId3, false);
+    waitForSegmentsToDelete(OFFLINE_SEGMENTS_REPLACE_TEST_REFRESH_TABLE_NAME, 
3, MAX_TIMEOUT_IN_MILLISECOND);
+    Assert.assertEquals(new 
HashSet<>(ControllerTestUtils.getHelixResourceManager()
+            .getSegmentsFor(OFFLINE_SEGMENTS_REPLACE_TEST_REFRESH_TABLE_NAME, 
true)),
+        new HashSet<>(Arrays.asList("s3", "s4", "s5")));
+
+    // Re-upload (s9, s10, s11) to test the segment clean up from 
startReplaceSegments
+    for (int i = 9; i < 12; i++) {
+      
ControllerTestUtils.getHelixResourceManager().addNewSegment(OFFLINE_SEGMENTS_REPLACE_TEST_REFRESH_TABLE_NAME,
+          
SegmentMetadataMockUtils.mockSegmentMetadata(OFFLINE_SEGMENTS_REPLACE_TEST_REFRESH_TABLE_NAME,
 "s" + i),
+          "downloadUrl");
+    }
+    Assert.assertEquals(ControllerTestUtils.getHelixResourceManager()
+        .getSegmentsFor(OFFLINE_SEGMENTS_REPLACE_TEST_REFRESH_TABLE_NAME, 
false).size(), 6);
+
+    // Call startReplaceSegments with (s3, s4, s5) -> (s12, s13, s14)
+    segmentsTo = Arrays.asList("s12", "s13", "s14");
+    String lineageEntryId4 = ControllerTestUtils.getHelixResourceManager()
+        
.startReplaceSegments(OFFLINE_SEGMENTS_REPLACE_TEST_REFRESH_TABLE_NAME, 
segmentsFrom, segmentsTo, true);
+    waitForSegmentsToDelete(OFFLINE_SEGMENTS_REPLACE_TEST_REFRESH_TABLE_NAME, 
3, MAX_TIMEOUT_IN_MILLISECOND);
+    Assert.assertEquals(new 
HashSet<>(ControllerTestUtils.getHelixResourceManager()
+            .getSegmentsFor(OFFLINE_SEGMENTS_REPLACE_TEST_REFRESH_TABLE_NAME, 
false)),
+        new HashSet<>(Arrays.asList("s3", "s4", "s5")));
+
+    // Upload to test the segment clean up from startReplaceSegments

Review comment:
       This comment is misleading. I updated.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to