You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@atlas.apache.org by sa...@apache.org on 2019/04/29 06:49:45 UTC

[atlas] branch master updated: ATLAS-3168: Fix intermittent UT failure: KafkaNotificationTest.initNotificationService()

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

sarath pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/atlas.git


The following commit(s) were added to refs/heads/master by this push:
     new ed288a7  ATLAS-3168: Fix intermittent UT failure: KafkaNotificationTest.initNotificationService()
ed288a7 is described below

commit ed288a759c556c704c824eb921c81b563a32f3e9
Author: Sarath Subramanian <ss...@hortonworks.com>
AuthorDate: Sun Apr 28 23:49:34 2019 -0700

    ATLAS-3168: Fix intermittent UT failure: KafkaNotificationTest.initNotificationService()
---
 .../apache/atlas/kafka/KafkaNotificationTest.java  | 27 +++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java b/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
index 63114bf..9b3535e 100644
--- a/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
+++ b/notification/src/test/java/org/apache/atlas/kafka/KafkaNotificationTest.java
@@ -40,7 +40,7 @@ public class KafkaNotificationTest {
 
     @BeforeClass
     public void setup() throws Exception {
-        initNotificationService();
+        startNotificationServicesWithRetry();
     }
 
     @AfterClass
@@ -77,6 +77,31 @@ public class KafkaNotificationTest {
         consumer.close();
     }
 
+    // retry starting notification services every 2 mins for total of 20 mins
+    // running parallel tests will keep the notification service ports occupied, hence retry
+    void startNotificationServicesWithRetry() throws Exception {
+        long totalTime = 0;
+        long sleepTime = 2 * 60 * 1000; // 2 mins
+        long maxTime   = 20 * 60 * 1000; // 20 mins
+
+        while (true) {
+            try {
+                initNotificationService();
+                break;
+            } catch (Exception ex) {
+                cleanUpNotificationService();
+
+                if (totalTime >= maxTime) {
+                    throw ex;
+                }
+
+                Thread.sleep(sleepTime);
+
+                totalTime = totalTime + sleepTime;
+            }
+        }
+    }
+
     void initNotificationService() throws Exception {
         Configuration applicationProperties = ApplicationProperties.get();