junrao commented on code in PR #15621: URL: https://github.com/apache/kafka/pull/15621#discussion_r1556068446
########## core/src/test/scala/integration/kafka/admin/ListOffsetsIntegrationTest.scala: ########## @@ -56,11 +60,33 @@ class ListOffsetsIntegrationTest extends KafkaServerTestHarness { @AfterEach override def tearDown(): Unit = { - setOldMessageFormat = false Utils.closeQuietly(adminClient, "ListOffsetsAdminClient") super.tearDown() } + @ParameterizedTest + @ValueSource(strings = Array("zk", "kraft")) + def testListMaxTimestampWithEmptyLog(quorum: String): Unit = { + val maxTimestampOffset = runFetchOffsets(adminClient, OffsetSpec.maxTimestamp(), topicName) + assertEquals(ListOffsetsResponse.UNKNOWN_OFFSET, maxTimestampOffset.offset()) + assertEquals(ListOffsetsResponse.UNKNOWN_TIMESTAMP, maxTimestampOffset.timestamp()) + } + + @ParameterizedTest + @ValueSource(strings = Array("zk")) + def testListVersion0(quorum: String): Unit = { + // create records for version 0 + createMessageFormatBrokers(RecordBatch.MAGIC_VALUE_V0) + produceMessagesInSeparateBatch() + + // update version to version 1 to list offset for max timestamp + createMessageFormatBrokers(RecordBatch.MAGIC_VALUE_V1) + // the offset of max timestamp is always -1 if the batch version is 0 + verifyListOffsets(expectedMaxTimestampOffset = -1) + Review Comment: extra new line ########## core/src/test/scala/integration/kafka/admin/ListOffsetsIntegrationTest.scala: ########## @@ -123,7 +149,7 @@ class ListOffsetsIntegrationTest extends KafkaServerTestHarness { @ParameterizedTest @ValueSource(strings = Array("zk")) def testThreeRecordsInSeparateBatchWithMessageConversion(quorum: String): Unit = { - createOldMessageFormatBrokers() + createMessageFormatBrokers(RecordBatch.MAGIC_VALUE_V1) Review Comment: > // In LogAppendTime's case, the maxTimestampOffset should be the first message of the batch. > // So in this separate batch test, it'll be the last offset 2 The comment in line 159 is not very accurate. Since we advance the time for each batch, the maxTimestampOffset is the message in the last batch. -- 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