rreddy-22 commented on code in PR #17402:
URL: https://github.com/apache/kafka/pull/17402#discussion_r1819853522


##########
core/src/test/scala/integration/kafka/api/TransactionsTest.scala:
##########
@@ -759,8 +762,107 @@ class TransactionsTest extends IntegrationTestHarness {
   }
 
   @ParameterizedTest
-  @ValueSource(strings = Array("zk", "kraft"))
-  def testFailureToFenceEpoch(quorum: String): Unit = {
+  @CsvSource(Array("kraft, true"))
+  def testBumpTransactionalEpochWithTV2Enabled(quorum: String, isTV2Enabled: 
Boolean): Unit = {
+    val producer = createTransactionalProducer("transactionalProducer",
+      deliveryTimeoutMs = 5000, requestTimeoutMs = 5000)
+    val consumer = transactionalConsumers.head
+
+    try {
+      // Create a topic with RF=1 so that a single broker failure will render 
it unavailable
+      val testTopic = "test-topic"
+      createTopic(testTopic, numPartitions, 1, new Properties)
+      val partitionLeader = TestUtils.waitUntilLeaderIsKnown(brokers, new 
TopicPartition(testTopic, 0))
+
+      producer.initTransactions()
+
+      // First transaction: commit
+      producer.beginTransaction()
+      
producer.send(TestUtils.producerRecordWithExpectedTransactionStatus(testTopic, 
0, "4", "4", willBeCommitted = true))
+      producer.commitTransaction()
+
+      // Get producerId and epoch after first commit
+      val log = brokers(partitionLeader).logManager.getLog(new 
TopicPartition(testTopic, 0)).get
+      val producerStateManager = log.producerStateManager
+      val activeProducersIter = 
producerStateManager.activeProducers.entrySet().iterator()
+      assertTrue(activeProducersIter.hasNext)
+      var producerStateEntry = activeProducersIter.next().getValue
+      val producerId = producerStateEntry.producerId
+      var previousProducerEpoch = producerStateEntry.producerEpoch
+
+      // Second transaction: abort
+      producer.beginTransaction()
+      
producer.send(TestUtils.producerRecordWithExpectedTransactionStatus(topic1, 
null, "2", "2", willBeCommitted = false))
+
+      killBroker(partitionLeader)
+      val failedFuture = 
producer.send(TestUtils.producerRecordWithExpectedTransactionStatus(testTopic, 
0, "3", "3", willBeCommitted = false))
+      Thread.sleep(6000)

Review Comment:
   Test is super flaky when using waitUntilTrue for the future to complete



-- 
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: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to