Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 1 addition & 18 deletions core/src/test/scala/unit/kafka/server/ReplicaManagerTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1187,8 +1187,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()
Expand Down Expand Up @@ -1245,8 +1243,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()
Expand Down Expand Up @@ -1293,7 +1289,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,
Expand Down Expand Up @@ -1343,8 +1338,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")
Expand Down Expand Up @@ -1418,8 +1411,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()
Expand Down Expand Up @@ -1489,15 +1480,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
Expand Down Expand Up @@ -1953,6 +1935,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 aliveBrokerIds = Seq[Integer](followerBrokerId, leaderBrokerId)
Expand Down