iit2009060 commented on code in PR #14482: URL: https://github.com/apache/kafka/pull/14482#discussion_r1348385649
########## core/src/test/scala/unit/kafka/log/remote/RemoteIndexCacheTest.scala: ########## @@ -524,23 +527,239 @@ class RemoteIndexCacheTest { } } - @Test - def testCorruptOffsetIndexFileExistsButNotInCache(): Unit = { - // create Corrupt Offset Index File - createCorruptRemoteIndexCacheOffsetFile() + @ParameterizedTest + @EnumSource(value = classOf[IndexType], names = Array("OFFSET", "TIMESTAMP", "TRANSACTION")) + def testCorruptCacheIndexFileExistsButNotInCache(indexType: IndexType): Unit = { + // create Corrupt Index File in remote index cache + if (indexType == IndexType.OFFSET) { + createCorruptOffsetIndexFile(cache.cacheDir()) + } + else if (indexType == IndexType.TIMESTAMP) { + createCorruptTimeIndexOffsetFile(cache.cacheDir()) + } + else if (indexType == IndexType.TRANSACTION) { + createCorruptTxnIndexForSegmentMetadata(cache.cacheDir(), rlsMetadata) + } val entry = cache.getIndexEntry(rlsMetadata) // Test would fail if it throws corrupt Exception - val expectedOffsetIndexFileName: String = remoteOffsetIndexFileName(rlsMetadata) val offsetIndexFile = entry.offsetIndex.file().toPath + val txnIndexFile = entry.txnIndex.file().toPath + val timeIndexFile = entry.timeIndex.file().toPath + + val expectedOffsetIndexFileName: String = remoteOffsetIndexFileName(rlsMetadata) + val expectedTimeIndexFileName: String = remoteTimeIndexFileName(rlsMetadata) + val expectedTxnIndexFileName: String = remoteTransactionIndexFileName(rlsMetadata) assertEquals(expectedOffsetIndexFileName, offsetIndexFile.getFileName.toString) + assertEquals(expectedTxnIndexFileName, txnIndexFile.getFileName.toString) + assertEquals(expectedTimeIndexFileName, timeIndexFile.getFileName.toString) + // assert that parent directory for the index files is correct assertEquals(RemoteIndexCache.DIR_NAME, offsetIndexFile.getParent.getFileName.toString, - s"offsetIndex=$offsetIndexFile is not overwrite under incorrect parent") + s"offsetIndex=entry.offsetIndex().file().toPath is created under incorrect parent") Review Comment: done -- 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