mjsax commented on code in PR #17527:
URL: https://github.com/apache/kafka/pull/17527#discussion_r1809644709


##########
clients/src/test/java/org/apache/kafka/clients/MockClient.java:
##########
@@ -138,7 +139,11 @@ public long connectionDelay(Node node, long now) {
 
     @Override
     public long pollDelayMs(Node node, long now) {
-        return connectionDelay(node, now);
+        return connectionState(node.idString()).pollDelayMs(now);
+    }
+
+    public void setAdvanceTimeDuringPoll(boolean advanceTimeDuringPoll) {

Review Comment:
   ```suggestion
       public void advanceTimeDuringPoll(boolean advanceTimeDuringPoll) {
   ```



##########
clients/src/test/java/org/apache/kafka/clients/producer/internals/SenderTest.java:
##########
@@ -567,6 +567,44 @@ public void testMetadataTopicExpiry() throws Exception {
         assertTrue(future.isDone(), "Request should be completed");
     }
 
+    @Test
+    public void 
senderThreadShouldNotGetStuckWhenThrottledAndAddingPartitionsToTxn() {
+        // We want MockClient#poll() to advance time so that eventually the 
backoff expires.
+        client.setAdvanceTimeDuringPoll(true);

Review Comment:
   Could be replace with `this.time = new MockTime(1L);` (or some other 
auto-tick value)?



##########
clients/src/test/java/org/apache/kafka/clients/MockClient.java:
##########
@@ -336,6 +336,12 @@ public List<ClientResponse> poll(long timeoutMs, long now) 
{
             copy.add(response);
         }
 
+        if (copy.isEmpty()) {
+            // Simulate time advancing. If no responses are received, then we 
know that
+            // we waited for the whole timeoutMs.
+            time.sleep(timeoutMs);

Review Comment:
   Should work, too, but why don't you just create `new MockTime(1L)` and use 
the already existing "auto-tick" feature?



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