To address sporadic failures 31/82531/1
authorEdw7n <n.edwin.anthony@ericsson.com>
Mon, 17 Jun 2019 15:53:33 +0000 (21:23 +0530)
committerEdw7n <n.edwin.anthony@ericsson.com>
Mon, 17 Jun 2019 15:53:33 +0000 (21:23 +0530)
- addresses failures seen in autoRelease
- clean up of explicit sleeps in the Junit
- replaced sleep with awaitsEventConsumption:q

Change-Id: I97fa44da04d38afe67aa9d4adc8b7314078ebb4d
Signed-off-by: Edw7n <n.edwin.anthony@ericsson.com>
itm/itm-impl/src/test/java/org/opendaylight/genius/itm/tests/ItmTepAutoConfigTest.java

index 3107de573ab2b9a32766a0e95783f9d9bd7eaa67..b8919de0e08dcefdbb503c1da2e4d285b695d9f4 100644 (file)
@@ -13,12 +13,10 @@ import static org.opendaylight.mdsal.binding.testutils.AssertDataObjects.assertE
 import com.google.common.base.Optional;
 import com.google.common.util.concurrent.CheckedFuture;
 import com.google.common.util.concurrent.ListenableFuture;
-
 import java.math.BigInteger;
 import java.util.ArrayList;
 import java.util.List;
 import javax.inject.Inject;
-
 import org.junit.Assert;
 import org.junit.Before;
 import org.junit.Ignore;
@@ -117,8 +115,7 @@ public class ItmTepAutoConfigTest {
         ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(false).build();
 
         // write into config DS
-        txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(iid, itmConfigObj, true));
-        Thread.sleep(1000);
+        txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(iid, itmConfigObj, true)).get();
 
         // read from config DS
         boolean defTzEnabled = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(
@@ -133,8 +130,7 @@ public class ItmTepAutoConfigTest {
         ItmConfig itmConfigObj = new ItmConfigBuilder().setDefTzEnabled(true).build();
 
         // write into config DS
-        txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(iid, itmConfigObj, true));
-        Thread.sleep(1000);
+        txRunner.callWithNewWriteOnlyTransactionAndSubmit(CONFIGURATION, tx -> tx.put(iid, itmConfigObj, true)).get();
         // read from config DS
         boolean defTzEnabled = SingleTransactionDataBroker.syncReadOptionalAndTreatReadFailedExceptionAsAbsentOptional(
             dataBroker, LogicalDatastoreType.CONFIGURATION, iid).get().isDefTzEnabled();
@@ -822,6 +818,7 @@ public class ItmTepAutoConfigTest {
                 ItmTepAutoConfigTestUtil.addTep(ItmTestConstants.NB_TZ_TEP_IP,
                         ItmTestConstants.DEF_BR_DPID, ItmTestConstants.TZ_NAME, false, dataBroker, txRunner);
         futures.get();
+        coordinatorEventsWaiter.awaitEventsConsumption();
 
         IpPrefix subnetMaskObj = ItmUtils.getDummySubnet();
 
@@ -848,7 +845,7 @@ public class ItmTepAutoConfigTest {
         //check deleted tz moved to notHosted
         InstanceIdentifier<TepsInNotHostedTransportZone> notHostedPath =
                 ItmTepAutoConfigTestUtil.getTepNotHostedInTZIid(ItmTestConstants.TZ_NAME);
-
+        coordinatorEventsWaiter.awaitEventsConsumption();
         Assert.assertNotNull(notHostedPath);
         Assert.assertEquals(ItmTestConstants.TZ_NAME, dataBroker.newReadOnlyTransaction()
                 .read(LogicalDatastoreType.OPERATIONAL, notHostedPath).checkedGet().get().getZoneName());