kafka-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From maniku...@apache.org
Subject [kafka] branch 2.2 updated: KAFKA-7939: Fix timing issue in KafkaAdminClientTest.testCreateTopicsRetryBackoff
Date Mon, 11 Mar 2019 14:19:43 GMT
This is an automated email from the ASF dual-hosted git repository.

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


The following commit(s) were added to refs/heads/2.2 by this push:
     new 28c807d  KAFKA-7939: Fix timing issue in KafkaAdminClientTest.testCreateTopicsRetryBackoff
28c807d is described below

commit 28c807d9fb87fb80cc6fb6833f4847b13a609496
Author: Manikumar Reddy <manikumar.reddy@gmail.com>
AuthorDate: Mon Mar 11 19:48:52 2019 +0530

    KAFKA-7939: Fix timing issue in KafkaAdminClientTest.testCreateTopicsRetryBackoff
    
    There is a small timing window where ```time.sleep(retryBackoff)``` will get executed
before adminClient adds retry request to the queue.  Added a check to wait until the retry
call added to the queue in AdminClient.
    
    Author: Manikumar Reddy <manikumar.reddy@gmail.com>
    
    Reviewers: Rajini Sivaram <rajinisivaram@googlemail.com>
    
    Closes #6418 from omkreddy/KAFKA-7939
    
    (cherry picked from commit 173a7e3d54ede6616037d6c55057417dfeb44ab9)
    Signed-off-by: Manikumar Reddy <manikumar@confluent.io>
---
 .../main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java   | 5 +++++
 .../java/org/apache/kafka/clients/admin/KafkaAdminClientTest.java    | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java b/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java
index 58baab7..f983cbb 100644
--- a/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java
+++ b/clients/src/main/java/org/apache/kafka/clients/admin/KafkaAdminClient.java
@@ -1248,6 +1248,11 @@ public class KafkaAdminClient extends AdminClient {
         return groupId == null;
     }
 
+    //for testing
+    int numPendingCalls() {
+        return runnable.pendingCalls.size();
+    }
+
     @Override
     public CreateTopicsResult createTopics(final Collection<NewTopic> newTopics,
                                            final CreateTopicsOptions options) {
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 12b076d..4c7c8ae 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
@@ -342,6 +342,11 @@ public class KafkaAdminClientTest {
             // Wait until the first attempt has failed, then advance the time
             TestUtils.waitForCondition(() -> mockClient.numAwaitingResponses() == 1,
                     "Failed awaiting CreateTopics first request failure");
+
+            // Wait until the retry call added to the queue in AdminClient
+            TestUtils.waitForCondition(() -> ((KafkaAdminClient) env.adminClient()).numPendingCalls()
== 1,
+                "Failed to add retry CreateTopics call");
+
             time.sleep(retryBackoff);
 
             future.get();


Mime
View raw message