chia7712 commented on a change in pull request #9649:
URL: https://github.com/apache/kafka/pull/9649#discussion_r551683555



##########
File path: core/src/test/scala/unit/kafka/server/AlterIsrManagerTest.scala
##########
@@ -174,13 +172,24 @@ class AlterIsrManagerTest {
   }
 
   @Test
-  def testPartitionErrors(): Unit = {
-    val errors = Seq(Errors.INVALID_UPDATE_VERSION, 
Errors.UNKNOWN_TOPIC_OR_PARTITION, Errors.NOT_LEADER_OR_FOLLOWER)
-    errors.foreach(error => {
-      val alterIsrManager = testPartitionError(tp0, error)
-      // Any partition-level error should clear the item from the pending 
queue allowing for future updates
-      assertTrue(alterIsrManager.submit(AlterIsrItem(tp0, null, _ => { }, 0)))
-    })
+  def testInvalidUpdateVersion(): Unit = {
+    checkPartitionError(Errors.INVALID_UPDATE_VERSION)
+  }
+
+  @Test
+  def testUnknownTopicPartition(): Unit = {
+    checkPartitionError(Errors.UNKNOWN_TOPIC_OR_PARTITION)
+  }
+
+  @Test
+  def testNotLeaderOrFollower(): Unit = {
+    checkPartitionError(Errors.NOT_LEADER_OR_FOLLOWER)
+  }
+
+  def checkPartitionError(error: Errors): Unit = {

Review comment:
       ditto

##########
File path: core/src/test/scala/unit/kafka/server/AlterIsrManagerTest.scala
##########
@@ -127,26 +127,24 @@ class AlterIsrManagerTest {
 
   @Test
   def testAuthorizationFailed(): Unit = {
-    val isrs = Seq(AlterIsrItem(tp0, new LeaderAndIsr(1, 1, List(1,2,3), 10), 
_ => { }, 0))
-    val manager = testTopLevelError(isrs, Errors.CLUSTER_AUTHORIZATION_FAILED)
-    // On authz error, we log the exception and keep retrying
-    assertFalse(manager.submit(AlterIsrItem(tp0, null, _ => { }, 0)))
+    checkTopLevelError(Errors.CLUSTER_AUTHORIZATION_FAILED)
   }
 
   @Test
   def testStaleBrokerEpoch(): Unit = {
-    val isrs = Seq(AlterIsrItem(tp0, new LeaderAndIsr(1, 1, List(1,2,3), 10), 
_ => { }, 0))
-    val manager = testTopLevelError(isrs, Errors.STALE_BROKER_EPOCH)
-    // On stale broker epoch, we want to retry, so we don't clear items from 
the pending map
-    assertFalse(manager.submit(AlterIsrItem(tp0, null, _ => { }, 0)))
+    checkTopLevelError(Errors.STALE_BROKER_EPOCH)
   }
 
   @Test
-  def testOtherErrors(): Unit = {
+  def testUnknownServer(): Unit = {
+    checkTopLevelError(Errors.UNKNOWN_SERVER_ERROR)
+  }
+
+  def checkTopLevelError(error: Errors): Unit = {

Review comment:
       Could you change it to ```private``` method?




----------------------------------------------------------------
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.

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


Reply via email to