junrao commented on code in PR #19489:
URL: https://github.com/apache/kafka/pull/19489#discussion_r2635905633


##########
clients/src/test/java/org/apache/kafka/clients/producer/internals/TransactionManagerTest.java:
##########
@@ -783,16 +785,18 @@ MAX_REQUEST_SIZE, ACKS_ALL, MAX_RETRIES, new 
SenderMetricsRegistry(metrics), thi
         assertTrue(transactionManager.hasInflightBatches(tp0));
         assertEquals(1, transactionManager.sequenceNumber(tp0));
 
-        time.sleep(5000); // delivery time out
-        sender.runOnce();
+        ProducerTestUtils.runUntil(sender, () -> {
+            time.sleep(5000); // advance the "now" so NetworkClient sees the 
request as expired

Review Comment:
   > advance the "now" so NetworkClient sees the request as expired
   
   advance the time so that NetworkClient will time out the request and cause 
the future to expire.



##########
clients/src/test/java/org/apache/kafka/clients/producer/internals/SenderTest.java:
##########
@@ -2677,23 +2692,24 @@ public void testResetNextBatchExpiry() throws Exception 
{
         appendToAccumulator(tp0, 0L, "key", "value");
 
         sender.runOnce();
+        long nowBeforeSecondRun = time.milliseconds();
         sender.runOnce();
-        time.setCurrentTimeMs(time.milliseconds() + 
accumulator.getDeliveryTimeoutMs() + 1);
+        this.time.setCurrentTimeMs(this.time.milliseconds() + 
accumulator.getDeliveryTimeoutMs() + 1);

Review Comment:
   Let's be consistent with referencing `time`. We don't use `this` two lines 
above. 



##########
clients/src/test/java/org/apache/kafka/clients/producer/internals/TransactionManagerTest.java:
##########
@@ -783,16 +785,18 @@ MAX_REQUEST_SIZE, ACKS_ALL, MAX_RETRIES, new 
SenderMetricsRegistry(metrics), thi
         assertTrue(transactionManager.hasInflightBatches(tp0));
         assertEquals(1, transactionManager.sequenceNumber(tp0));
 
-        time.sleep(5000); // delivery time out
-        sender.runOnce();
+        ProducerTestUtils.runUntil(sender, () -> {
+            time.sleep(5000); // advance the "now" so NetworkClient sees the 
request as expired
+            return responseFuture1.isDone();
+        });
 
         // The retried request will remain inflight until the request timeout
         // is reached even though the delivery timeout has expired and the
         // future has completed exceptionally.
         assertTrue(responseFuture1.isDone());
-        
TestUtils.assertFutureThrowsWithMessageContaining(TimeoutException.class, 
responseFuture1, SENDER_TIMEOUT_MSG);
+        
TestUtils.assertFutureThrowsWithMessageContaining(NetworkException.class, 
responseFuture1, NETWORK_DISCONNECTED_MSG);

Review Comment:
   >         // The retried request will remain inflight until the request 
timeout
   >         // is reached even though the delivery timeout has expired and the
   >         // future has completed exceptionally.
   >         assertTrue(responseFuture1.isDone());
   
   These are no longer needed.



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