This is an automated email from the ASF dual-hosted git repository.

jgus pushed a commit to branch 2.5
in repository https://gitbox.apache.org/repos/asf/kafka.git


The following commit(s) were added to refs/heads/2.5 by this push:
     new 8eddfcb  KAFKA-9544; Fix flaky test 
`AdminClientTest.testDefaultApiTimeoutOverride` (#8101)
8eddfcb is described below

commit 8eddfcbed71aa04e800f68cf2623696e439e2057
Author: Jason Gustafson <[email protected]>
AuthorDate: Wed Feb 19 09:24:26 2020 -0800

    KAFKA-9544; Fix flaky test `AdminClientTest.testDefaultApiTimeoutOverride` 
(#8101)
    
    There is a race condition with the backoff sleep in the test case and 
setting the next allowed send time in the AdminClient. To fix it, we allow the 
test case to do the backoff sleep multiple times if needed.
    
    Reviewers: Rajini Sivaram <[email protected]>
---
 .../org/apache/kafka/clients/admin/KafkaAdminClientTest.java     | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git 
a/clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
 
b/clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
index 65a3436..28b4640 100644
--- 
a/clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
+++ 
b/clients/src/test/java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java
@@ -2740,11 +2740,14 @@ public class KafkaAdminClientTest {
             // Wait for the request to be timed out before backing off
             TestUtils.waitForCondition(() -> 
!env.kafkaClient().hasInFlightRequests(),
                     "Timed out waiting for inFlightRequests to be timed out");
-            time.sleep(retryBackoffMs);
 
             // Since api timeout bound is not hit, AdminClient should retry
-            TestUtils.waitForCondition(() -> 
env.kafkaClient().hasInFlightRequests(),
-                    "Timed out waiting for Metadata request to be sent");
+            TestUtils.waitForCondition(() -> {
+                boolean hasInflightRequests = 
env.kafkaClient().hasInFlightRequests();
+                if (!hasInflightRequests)
+                    time.sleep(retryBackoffMs);
+                return hasInflightRequests;
+            }, "Timed out waiting for Metadata request to be sent");
             time.sleep(requestTimeoutMs + 1);
 
             TestUtils.assertFutureThrows(result.future, 
TimeoutException.class);

Reply via email to