This is an automated email from the ASF dual-hosted git repository. jsancio pushed a commit to branch trunk in repository https://gitbox.apache.org/repos/asf/kafka.git
The following commit(s) were added to refs/heads/trunk by this push: new f421c008aa MINOR: Remove ReplicaManagerTest.initializeLogAndTopicId (#12276) f421c008aa is described below commit f421c008aa0495441ce6f017cdd041937a26d10f Author: Ismael Juma <ism...@juma.me.uk> AuthorDate: Tue Jun 14 09:10:18 2022 -0700 MINOR: Remove ReplicaManagerTest.initializeLogAndTopicId (#12276) The workaround is not required with mockito. Reviewers: José Armando García Sancio <jsan...@users.noreply.github.com>, Divij Vaidya <di...@amazon.com>, Kvicii <42023367+kvi...@users.noreply.github.com> --- .../scala/unit/kafka/server/ReplicaManagerTest.scala | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala b/core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala index b40c302fa9..8050a36d1d 100644 --- a/core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala +++ b/core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala @@ -1188,8 +1188,6 @@ class ReplicaManagerTest { val tp0 = new TopicPartition(topic, 0) val tidp0 = new TopicIdPartition(topicId, tp0) - initializeLogAndTopicId(replicaManager, tp0, topicId) - // Make this replica the follower val leaderAndIsrRequest2 = new LeaderAndIsrRequest.Builder(ApiKeys.LEADER_AND_ISR.latestVersion, 0, 0, brokerEpoch, Seq(new LeaderAndIsrPartitionState() @@ -1246,8 +1244,6 @@ class ReplicaManagerTest { val tp0 = new TopicPartition(topic, 0) val tidp0 = new TopicIdPartition(topicId, tp0) - initializeLogAndTopicId(replicaManager, tp0, topicId) - // Make this replica the leader val leaderAndIsrRequest2 = new LeaderAndIsrRequest.Builder(ApiKeys.LEADER_AND_ISR.latestVersion, 0, 0, brokerEpoch, Seq(new LeaderAndIsrPartitionState() @@ -1294,7 +1290,6 @@ class ReplicaManagerTest { val topicId = Uuid.randomUuid() val tp0 = new TopicPartition(topic, 0) val tidp0 = new TopicIdPartition(topicId, tp0) - initializeLogAndTopicId(replicaManager, tp0, topicId) // Make this replica the follower val leaderAndIsrRequest = new LeaderAndIsrRequest.Builder(ApiKeys.LEADER_AND_ISR.latestVersion, 0, 0, brokerEpoch, @@ -1344,8 +1339,6 @@ class ReplicaManagerTest { val tp0 = new TopicPartition(topic, 0) val tidp0 = new TopicIdPartition(topicId, tp0) - initializeLogAndTopicId(replicaManager, tp0, topicId) - when(replicaManager.metadataCache.getPartitionReplicaEndpoints( tp0, new ListenerName("default") @@ -1419,8 +1412,6 @@ class ReplicaManagerTest { val tp0 = new TopicPartition(topic, 0) val tidp0 = new TopicIdPartition(topicId, tp0) - initializeLogAndTopicId(replicaManager, tp0, topicId) - // Make this replica the follower val leaderAndIsrRequest2 = new LeaderAndIsrRequest.Builder(ApiKeys.LEADER_AND_ISR.latestVersion, 0, 0, brokerEpoch, Seq(new LeaderAndIsrPartitionState() @@ -1490,15 +1481,6 @@ class ReplicaManagerTest { leaderBrokerId, countDownLatch, expectTruncation = true, extraProps = props)) } - // Due to some limitations to EasyMock, we need to create the log so that the Partition.topicId does not call - // LogManager.getLog with a default argument - // TODO: convert tests to using Mockito to avoid this issue. - private def initializeLogAndTopicId(replicaManager: ReplicaManager, topicPartition: TopicPartition, topicId: Uuid): Unit = { - val partition = replicaManager.createPartition(new TopicPartition(topic, 0)) - val log = replicaManager.logManager.getOrCreateLog(topicPartition, false, false, Some(topicId)) - partition.log = Some(log) - } - @Test def testDefaultReplicaSelector(): Unit = { val topicPartition = 0 @@ -1954,6 +1936,7 @@ class ReplicaManagerTest { val mockLogMgr: LogManager = mock(classOf[LogManager]) when(mockLogMgr.liveLogDirs).thenReturn(config.logDirs.map(new File(_).getAbsoluteFile)) when(mockLogMgr.getOrCreateLog(ArgumentMatchers.eq(topicPartitionObj), ArgumentMatchers.eq(false), ArgumentMatchers.eq(false), any())).thenReturn(mockLog) + when(mockLogMgr.getLog(topicPartitionObj, isFuture = false)).thenReturn(Some(mockLog)) when(mockLogMgr.getLog(topicPartitionObj, isFuture = true)).thenReturn(None) val allLogs = new Pool[TopicPartition, UnifiedLog]() allLogs.put(topicPartitionObj, mockLog)