RamanVerma commented on code in PR #15384:
URL: https://github.com/apache/kafka/pull/15384#discussion_r1499456622


##########
core/src/test/scala/unit/kafka/coordinator/transaction/TransactionStateManagerTest.scala:
##########
@@ -527,16 +532,20 @@ class TransactionStateManagerTest {
     def assertListTransactions(
       expectedTransactionalIds: Set[String],
       filterProducerIds: Set[Long] = Set.empty,
-      filterStates: Set[String] = Set.empty
+      filterStates: Set[String] = Set.empty,
+      filterDuration: Long = -1L
     ): Unit = {
-      val listResponse = 
transactionManager.listTransactionStates(filterProducerIds, filterStates)
+      val listResponse = 
transactionManager.listTransactionStates(filterProducerIds, filterStates, 
filterDuration)
       assertEquals(Errors.NONE, Errors.forCode(listResponse.errorCode))
       assertEquals(expectedTransactionalIds, 
listResponse.transactionStates.asScala.map(_.transactionalId).toSet)
       val expectedUnknownStates = filterStates.filter(state => 
TransactionState.fromName(state).isEmpty)
       assertEquals(expectedUnknownStates, 
listResponse.unknownStateFilters.asScala.toSet)
     }
-
     assertListTransactions(Set("t0", "t1", "t2", "t3", "t4", "t5", "t6", "t7"))
+    assertListTransactions(Set("t0", "t1", "t2", "t3", "t4", "t5", "t6", 
"t7"), filterDuration = 0L)
+    assertListTransactions(Set("t0", "t1", "t2", "t3"), filterDuration = 1000L)
+    assertListTransactions(Set("t0", "t1"), filterDuration = 2000L)

Review Comment:
   curious: why are we not getting t2 and t3 in this test (duration greater 
than 2000L)



##########
core/src/test/scala/unit/kafka/coordinator/transaction/TransactionStateManagerTest.scala:
##########
@@ -513,12 +514,16 @@ class TransactionStateManagerTest {
 
     putTransaction(transactionalId = "t0", producerId = 0, state = Ongoing)
     putTransaction(transactionalId = "t1", producerId = 1, state = Ongoing)
+    // update time to create transactions with various durations
+    time.sleep(1000)
     putTransaction(transactionalId = "t2", producerId = 2, state = 
PrepareCommit)
     putTransaction(transactionalId = "t3", producerId = 3, state = 
PrepareAbort)
+    time.sleep(1000)

Review Comment:
   We should reduce the sleep times to 100s of ms rather than 1000s. Similarly, 
change lines 545-548. This will speed up the test and still serve our purpose.



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