zachjsh commented on a change in pull request #11501:
URL: https://github.com/apache/druid/pull/11501#discussion_r677867443



##########
File path: 
indexing-service/src/test/java/org/apache/druid/indexing/common/task/KillUnusedSegmentsTaskTest.java
##########
@@ -74,7 +74,58 @@ public void testKill() throws Exception
     );
 
     final KillUnusedSegmentsTask task =
-        new KillUnusedSegmentsTask(null, DATA_SOURCE, 
Intervals.of("2019-03-01/2019-04-01"), null);
+        new KillUnusedSegmentsTask(
+            null,
+            DATA_SOURCE,
+            Intervals.of("2019-03-01/2019-04-01"),
+            null,
+            false
+        );
+
+    Assert.assertEquals(TaskState.SUCCESS, 
taskRunner.run(task).get().getStatusCode());
+
+    final List<DataSegment> unusedSegments =
+        
getMetadataStorageCoordinator().retrieveUnusedSegmentsForInterval(DATA_SOURCE, 
Intervals.of("2019/2020"));
+
+    
Assert.assertEquals(ImmutableList.of(newSegment(Intervals.of("2019-02-01/2019-03-01"),
 version)), unusedSegments);
+    Assertions.assertThat(
+        getMetadataStorageCoordinator()
+            .retrieveUsedSegmentsForInterval(DATA_SOURCE, 
Intervals.of("2019/2020"), Segments.ONLY_VISIBLE)
+    ).containsExactlyInAnyOrder(
+        newSegment(Intervals.of("2019-01-01/2019-02-01"), version),
+        newSegment(Intervals.of("2019-04-01/2019-05-01"), version)
+    );
+  }
+
+
+  @Test
+  public void testKillWithMarkUnused() throws Exception
+  {
+    final String version = DateTimes.nowUtc().toString();
+    final Set<DataSegment> segments = ImmutableSet.of(
+        newSegment(Intervals.of("2019-01-01/2019-02-01"), version),
+        newSegment(Intervals.of("2019-02-01/2019-03-01"), version),
+        newSegment(Intervals.of("2019-03-01/2019-04-01"), version),
+        newSegment(Intervals.of("2019-04-01/2019-05-01"), version)
+    );
+    final Set<DataSegment> announced = 
getMetadataStorageCoordinator().announceHistoricalSegments(segments);
+
+    Assert.assertEquals(segments, announced);
+
+    Assert.assertTrue(
+        getSegmentsMetadataManager().markSegmentAsUnused(
+            newSegment(Intervals.of("2019-02-01/2019-03-01"), 
version).getId().toString()
+        )
+    );
+
+    final KillUnusedSegmentsTask task =
+        new KillUnusedSegmentsTask(
+            null,
+            DATA_SOURCE,
+            Intervals.of("2019-03-01/2019-04-01"),
+            null,
+            true
+        );

Review comment:
       The conditions that the test here is checking seem to be the same for 
the case that MarkUnused is false. Any other condition(s) here that we can 
check here to differentiate the 2 tests?




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