LakshSingla commented on code in PR #13706:
URL: https://github.com/apache/druid/pull/13706#discussion_r1116546584
##########
indexing-service/src/test/java/org/apache/druid/indexing/common/task/batch/parallel/TombstoneHelperTest.java:
##########
@@ -115,9 +111,136 @@ public void
tombstonesCreatedWhenNoDataInInputIntervalAndExistingSegments() thro
new SegmentIdWithShardSpec("test", ti, "newVersion", new
TombstoneShardSpec())
);
}
- Set<DataSegment> tombstones =
tombstoneHelper.computeTombstones(intervalToVersion);
+ Set<DataSegment> tombstones =
tombstoneHelper.computeTombstones(dataSchema, intervalToVersion);
Assert.assertEquals(3, tombstones.size());
tombstones.forEach(ts -> Assert.assertTrue(ts.isTombstone()));
}
+ @Test
+ public void
tombstonesCreatedForReplaceWhenReplaceIsContainedInUsedIntervals() throws
Exception
+ {
+ Interval usedInterval = Intervals.of("2020-02-01/2020-04-01");
+ Interval replaceInterval = Intervals.of("2020-03-01/2020-03-31");
+ Interval intervalToDrop = Intervals.of("2020-03-05/2020-03-07");
+ Granularity replaceGranularity = Granularities.DAY;
+
+ DataSegment existingUsedSegment =
+ DataSegment.builder()
+ .dataSource("test")
+ .interval(usedInterval)
+ .version("oldVersion")
+ .size(100)
+ .build();
+ Assert.assertFalse(existingUsedSegment.isTombstone());
+ Mockito.when(taskActionClient.submit(any(TaskAction.class)))
+ .thenReturn(Collections.singletonList(existingUsedSegment));
+ TombstoneHelper tombstoneHelper = new TombstoneHelper(taskActionClient);
+
+ Set<Interval> tombstoneIntervals =
tombstoneHelper.computeTombstoneIntervalsForReplace(
+ ImmutableList.of(replaceInterval),
+ ImmutableList.of(intervalToDrop),
+ "test",
+ replaceGranularity
+ );
+ Assert.assertEquals(
+ ImmutableSet.of(Intervals.of("2020-03-05/2020-03-06"),
Intervals.of("2020-03-06/2020-03-07")),
+ tombstoneIntervals
+ );
+ }
+
+ @Test
+ public void tombstonesCreatedForReplaceWhenThereIsAGapInUsedIntervals()
throws Exception
+ {
+ List<Interval> usedIntervals = ImmutableList.of(
+ Intervals.of("2020-02-01/2020-04-01"),
+ Intervals.of("2020-07-01/2020-11-01")
+ );
+ Interval replaceInterval = Intervals.of("2020-01-01/2020-12-01");
+ Interval intervalToDrop = Intervals.of("2020-03-01/2020-09-01");
+ Granularity replaceGranularity = Granularities.MONTH;
+
+ List<DataSegment> existingUsedSegments = usedIntervals.stream().map(
+ usedInterval -> DataSegment.builder()
+ .dataSource("test")
+ .interval(usedInterval)
+ .version("oldVersion")
+ .size(100)
+ .build()
+ ).collect(Collectors.toList());
+
Mockito.when(taskActionClient.submit(any(TaskAction.class))).thenReturn(existingUsedSegments);
+ TombstoneHelper tombstoneHelper = new TombstoneHelper(taskActionClient);
+
+ Set<Interval> tombstoneIntervals =
tombstoneHelper.computeTombstoneIntervalsForReplace(
+ ImmutableList.of(replaceInterval),
+ ImmutableList.of(intervalToDrop),
+ "test",
+ replaceGranularity
+ );
+ Assert.assertEquals(
+ ImmutableSet.of(
+ Intervals.of("2020-03-01/2020-04-01"),
+ Intervals.of("2020-07-01/2020-08-01"),
+ Intervals.of("2020-08-01/2020-09-01")
+ ),
+ tombstoneIntervals
+ );
+ }
+
+ @Test
+ public void tombstonesCreatedForReplaceWhenUsedIntervalsDonotAlign() throws
Exception
Review Comment:
Renamed the tests to specify that we are testing intervals only (since
that's the valuable and variable part in the generated segments).
--
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]