You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "kowshik (via GitHub)" <gi...@apache.org> on 2023/02/18 05:29:26 UTC

[GitHub] [kafka] kowshik commented on a diff in pull request #13272: MINOR: Add missing unit tests for {Local|Remote}LeaderEndpoint classes

kowshik commented on code in PR #13272:
URL: https://github.com/apache/kafka/pull/13272#discussion_r1110637054


##########
core/src/test/scala/kafka/server/LocalLeaderEndPointTest.scala:
##########
@@ -118,6 +120,46 @@ class LocalLeaderEndPointTest {
     assertEquals((4, 3L), endPoint.fetchEarliestLocalOffset(topicPartition, currentLeaderEpoch = 7))
   }
 
+  @Test
+  def testFetchEpochEndOffsets(): Unit = {
+    appendRecords(replicaManager, topicPartition, records)
+      .onFire(response => assertEquals(Errors.NONE, response.error))
+
+    var result = endPoint.fetchEpochEndOffsets(Map(
+      topicPartition -> new OffsetForLeaderPartition()
+        .setPartition(topicPartition.partition)
+        .setLeaderEpoch(0)))
+
+    var expected = Map(
+      topicPartition -> new EpochEndOffset()
+        .setPartition(topicPartition.partition)
+        .setErrorCode(Errors.NONE.code)
+        .setLeaderEpoch(0)
+        .setEndOffset(3L))
+
+    assertEquals(expected, result)
+
+    // Change leader epoch and end offset, and verify the behavior again.
+    val leaderAndIsrRequest = buildLeaderAndIsrRequest(leaderEpoch = 4)
+    replicaManager.becomeLeaderOrFollower(0, leaderAndIsrRequest, (_, _) => ())
+    appendRecords(replicaManager, topicPartition, records)
+      .onFire(response => assertEquals(Errors.NONE, response.error))
+
+    result = endPoint.fetchEpochEndOffsets(Map(
+      topicPartition -> new OffsetForLeaderPartition()
+        .setPartition(topicPartition.partition)
+        .setLeaderEpoch(4)))
+
+    expected = Map(
+      topicPartition -> new EpochEndOffset()
+        .setPartition(topicPartition.partition)
+        .setErrorCode(Errors.NONE.code)
+        .setLeaderEpoch(4)
+        .setEndOffset(6L))
+
+    assertEquals(expected, result)

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-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org