zachjsh commented on code in PR #15415:
URL: https://github.com/apache/druid/pull/15415#discussion_r1416385345
##########
server/src/test/java/org/apache/druid/server/http/MetadataResourceTest.java:
##########
@@ -236,6 +246,117 @@ public void testGetAllSegmentsIncludingRealtime()
Assert.assertEquals(new SegmentStatusInCluster(realTimeSegments[1], false,
null, 40L, true), resultList.get(5));
}
+ @Test
+ public void testGetUnusedSegmentsInDataSource()
+ {
+ Mockito.doAnswer(mockIterateAllUnusedSegmentsForDatasource())
+ .when(segmentsMetadataManager)
+ .iterateAllUnusedSegmentsForDatasource(
+ ArgumentMatchers.any(),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.any(),
+ ArgumentMatchers.any());
+
+ // test with null datasource name - fails with expected bad datasource
name error
+ DruidException e = Assert.assertThrows(
+ DruidException.class,
+ () -> metadataResource.getUnusedSegmentsInDataSource(request, null,
null, -1, null)
+ );
+ Assert.assertEquals(DruidException.Category.INVALID_INPUT,
e.getCategory());
+ Assert.assertEquals("dataSource name must be non-empty", e.getMessage());
+
+ // test with empty datasource name - fails with expected bad datasource
name error
+ e = Assert.assertThrows(
Review Comment:
fixed
##########
server/src/test/java/org/apache/druid/metadata/IndexerSQLMetadataStorageCoordinatorTest.java:
##########
@@ -1208,12 +1208,64 @@ public void
testRetrieveUnusedSegmentsUsingMultipleIntervalsAndNoLimit() throws
final ImmutableList<DataSegment> actualUnusedSegments =
retrieveUnusedSegmentsUsingMultipleIntervalsAndLimit(
segments.stream().map(DataSegment::getInterval).collect(Collectors.toList()),
+ null,
null
);
Assert.assertEquals(segments.size(), actualUnusedSegments.size());
Assert.assertTrue(segments.containsAll(actualUnusedSegments));
}
+ @Test
+ public void testRetrieveUnusedSegmentsUsingNoIntervalsAndNoLimit() throws
IOException
+ {
+ final List<DataSegment> segments = createAndGetUsedYearSegments(1900,
2133);
+ markAllSegmentsUnused(new HashSet<>(segments));
+
+ final ImmutableList<DataSegment> actualUnusedSegments =
retrieveUnusedSegmentsUsingMultipleIntervalsAndLimit(
+ ImmutableList.of(),
+ null,
+ null
+ );
+ Assert.assertEquals(segments.size(), actualUnusedSegments.size());
+ Assert.assertTrue(segments.containsAll(actualUnusedSegments));
+ }
+
+ @Test
+ public void testRetrieveUnusedSegmentsUsingNoIntervalsAndNoLimitAndOffset()
throws IOException
+ {
+ final List<DataSegment> segments = createAndGetUsedYearSegments(2033,
2133);
+ markAllSegmentsUnused(new HashSet<>(segments));
+
+ int offset = 10;
+ List<DataSegment> expectedSegments =
segments.stream().sorted((Comparator<DataSegment>) (o1, o2) -> {
+ long o1Start = o1.getInterval().getStartMillis();
+ long o2Start = o2.getInterval().getStartMillis();
Review Comment:
fixed
--
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]