Commit ed288a75 by Sarath Subramanian

ATLAS-3168: Fix intermittent UT failure: KafkaNotificationTest.initNotificationService()

parent b7af1096
......@@ -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();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment