use of org.apache.druid.segment.incremental.RowIngestionMeters in project druid by druid-io.
the class ClosedSegmentsSinksBatchAppenderatorTest method testPushContract.
@Test(timeout = 10000L)
public void testPushContract() throws Exception {
final RowIngestionMeters rowIngestionMeters = new SimpleRowIngestionMeters();
try (final ClosedSegmensSinksBatchAppenderatorTester tester = new ClosedSegmensSinksBatchAppenderatorTester(1, 50000L, null, false, rowIngestionMeters)) {
final Appenderator appenderator = tester.getAppenderator();
appenderator.startJob();
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "bar", 1), null);
appenderator.add(IDENTIFIERS.get(0), createInputRow("2000", "bar2", 1), null);
appenderator.add(IDENTIFIERS.get(1), createInputRow("2000", "bar3", 1), null);
// push only a single segment
final SegmentsAndCommitMetadata segmentsAndCommitMetadata = appenderator.push(Collections.singletonList(IDENTIFIERS.get(0)), null, false).get();
// only one segment must have been pushed:
Assert.assertEquals(Collections.singletonList(IDENTIFIERS.get(0)), Lists.transform(segmentsAndCommitMetadata.getSegments(), SegmentIdWithShardSpec::fromDataSegment).stream().sorted().collect(Collectors.toList()));
Assert.assertEquals(tester.getPushedSegments().stream().sorted().collect(Collectors.toList()), segmentsAndCommitMetadata.getSegments().stream().sorted().collect(Collectors.toList()));
// the responsability for dropping is in the BatchAppenderatorDriver, drop manually:
appenderator.drop(IDENTIFIERS.get(0));
// and the segment that was not pushed should still be active
Assert.assertEquals(Collections.singletonList(IDENTIFIERS.get(1)), appenderator.getSegments());
}
}
Aggregations