sijie closed pull request #2600: [tests] make PersistentQueueE2ETest tolerant 
failures during deleting topic at cleanup
URL: https://github.com/apache/incubator-pulsar/pull/2600
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentQueueE2ETest.java
 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentQueueE2ETest.java
index c41a07a2cb..2937ca0caf 100644
--- 
a/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentQueueE2ETest.java
+++ 
b/pulsar-broker/src/test/java/org/apache/pulsar/broker/service/PersistentQueueE2ETest.java
@@ -35,6 +35,7 @@
 import org.apache.commons.collections.CollectionUtils;
 import org.apache.pulsar.broker.service.persistent.PersistentSubscription;
 import org.apache.pulsar.broker.service.persistent.PersistentTopic;
+import org.apache.pulsar.client.admin.PulsarAdminException;
 import org.apache.pulsar.client.api.Consumer;
 import org.apache.pulsar.client.api.ConsumerBuilder;
 import org.apache.pulsar.client.api.Message;
@@ -76,6 +77,14 @@ protected void cleanup() throws Exception {
 
     private static final Logger log = 
LoggerFactory.getLogger(PersistentQueueE2ETest.class);
 
+    private void deleteTopic(String topicName) {
+        try {
+            admin.topics().delete(topicName);
+        } catch (PulsarAdminException pae) {
+            // it is okay to get exception if it is cleaning up.
+        }
+    }
+
     @Test
     public void testSimpleConsumerEvents() throws Exception {
         final String topicName = "persistent://prop/use/ns-abc/shared-topic1";
@@ -172,7 +181,7 @@ public void testSimpleConsumerEvents() throws Exception {
         producer.close();
         consumer2.close();
 
-        admin.topics().delete(topicName);
+        deleteTopic(topicName);
     }
 
     @Test
@@ -220,7 +229,8 @@ public void testReplayOnConsumerDisconnect() throws 
Exception {
         assertTrue(CollectionUtils.subtract(messagesProduced, 
messagesConsumed).isEmpty());
 
         consumer1.close();
-        admin.topics().delete(topicName);
+
+        deleteTopic(topicName);
     }
 
     @Test
@@ -279,7 +289,8 @@ public void testConsumersWithDifferentPermits() throws 
Exception {
 
         consumer1.close();
         consumer2.close();
-        admin.topics().delete(topicName);
+
+        deleteTopic(topicName);
     }
 
     // this test is good to have to see the distribution, but every now and 
then it gets slightly different than the
@@ -352,7 +363,8 @@ public void testRoundRobinBatchDistribution() throws 
Exception {
         consumer1.close();
         consumer2.close();
         consumer3.close();
-        admin.topics().delete(topicName);
+
+        deleteTopic(topicName);
     }
 
     @Test(timeOut = 300000)
@@ -550,6 +562,7 @@ public void testUnackedCountWithRedeliveries() throws 
Exception {
         producer.close();
         consumer1.close();
         consumer2.close();
-        admin.topics().delete(topicName);
+
+        deleteTopic(topicName);
     }
 }


 

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to