pnowojski commented on a change in pull request #7520: [FLINK-11293][kafka, 
test] Added timeout to delete topic request.
URL: https://github.com/apache/flink/pull/7520#discussion_r248757349
 
 

 ##########
 File path: 
flink-connectors/flink-connector-kafka/src/test/java/org/apache/flink/streaming/connectors/kafka/KafkaTestEnvironmentImpl.java
 ##########
 @@ -155,10 +159,23 @@ public void prepare(Config config) {
        public void deleteTestTopic(String topic) {
                LOG.info("Deleting topic {}", topic);
                try (AdminClient adminClient = 
AdminClient.create(getStandardProperties())) {
-                       
adminClient.deleteTopics(Collections.singleton(topic)).all().get();
+                       tryDelete(adminClient, topic);
                } catch (Exception e) {
                        e.printStackTrace();
-                       fail("Delete test topic : " + topic + " failed, " + 
e.getMessage());
+                       fail(String.format("Delete test topic : %s failed, %s", 
topic, e.getMessage()));
+               }
+       }
+
+       private void tryDelete(AdminClient adminClient, String topic)
+                       throws ExecutionException, InterruptedException, 
TimeoutException {
+               try {
+                       
adminClient.deleteTopics(Collections.singleton(topic)).all().get(DELETE_TIMEOUT_SECONDS,
 TimeUnit.SECONDS);
+               } catch (TimeoutException e) {
+                       LOG.info("Did not receive delete topic response within 
%d seconds. Checking if it succeeded",
+                               DELETE_TIMEOUT_SECONDS);
+                       if 
(adminClient.listTopics().names().get(DELETE_TIMEOUT_SECONDS, 
TimeUnit.SECONDS).contains(topic)) {
+                               fail(String.format("Delete test topic : %s 
failed.", topic));
 
 Review comment:
   replace `fail(...)` with `throw e;`? Would deduplicate the error handling?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to