This is an automated email from the ASF dual-hosted git repository.
sarath pushed a commit to branch branch-2.0
in repository https://gitbox.apache.org/repos/asf/atlas.git
The following commit(s) were added to refs/heads/branch-2.0 by this push:
new 12f468a ATLAS-3168: Fix intermittent UT failure:
NotificationHookConsumerKafkaTest.initNotificationService()
12f468a is described below
commit 12f468a313f96f799657047ae055b5be48e4840e
Author: Sarath Subramanian <[email protected]>
AuthorDate: Sun Aug 4 23:54:43 2019 -0700
ATLAS-3168: Fix intermittent UT failure:
NotificationHookConsumerKafkaTest.initNotificationService()
(cherry picked from commit fb54a29db5a3a454f237341e7be60fb2f12de5fc)
---
.../NotificationHookConsumerKafkaTest.java | 29 ++++++++++++++++++++--
1 file changed, 27 insertions(+), 2 deletions(-)
diff --git
a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java
b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java
index 940c639..93675e8 100644
---
a/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java
+++
b/webapp/src/test/java/org/apache/atlas/notification/NotificationHookConsumerKafkaTest.java
@@ -85,7 +85,7 @@ public class NotificationHookConsumerKafkaTest {
private AtlasMetricsUtil metricsUtil;
@BeforeTest
- public void setup() throws AtlasException, InterruptedException,
AtlasBaseException {
+ public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
AtlasType mockType = mock(AtlasType.class);
@@ -95,7 +95,7 @@ public class NotificationHookConsumerKafkaTest {
when(instanceConverter.toAtlasEntities(anyList())).thenReturn(mockEntity);
- initNotificationService();
+ startNotificationServicesWithRetry();
}
@AfterTest
@@ -228,6 +228,31 @@ public class NotificationHookConsumerKafkaTest {
kafkaNotification.send(NotificationInterface.NotificationType.HOOK,
message);
}
+ // retry starting notification services every 2 mins for total of 30 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 = 30 * 60 * 1000; // 30 mins
+
+ while (true) {
+ try {
+ initNotificationService();
+ break;
+ } catch (Exception ex) {
+ cleanUpNotificationService();
+
+ if (totalTime >= maxTime) {
+ throw ex;
+ }
+
+ Thread.sleep(sleepTime);
+
+ totalTime = totalTime + sleepTime;
+ }
+ }
+ }
+
void initNotificationService() throws AtlasException, InterruptedException
{
Configuration applicationProperties = ApplicationProperties.get();