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


##########
core/src/test/scala/unit/kafka/coordinator/transaction/TransactionMarkerChannelManagerTest.scala:
##########
@@ -400,6 +404,107 @@ 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())
+    val cache = new KRaftMetadataCache(0, () => KRaftVersion.KRAFT_VERSION_0)
+    val topicId = Uuid.randomUuid()
+    val listenerName = 
ListenerName.forSecurityProtocol(SecurityProtocol.PLAINTEXT)
+
+    // Send the getPartitionLeaderEndpoint request to the real metadata cache.
+    when(metadataCache.getPartitionLeaderEndpoint(
+      anyString(),
+      anyInt(),
+      any[ListenerName]())
+    ).thenAnswer(invocation => {
+      cache.getPartitionLeaderEndpoint(
+        invocation.getArgument(0),
+        invocation.getArgument(1),
+        invocation.getArgument(2))
+    })

Review Comment:
   Thanks for making the changes! Can we get away without this and pass `cache` 
directly to the `TransactionMarkerChannelManager`?



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