MINOR: Combine repeated top-level error test in AlterIsrManagerTest
Reviewers: Chia-Ping Tsai David Arthur
@@ -127,29 +127,27 @@ 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)
+ }
+
+ private def checkTopLevelError(error: Errors): Unit = {
val isrs = Seq(AlterIsrItem(tp0, new LeaderAndIsr(1, 1, List(1,2,3), 10), _ => { }, 0))
- val manager = testTopLevelError(isrs, Errors.UNKNOWN_SERVER_ERROR)
- // On other unexpected errors, we also want to retry
- assertFalse(manager.submit(AlterIsrItem(tp0, null, _ => { }, 0)))
+ val alterIsrManager = testTopLevelError(isrs, error)
+ // Any top-level error, we want to retry, so we don't clear items from the pending map
+ assertFalse(alterIsrManager.submit(AlterIsrItem(tp0, null, _ => { }, 0)))
}
- def testTopLevelError(isrs: Seq[AlterIsrItem], error: Errors): AlterIsrManager = {
+ private def testTopLevelError(isrs: Seq[AlterIsrItem], error: Errors): AlterIsrManager = {
val callbackCapture = EasyMock.newCapture[ControllerRequestCompletionHandler]()
EasyMock.expect(brokerToController.start())
@@ -174,16 +172,27 @@ 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 => {
+ 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)
+ }
+
+ private def checkPartitionError(error: Errors): Unit = {
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 testPartitionError(tp: TopicPartition, error: Errors): AlterIsrManager = {
+ private def testPartitionError(tp: TopicPartition, error: Errors): AlterIsrManager = {
val callbackCapture = EasyMock.newCapture[ControllerRequestCompletionHandler]()
EasyMock.reset(brokerToController)
EasyMock.expect(brokerToController.start())
