squah-confluent commented on code in PR #24092:
URL: https://github.com/apache/kafka/pull/24092#discussion_r4482257454


##########
core/src/test/scala/unit/kafka/server/MetadataCacheTest.scala:
##########
@@ -982,6 +982,54 @@ class MetadataCacheTest {
     assertTrue(fencedBroker.isFenced)
   }
 
+  @Test def testGetPartitionLeaderEndpointForKnownPartitionWithoutEndpoint(): 
Unit = {
+    val metadataCache = new KRaftMetadataCache(0, () => 
KRaftVersion.KRAFT_VERSION_0)

Review Comment:
   nit: Should this be
   
   ```suggestion
     @ParameterizedTest
     @MethodSource(Array("cacheProvider"))
     def testGetPartitionLeaderEndpointForKnownPartitionWithoutEndpoint(cache: 
MetadataCache): Unit = {
   ```
   ? It seems to be the equivalent of `createCache` in 4.3



##########
core/src/test/scala/unit/kafka/server/MetadataCacheTest.scala:
##########
@@ -982,6 +982,54 @@ class MetadataCacheTest {
     assertTrue(fencedBroker.isFenced)
   }
 
+  @Test def testGetPartitionLeaderEndpointForKnownPartitionWithoutEndpoint(): 
Unit = {
+    val metadataCache = new KRaftMetadataCache(0, () => 
KRaftVersion.KRAFT_VERSION_0)
+    val listenerName = 
ListenerName.forSecurityProtocol(SecurityProtocol.PLAINTEXT)
+    val topic = "topic"
+    val topicId = Uuid.randomUuid
+    val records = Seq(new RegisterBrokerRecord()
+      .setBrokerId(0)
+      .setBrokerEpoch(0L)
+      .setRack(null)
+      .setFenced(false)
+      .setEndPoints(new BrokerEndpointCollection(Seq(new BrokerEndpoint()
+        .setHost("foo0")
+        .setPort(9092)
+        .setSecurityProtocol(SecurityProtocol.PLAINTEXT.id)
+        .setName(listenerName.value)).iterator.asJava)),
+      new TopicRecord()
+        .setName(topic)
+        .setTopicId(topicId),
+      new PartitionRecord()
+        .setTopicId(topicId)
+        .setPartitionId(0)
+        .setLeader(0)
+        .setLeaderEpoch(0)
+        .setPartitionEpoch(0)
+        .setIsr(util.List.of(0)).setReplicas(util.List.of(0)),

Review Comment:
   nit:
   ```suggestion
           .setIsr(util.List.of(0))
           .setReplicas(util.List.of(0)),
   ```



##########
core/src/test/scala/unit/kafka/server/MetadataCacheTest.scala:
##########
@@ -982,6 +982,54 @@ class MetadataCacheTest {
     assertTrue(fencedBroker.isFenced)
   }
 
+  @Test def testGetPartitionLeaderEndpointForKnownPartitionWithoutEndpoint(): 
Unit = {
+    val metadataCache = new KRaftMetadataCache(0, () => 
KRaftVersion.KRAFT_VERSION_0)
+    val listenerName = 
ListenerName.forSecurityProtocol(SecurityProtocol.PLAINTEXT)
+    val topic = "topic"
+    val topicId = Uuid.randomUuid
+    val records = Seq(new RegisterBrokerRecord()
+      .setBrokerId(0)
+      .setBrokerEpoch(0L)

Review Comment:
   ```suggestion
         .setBrokerEpoch(brokerEpoch)
   ```
   seems to be the 4.3 equivalent



##########
core/src/test/scala/unit/kafka/coordinator/transaction/TransactionMarkerChannelManagerTest.scala:
##########
@@ -400,6 +400,70 @@ class TransactionMarkerChannelManagerTest {
     assertEquals(Map(broker1 -> expectedBroker1Request), secondDrainedRequests)
   }
 
+  @ParameterizedTest
+  @EnumSource(classOf[TransactionResult])
+  def shouldRetryMarkersUntilLeaderEndpointIsAvailable(result: 
TransactionResult): Unit = {
+    mockCache()
+    txnMetadata2.state(if (result == TransactionResult.COMMIT) 
TransactionState.PREPARE_COMMIT else TransactionState.PREPARE_ABORT)
+    val expectedTransition = txnMetadata2.prepareComplete(time.milliseconds())
+    // Return noNode for addTxnMarkersToSend, and the first two 
generateRequests()
+    when(metadataCache.getPartitionLeaderEndpoint(
+      ArgumentMatchers.eq(partition1.topic),
+      ArgumentMatchers.eq(partition1.partition),
+      any())
+    ).thenReturn(Optional.of(Node.noNode))
+      .thenReturn(Optional.of(Node.noNode))
+      .thenReturn(Optional.of(Node.noNode))
+      .thenReturn(Optional.of(broker1)
+    )

Review Comment:
   Is `MetadataCacheTest.updateCache` really not visible from here?



##########
core/src/test/scala/unit/kafka/server/MetadataCacheTest.scala:
##########
@@ -982,6 +982,54 @@ class MetadataCacheTest {
     assertTrue(fencedBroker.isFenced)
   }
 
+  @Test def testGetPartitionLeaderEndpointForKnownPartitionWithoutEndpoint(): 
Unit = {
+    val metadataCache = new KRaftMetadataCache(0, () => 
KRaftVersion.KRAFT_VERSION_0)
+    val listenerName = 
ListenerName.forSecurityProtocol(SecurityProtocol.PLAINTEXT)
+    val topic = "topic"
+    val topicId = Uuid.randomUuid
+    val records = Seq(new RegisterBrokerRecord()
+      .setBrokerId(0)
+      .setBrokerEpoch(0L)
+      .setRack(null)
+      .setFenced(false)
+      .setEndPoints(new BrokerEndpointCollection(Seq(new BrokerEndpoint()
+        .setHost("foo0")
+        .setPort(9092)
+        .setSecurityProtocol(SecurityProtocol.PLAINTEXT.id)
+        .setName(listenerName.value)).iterator.asJava)),
+      new TopicRecord()
+        .setName(topic)
+        .setTopicId(topicId),
+      new PartitionRecord()
+        .setTopicId(topicId)
+        .setPartitionId(0)
+        .setLeader(0)
+        .setLeaderEpoch(0)
+        .setPartitionEpoch(0)
+        .setIsr(util.List.of(0)).setReplicas(util.List.of(0)),
+      new PartitionRecord()
+        .setTopicId(topicId)
+        .setPartitionId(1)
+        .setLeader(1)
+        .setLeaderEpoch(0)
+        .setPartitionEpoch(0)
+        .setIsr(util.List.of(1))
+        .setReplicas(util.List.of(1)),
+      new PartitionRecord()
+        .setTopicId(topicId)
+        .setPartitionId(2)
+        .setLeader(LeaderConstants.NO_LEADER)
+        .setLeaderEpoch(0).setPartitionEpoch(0)
+        .setIsr(util.List.of).setReplicas(util.List.of(0)))

Review Comment:
   ```suggestion
           .setLeaderEpoch(0)
           .setPartitionEpoch(0)
           .setIsr(util.List.of)
           .setReplicas(util.List.of(0)))
   ```



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to