You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/02/26 12:28:45 UTC

[GitHub] [kafka] showuon commented on a change in pull request #10185: KAFKA-12284: wait for mm2 auto-created the topic

showuon commented on a change in pull request #10185:
URL: https://github.com/apache/kafka/pull/10185#discussion_r583604108



##########
File path: connect/mirror/src/test/java/org/apache/kafka/connect/mirror/integration/MirrorConnectorsIntegrationBaseTest.java
##########
@@ -455,27 +470,44 @@ private static void waitUntilMirrorMakerIsRunning(EmbeddedConnectCluster connect
                     "Connector " + connector.getSimpleName() + " tasks did not start in time on cluster: " + connectCluster);
         }
     }
- 
+
+    /*
+     * wait for the topic created on the cluster
+     */
+    private static void waitForTopicCreated(EmbeddedKafkaCluster cluster, String topicName) throws InterruptedException {
+        try (final Admin adminClient = cluster.createAdminClient()) {
+            waitForCondition(() -> adminClient.listTopics().names().get().contains(topicName), OFFSET_SYNC_DURATION_MS,
+                "Topic: " + topicName + " didn't get created in the cluster"
+            );
+        }
+    }
+
     /*
      * delete all topics of the input kafka cluster
      */
     private static void deleteAllTopics(EmbeddedKafkaCluster cluster) throws Exception {
-        Admin client = cluster.createAdminClient();
-        client.deleteTopics(client.listTopics().names().get());
+        try (final Admin adminClient = cluster.createAdminClient()) {
+            Set<String> topicsToBeDeleted = adminClient.listTopics().names().get();
+            log.debug("Deleting topics: {} ", topicsToBeDeleted);
+            adminClient.deleteTopics(topicsToBeDeleted).all().get();
+        } catch (final Throwable e) {

Review comment:
       @mimaison , I just wanted to catch all exceptions here. Do you think it's better we catch specific exceptions here?




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org