abhishekrb19 commented on code in PR #15994:
URL: https://github.com/apache/druid/pull/15994#discussion_r1521118358


##########
indexing-service/src/test/java/org/apache/druid/indexing/common/task/KillUnusedSegmentsTaskTest.java:
##########
@@ -593,14 +760,113 @@ public void 
testKillMultipleUnusedSegmentsWithDifferentMaxUsedStatusLastUpdatedT
     Assert.assertEquals(TaskState.SUCCESS, 
taskRunner.run(task2).get().getStatusCode());
 
     final List<DataSegment> unusedSegments2 = 
getMetadataStorageCoordinator().retrieveUnusedSegmentsForInterval(
+        DATA_SOURCE,
+        umbrellaInterval,
+        null,
+        null
+    );
+
+    Assert.assertEquals(ImmutableList.of(), unusedSegments2);
+    Assert.assertEquals(new KillTaskReport.Stats(2, 3, 0), getReportedStats());
+  }
+
+  @Test
+  public void 
testKillMultipleUnusedSegmentsWithVersionAndDifferentLastUpdatedTime() throws 
Exception
+  {
+    final DateTime version = DateTimes.nowUtc();
+    final DataSegment segment1 = 
newSegment(Intervals.of("2019-01-01/2019-02-01"), version.toString());
+    final DataSegment segment2 = 
newSegment(Intervals.of("2019-02-01/2019-03-01"), version.toString());
+    final DataSegment segment3 = 
newSegment(Intervals.of("2019-03-01/2019-04-01"), version.toString());
+    final DataSegment segment4 = 
newSegment(Intervals.of("2019-04-01/2019-05-01"), 
version.minusHours(2).toString());
+    final DataSegment segment5 = 
newSegment(Intervals.of("2019-04-01/2019-05-01"), 
version.minusHours(3).toString());
+
+    final Set<DataSegment> segments = ImmutableSet.of(segment1, segment2, 
segment3, segment4, segment5);
+    Assert.assertEquals(segments, 
getMetadataStorageCoordinator().commitSegments(segments));
+
+    Assert.assertEquals(
+        3,
+        getSegmentsMetadataManager().markSegmentsAsUnused(
+            ImmutableSet.of(segment1.getId(), segment2.getId(), 
segment4.getId())
+        )
+    );
+
+    // Capture the last updated time cutoff
+    final DateTime maxUsedStatusLastUpdatedTime1 = DateTimes.nowUtc();
+
+    // Delay for 1s, mark the segments as unused and then capture the last 
updated time cutoff again
+    Thread.sleep(1000);

Review Comment:
   I think we can actually remove the sleep here and in the other existing 
tests by directly marking the segments as unused using the test connector. That 
way, the test would have control over the last updated time and we can set it 
to whatever time. I can clean up this pattern along with other miscellaneous 
testing stuff in a follow-up patch
   
   
   
   
   



-- 
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