jolshan commented on code in PR #24092:
URL: https://github.com/apache/kafka/pull/24092#discussion_r4484441490


##########
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:
   The `TransactionMarkerChannelManager` is created with the metadata cache at 
the top of the tests. I could make some changes to not do that, but didn't want 
to modify the file too much for this one bugfix test.
   
   I suppose one alternative is also to make a new manager just for this test 
with the real metadata cache if we want to remove the mock interaction there.



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