chia7712 commented on code in PR #16085: URL: https://github.com/apache/kafka/pull/16085#discussion_r1616250511
########## core/src/test/scala/unit/kafka/log/LogSegmentsTest.scala: ########## @@ -105,8 +109,6 @@ class LogSegmentsTest { assertFalse(segments.nonEmpty) assertEquals(0, segments.numberOfSegments) assertFalse(segments.contains(offset1)) - - segments.close() Review Comment: why removing this line? ########## core/src/test/scala/unit/kafka/log/LogSegmentsTest.scala: ########## @@ -238,5 +248,39 @@ class LogSegmentsTest { assertEquals(Int.MaxValue, LogSegments.sizeInBytes(asList(logSegment))) assertEquals(largeSize, LogSegments.sizeInBytes(asList(logSegment, logSegment))) assertTrue(UnifiedLog.sizeInBytes(asList(logSegment, logSegment)) > Int.MaxValue) + + val logSegments: LogSegments = new LogSegments(topicPartition) + logSegments.add(logSegment) + assertEquals(Int.MaxValue, logSegments.sizeInBytes()) + } + + @Test + def testUpdateDir(): Unit = { + val seg1 = createSegment(1) + val segments = new LogSegments(topicPartition) + segments.add(seg1) + + val newDir: File = TestUtils.tempDir() + segments.updateParentDir(newDir) + assertEquals(newDir, seg1.log().file().getParentFile) + assertEquals(newDir, seg1.timeIndexFile().getParentFile) + assertEquals(newDir, seg1.offsetIndexFile().getParentFile) + assertEquals(newDir, seg1.txnIndex().file().getParentFile) + + Utils.delete(newDir) + } + + @Test + def testGetFirstBatchTimestampForSegments(): Unit = { + val segments: java.util.List[LogSegment] = new util.ArrayList[LogSegment]() + val seg1 = createSegment(1) + val seg2 = createSegment(2) + segments.add(seg1) + segments.add(seg2) + assertEquals(Seq(Long.MaxValue, Long.MaxValue), LogSegments.getFirstBatchTimestampForSegments(segments).asScala.toSeq) Review Comment: It seems `getFirstBatchTimestampForSegments` is used by `UnifiedLog` only, so we should move this helper to `UnifiedLog` https://github.com/apache/kafka/blob/bac8df56ffdf8a64ecfb78ec0779bcbc8e9f7c10/core/src/main/scala/kafka/log/UnifiedLog.scala#L1921 -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org