gitlw commented on code in PR #12029: URL: https://github.com/apache/kafka/pull/12029#discussion_r861766611
########## core/src/test/scala/unit/kafka/log/UnifiedLogTest.scala: ########## @@ -3410,6 +3410,53 @@ class UnifiedLogTest { assertThrows(classOf[OffsetOutOfRangeException], () => log.maybeIncrementLogStartOffset(26L, ClientRecordDeletion)) } + def testBackgroundDeletionWithIOException(): Unit = { + val logConfig = LogTestUtils.createLogConfig(segmentBytes = 1024 * 1024) + val log = createLog(logDir, logConfig) + assertEquals(1, log.numberOfSegments, "The number of segments should be 1") + + // Delete the underlying directory to trigger a KafkaStorageException + val dir = log.dir + Utils.delete(dir) + dir.createNewFile() + + var kafkaStorageExceptionCaptured = false + try { + log.delete() + } catch { + case _: KafkaStorageException => + kafkaStorageExceptionCaptured = true + } + assertTrue(kafkaStorageExceptionCaptured) + assertTrue(log.logDirFailureChannel.hasOfflineLogDir(tmpDir.toString)) + } + + /** + * test renaming a log's dir without reinitialization, which is the case during topic deletion + */ + @Test + def testRenamingDirWithoutReinitialization(): Unit = { + val logConfig = LogTestUtils.createLogConfig(segmentBytes = 1024 * 1024) + val log = createLog(logDir, logConfig) + assertEquals(1, log.numberOfSegments, "The number of segments should be 1") + + val newDir = TestUtils.randomPartitionLogDir(tmpDir) + assertTrue(newDir.exists()) + + log.renameDir(newDir.getName, false) Review Comment: That sounds reasonable to me. PR has been updated. -- 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