SEKIRO-J commented on a change in pull request #8748: Use earliest offset on kafka newly discovered partitions URL: https://github.com/apache/incubator-druid/pull/8748#discussion_r342334184
########## File path: extensions-core/kafka-indexing-service/src/test/java/org/apache/druid/indexing/kafka/supervisor/KafkaSupervisorTest.java ########## @@ -585,6 +589,108 @@ public void testLatestOffset() throws Exception ); } + /** + * Test if partitionIds get updated + */ + @Test + public void testPartitionIdsUpdates() throws Exception + { + supervisor = getTestableSupervisor(1, 1, false, "PT1H", null, null); + addSomeEvents(1100); + + Capture<KafkaIndexTask> captured = Capture.newInstance(); + EasyMock.expect(taskMaster.getTaskQueue()).andReturn(Optional.of(taskQueue)).anyTimes(); + EasyMock.expect(taskMaster.getTaskRunner()).andReturn(Optional.absent()).anyTimes(); + EasyMock.expect(taskStorage.getActiveTasksByDatasource(DATASOURCE)).andReturn(ImmutableList.of()).anyTimes(); + EasyMock.expect(indexerMetadataStorageCoordinator.getDataSourceMetadata(DATASOURCE)).andReturn( + new KafkaDataSourceMetadata( + null + ) + ).anyTimes(); + EasyMock.expect(taskQueue.add(EasyMock.capture(captured))).andReturn(true); + replayAll(); + + supervisor.start(); + supervisor.runInternal(); + verifyAll(); + + Assert.assertFalse(supervisor.isPartitionIdsEmpty()); + } + + + /** + * Test For if always use earliest offset on newly discovered partitions + */ + @Ignore("This is a regression test that needs to wait 10s+, ignore for now") + @Test + public void testLatestOffsetOnDiscovery() throws Exception + { + supervisor = getTestableSupervisor(1, 1, false, "PT1H", null, null); + addSomeEvents(9); + + Capture<KafkaIndexTask> captured = Capture.newInstance(); + EasyMock.expect(taskMaster.getTaskQueue()).andReturn(Optional.of(taskQueue)).anyTimes(); + EasyMock.expect(taskMaster.getTaskRunner()).andReturn(Optional.absent()).anyTimes(); + EasyMock.expect(taskStorage.getActiveTasksByDatasource(DATASOURCE)).andReturn(ImmutableList.of()).anyTimes(); + EasyMock.expect(indexerMetadataStorageCoordinator.getDataSourceMetadata(DATASOURCE)).andReturn( + new KafkaDataSourceMetadata( + null + ) + ).anyTimes(); + EasyMock.expect(taskQueue.add(EasyMock.capture(captured))).andReturn(true); + replayAll(); + supervisor.start(); + supervisor.runInternal(); + verifyAll(); + + KafkaIndexTask task = captured.getValue(); + Assert.assertEquals( + 10, + task.getIOConfig().getStartSequenceNumbers().getPartitionSequenceNumberMap().get(0).longValue() + ); + Assert.assertEquals( + 10, + task.getIOConfig().getStartSequenceNumbers().getPartitionSequenceNumberMap().get(1).longValue() + ); + Assert.assertEquals( + 10, + task.getIOConfig().getStartSequenceNumbers().getPartitionSequenceNumberMap().get(2).longValue() + ); + + addMoreEvents(9, 6); + Thread.sleep(10000); Review comment: https://github.com/apache/incubator-druid/pull/8748#discussion_r342276353 ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@druid.apache.org For additional commands, e-mail: commits-h...@druid.apache.org